Notifications
Clear all

[Closed] ListBox items to Node

Hey,

I’m using a ListBox, and Omni01 is in the list.
I’m trying to import Omni01 into FumeFX lights.

How can i convert that to a Node?
Unable to convert: #("Omni01") to type: <node>

Thanks
Nahuel

9 Replies
 JHN

You’re are getting back an array of strings (one string in this case), I’m guessing you’re using either a multilistbox or the listbox.items property.

If listbox:


-- Get single node
getNodeByName yourlistBox.selected
or
getNodeByName yourlistBox.items[yourlistBox.selection]

If multilistbox:


 -- Get single node (dealing with bitArray
for i = 1 to multilistbox.selection.count where multilistbox.selection[i] == true do
   getNodeByName multilistbox.items[i]

This code is untested, and you’re not providing a good example, so your mileage may vary. But it will get you on the right track.

-Johan

Thanks! It worked!

I was using a ListBox.

How can i make the same but with all the items in the ListBox?

I tried:

getNodeByName lbx1.items 

But it didn’t work.

I get this error:

Unable to convert: #("Omni01", "Omni02") to type: String
 JHN
-- returns an array of nodes
allNodes = for item in listbox.items collect getNodeByName item

-- now you can use the nodes like a selection for example
select allNodes
-- or pass to other functions expection node input

-Johan

allNodes = for item in listbox.items collect getNodeByName item

Do i only need to change the “listbox.items” name?

I get:

Unable to convert: #($Omni_Light:Omni02 @ [1.698181,-67.988297,42.913687], $Omni_Light:Omni01 @ [108.703026,30.566040,49.102013]) to type: <node>
 JHN

This is the time you need to show more code.
Also pay attention to the error, it says “I can’t convert an array to an node”. So the obvious task is to get the node out the array. What you do now is open up the maxscript help file and look for array. There you will find you can access array members by using a iterator or address.


-- 2 ways, 1 direct assigment
for node in theNodes do
(
   yourActionWith node
)
-- 2 get node from array by itterator
for i = 1 to theNodes.count do
(
   yourActionWith theNodes[i]
)

That’s all I can help, so if it’s not clear please show the code or function you want to assign the nodes to.

-Johan

If you replace line 73 with:

[b]allNodes[/b] = getNodeByName lbx1.selected
 

it works, but only with the selected item.

Make sure line 74, has the “allNodes” at the end:


 GenFFX_1 container_file.text [b]allNodes[/b]

More info:
I need to add all the lights listed in the ListBox to FumeFX.
This is the code that does that:

FumeGrp[i].lights = FumeLightGrp