[Closed] Problem with multilistbox and bitarray
I’m trying to build a script which handle the exclusion/inclusion list for chosen lights.
In it I have a multilistbox listing the current excluded or included objects for a chosen light and a remove button who should remove the selected item(s) of the multilistbox.
Problem:
with a simple listbox it’s easy, a “mylistbox.items = deleteItem mylistbox.items mylistbox.selection” do the job, ’cause the value of the mylistbox.selection is not a bitarray, so i can use this method.
With the multilistbox (which has the avantage to allow multiple selection) it’s impossible because the value of the .items and .selection are incompatible.
Does anyone now a solution for this problem ?
Thanks
you need to delete them individualy…and backwards as deleting item #2 moves item #3 into the #2 spot…
DelListItems = ( mylistbox.selection as array)
for DelIndex = DelListitems.count to 1 by -1 do ( deleteitem Mylistbox.items DelIndex)
I don’t have max in front of me, but something like this should work. You may need to close and open your dialog or rollout out for it to update…
Good luck
Keith Morrison
Thank you, I succeed…to find an ever bigger problem. Now when i select the objects i want to remove from my multilistbox and press the remove button, the list updates with no problem, BUT the finallity is of course to match the content of this listbox to the one of the include/exclude list of the selected light.
Problem : I can’t link the two of them. A easy way would be to said for exemple
mylight.includelist = mylistbox.items, but it doesn’t work ’cause the 2 arrays seems incompatible (one is a list of string, the other one a list of nodes.)
I’m getting crazy, and for sure it’s not something very hard to do, but i’m stick on it.
(
local HoldInc=#()
local x
HoldInc = Mylight.includeList – Make temp Array to hold Includes, I don think Deleteitem works on .includelist
for x=HoldInc.count to 1 by -1 do – Step Through Array backwards again, same reason.
(
CheckObj = HoldInc[x]
– if the name of the object is not found in the Mylistbox.items string array then delete
if ( finditem Mylistbox.items CheckObj.name != 0) then
(
delete HoldInc x
)
)
Mylight.includeList = HoldInc
)
Most of the time you need to create loops for comparing arrays…
good luck
Keith Morrison
Agin thanks, now my script works.
As I said here http://www.cgtalk.com/showpost.php?p=1688502&postcount=5 I can post it for intersted people.