[Closed] Assigning textures to a list of items
Hi!
I’m trying to use a for loop to go through a list of items, assign an existing texture to each one, then apply a different texture to one of them (This is all part of a greater loop that renders each version seperately). However, I’m having some trouble with the syntax:
for i=1 to lbx1.items.count do
(
for j=1 to lbx1.items.count do
(
(getNodeByName lbx1.items[j]).material = currentMaterialLibrary["Matte"]
)
lbx1.selection = i
(getNodeByName lbx1.items[i]).material = currentMaterialLibrary["Red"]
)
Does anyone know what the proper way to type this is?
A quick easy way to code this is to use the material editor slots for telling the script which material to use, the slots are numbered 1 to 24.
$.material = meditmaterials[1]
Any help?
Still not working, unfortunately. While I’m sure that’s the proper way to assign a material, I seem to be having trouble telling it what object to apply it to. When I use the code,
getNodeByName lbx1.items[j].material = meditmaterials[1]
I get the error,
--No ""="" function for (Global:getNodeByName (prop material * ((prop items RolloutControl:lbx1 in rollout:myWin)[local:j])))
As near as I can tell, this means I’m not getting the calling of the name right, though that syntax works fine everywhere else I try to use it. Any suggestions?
If your listbox (lbx1) stores the nodes names, it should work like this:
(getNodeByName lbx1.items[j]).material = meditMaterials[1]
You need to get the node first, before you can assign a material to it.
Hey, that worked great! Thanks a lot!
Also, if it’s not too much to ask, does anyone know how to delete items from a listbox? I have a couple different ones and I don’t want overlap between them