String array in multilist box to object selection

Hi guys,
need a little help.

What i have going on in the script is as following.

1: select all the objects in the max file by select $*
2: i filter that selection by type il.e class of obj == pf source
3: store the same in a variable e.g A
4: copy the to another variable B so i can use the same in multilistbox
5: create rollout and button to run other scripts.
6: Lists the selection properly
uptil here every thing is fine
7: now here's the problem the script from here onwards which was copied from

heres the problem i am trying to solve multilistbox has capability to select multiple listed items using ctrl unlike listbox

what i would like to do is select multiple items in there and run scripts on them ex modifying common properties etc....

I have attached both the script file and a demo max scene to test this out :)

more details in the script below.

Thanks in advance...

	to test please create 2-3 pf sources (rename them optional will work either ways) in the scene along with some random geo e.g sphere, torus, teapot etc.
	the script will automatically filter out pfsource objects from the scenefile
	What i am stuck with is in the comments below under rollout after on_Process pressed do
	The Idea behind the script is when doing sims on large scale scene files with lots of PF source objects it would be nice to select 
	a bunch from the lest and rund scripted commands as selecting from selectbyname menu or viewport would be cumbersome and subject to mistakes
	one example would be desable render or maybe recalculate caches on selected pf sources etc.
	Also this is especially helpful when your pf sources or other objects are are named inconsistantly 
	I plan to retro fit this script to various object types and run scripted procidures on the selection
-- Define Variables
PartiGrp = #()
PartiList = #()
--slect and list pfsource
select $*
if $!= $selection then
	PartiGrp[1] = $
	PartiList = PartiGrp[1].name
	for obj in ($ as array) do
		if classof obj == PF_Source do
			append PartiGrp obj
			for i = 1 to PartiGrp.count do
				PartiList[i] = (PartiGrp[i].name)
--UI setup
try(destroyDialog _PartiSub )catch()
rollout _PartiSub "PF source global CTRL" 
	Multilistbox _Multilistbox "Particle souce" items: PartiList
	button _Process "Process" 
	on _Process pressed do
		question is what if i want multiple partilce system selected so i can run scripted functions of 
		Code below enables me to slelect one node at a time by pressing sumbit button if i select more then one it does not work.
		Beauty of multilistbox is you can ctrl + select more items from the list
		_selIndex = (_Multilistbox.selection as array)[1]
		-- "select fume grids"
		select PartiGrp[_selIndex]
createdialog _PartiSub
4scriptspot.ms1.93 KB
pfsouce_eg.max320 KB


Comment viewing options

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

select (for index in

select (for index in _Multilistbox.selection collect PartiGrp[index])

desigringo's picture

thanks you swordslayer,

thanks you swordslayer,
will try this it seems i was not subscribed to the thread so didnt get notifaciton....

Thanks a ton in advance....


Comment viewing options

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