Slate material editor : Create a BezierFloat node to control every UV_Tile on selected nodes

Hey everyone !

I'd like to have a script wich create a Bezier float node in the slate material editor and then connect it to every selected node which have the UV Tile property.

So i can change the tiling easyly on a lot of node.

I don't know how to connect node together and I don't know how to check the property of the selected node...

Please help !

SelView = sme.GetView sme.ActiveView		--get active view
SelNode = SelView.getSelectedNodes()		--get selectednode
 
UVctrl = Bezier_Float()				--create a float controller
UVctrlNode = SelView.CreateNode UVctrl NodePos	--create the node in the active view
UVctrlNode.name = "Uv_TileController"		--change the name of the bezier node
 
 
for i = 1 to SelNode.count do
	(
	/*
	here what i want to do but can't	
	-test if SelNode[i] hasproperty uvtile 
	-if true connect the controller to the property
 
	*/
	)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
TsveTan's picture

Add custAttributes!

Use custAttributes to add a property to a given node . If the property name is "uv_tile" access its value as node.uv_tile.

pixamoon's picture

`

Hi,
So far I've got this way to connect Bezier_Float to U_Tiling and v_Tiling:

(
local av = sme.ActiveView
local SelView = sme.GetView sme.ActiveView		--get active view
local SelNode = SelView.getSelectedNodes()		--get selectednode
local a 
 
UVctrl = Bezier_Float()				--create a float controller
UVctrlNode = SelView.CreateNode UVctrl [10,10]	--create the node in the active view
UVctrlNode.name = "Uv_TileController"		--change the name of the bezier node
 
for i = 1 to rootScene[#SME][av].numsubs where rootScene[#SME][av][i].name == "Uv_TileController" do a = rootScene[#SME][av][i]
 
for sn in SelNode do
	for i = 1 to rootScene[#SME][av].numsubs where classof rootScene[#SME][av][i].reference == Bitmaptexture do (
		rootScene[#SME][av][i].reference.coords.U_Tiling.controller = a.reference
		rootScene[#SME][av][i].reference.coords.V_Tiling.controller = a.reference
	)
)

It works only for selected Bitmap Textures in SME

You will not see wire connection after running script. But if you change Uv_TileController value it will change bitmap U_Tile and V_Tiling values.
To see the wire connection - click on bitmap and choose "Show All Additional Params"

Hope it will help. It still link controllers by names, so if you have duplicating names... it may cause wrong linking.
Best,
Pixamoon

AttachmentSize
slate_material_editor_uv_tiling_2.ms 814 bytes
Christopher.helin's picture

Thanks a lot for your help

Thanks a lot for your help !
I've tried your script and it does exactly what I wanted!
Except it applies the bezier controller to every node in the active view...I don't know if I use it the wrong way...When you tested it was it working on selected node only ?
All the names are unique by the way.

If you don't know I'll try to find a way ;)

Thanks again

Have a nice day !

pixamoon's picture

`

hmm, It should work for selected BitmapTex nodes only.

I'll check it now

pixamoon's picture

`

Ah, sorry, I deleted one thing on cleaning code before post.

This one should be work for selected BitmapTex Nodes only:

(
local av = sme.ActiveView
local SelView = sme.GetView sme.ActiveView	--get active view
local SelNode = SelView.getSelectedNodes()	--get selectednode
local a 
 
UVctrl = Bezier_Float()				--create a float controller
UVctrlNode = SelView.CreateNode UVctrl [10,10]	--create the node in the active view
UVctrlNode.name = "Uv_TileController"		--change the name of the bezier node
 
for i = 1 to rootScene[#SME][av].numsubs where rootScene[#SME][av][i].name == "Uv_TileController" do a = rootScene[#SME][av][i].reference
 
for sn in SelNode do
	for i = 1 to rootScene[#SME][av].numsubs where classof rootScene[#SME][av][i].reference == Bitmaptexture and sn.name == rootScene[#SME][av][i].reference.name do (
		rootScene[#SME][av][i].reference.coords.U_Tiling.controller = a
		rootScene[#SME][av][i].reference.coords.V_Tiling.controller = a
	)
)

Same code attached as ms script. :)

AttachmentSize
slate_material_editor_uv_tiling_3.ms 857 bytes
Christopher.helin's picture

Yeah it's perfect ! thank you

Yeah it's perfect ! thank you !!!

pixamoon's picture

`

You're welcome :) Glad it helped !
Pixamoon

Christopher.helin's picture

The function

The function SelView.getSelectedNodes() return the selected node in the slate but the listener says it's a mixininterface:node. I can't get the UV_Tile property of the node...apparently there's just the '.name' '.position' and '.selected' that working. How can I get the UV_tile property ?

I tried to use 'trackViewNodes[#sme][sme.ActiveView][1].reference.name' to get the name of all node and then compare the name with SelView.getSelectedNodes[1].name

But I'm lost...I don't understand what I'm doing...I just want to connect the selected texturmap Uv property to a bezier node controller...It should not be so hard to do !

SelView = sme.GetView sme.ActiveView			--get active view
SelNode = SelView.getSelectedNodes()			--get selectednode
 
SelNodeName = #()
trackref = #()
trackName = #()
SelTrack = #()
 
 
for n = 1 to selNode.count do  --get the name of selected nodes in the slate
	(
	append SelNodeName selNode[n].name
	)
 
for t=1 to trackViewNodes[#sme][SelView.name].numsubs do
	(
		if superclassof trackViewNodes[#sme][sme.ActiveView][t].reference == textureMap do (append trackName trackViewNodes[#sme][sme.ActiveView][t].reference.name)  --get name of all nodes
 
	for n = 1 to selNode.count do
		(
		if trackName[t] == SelNodeName[n] do (append SelTrack trackViewNodes[#sme][SelView.name][t])  --test if name are the same to get the selected nodes 
		)
	)
 
 
NodePos = [0,0]
UVctrl = Bezier_Float()							--create a float controller
UVctrlNode = SelView.CreateNode UVctrl NodePos	--create the node in the active view
UVctrlNode.name = "Uv_TileController"			--change the name of the bezier node
UVctrlNode.selected = false
 
 
for s=1 to SelTrack.count do 
(
	setproperty SelTrack[s].reference.coords "U_Tiling" UVctrl
	setproperty SelTrack[s].reference.coords "V_Tiling" UVctrl
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.