[Closed] select list of objects
I’m trying to create object selector to select geometry in scene for batch processing. Similiar to Particle Flow’s Position Object for selecting emiter objects. So far have gotten add and remove button to work but can’t seem to fiture out how to select object using “By list”.
Is there a way to Add object to listbox while being able to not select objects which are already listed in listbox? Have tried using ‘matchPattern’ and ‘findString’ without much luck.
Also is it possible to use multilistbox for object selection? Keep getting errors when trying to use ‘deleteItem’ to remove objects with remove button.
Here’s part of code I’m using.
groupBox groupReactor_Batch “Batch Process” pos:[20,390] width:300 height:120
–Multi
ListBox MO_Reactor_list width:150 height:4 selection:0 pos:[30,410] –items:#()
pickbutton MO_Reactor_Add “Add” width:30 height:15 pos:[40,475] filter:geometry_filter
button MO_Reactor_ByList “By List” width:40 height:15 pos:[70,475]
button MO_Reactor_Remove “Remove” width:50 height:15 pos:[120,475]
progressBar MO_Reactor_prgrsbr width:280 height:5 pos:[30,500] color:[0,0,255]
button MO_Reactor_Process “Process…” width:80 height:40 pos:[210,430]
on MO_Reactor_list selected nameIndex do
try(
select (getNodeByName MO_Reactor_list.items[nameIndex])
)catch()
on MO_Reactor_Add picked obj do
(
try(
ss = MassRollout.MO_Reactor_list.items –(ss as string)
blah = obj.name
– if findString ss blah != undefined then
– if matchPattern ss pattern:blah != undefined then
(
mass_object = obj
MO_Reactor_list.items = append MO_Reactor_list.items (mass_object.name as string)
–matchPattern s pattern:“text?”
)
)catch()
)
on MO_Reactor_ByList pressed do
(
max tool hlist
mass_object = obj
MO_Reactor_list.items = append MO_Reactor_list.items (mass_object.name as string)
)
on MO_Reactor_Remove pressed do
(
try(
–delete (getNodeByName MassRollout.MO_Reactor_list.selected)
temp = MassRollout.MO_Reactor_list.items
itm = MassRollout.MO_Reactor_list.selection
deleteItem temp MassRollout.MO_Reactor_list.selection
MassRollout.MO_Reactor_list.items = temp
)catch()
)
my idea when select objs and show it in list box :
-
get all objects needed in a array .
eg:
local theobjs = for i in geometry where i.material != undefined collect i -
set another array for show them in list box :
eg:
local theobjs_Name_show = for i in theobjs collect i.name
theListBox.items = theobjs_name_show -
then if u select a objs in the listbox , u will get the index of the it . the index can be used in theobjs array too .
eg:
– if u select someone of the list box
– get the index selected .
local theIndex_selected = theListBox.selection
– use the index in theobjs selection .
select theobjs[theIndex_selected]
– select the inverse objs of theobjs .
clearselection ()
for i=1 to theobjs.count do ( if i!=theIndex_selected do selectmore i )
– if u delete something in the list box then , u can do in 2 steps
– first : delete the objs in theobjes array with the index selected .
– sec: delete the item of show in the list box . then refresh the list box items array.
– or rebuild theobjs_Name_show if necessary .
maybe helpful .