Notifications
Clear all

[Closed] Selectionset problem

I just started to learn maxscript 2 weeks ago, so go easy on me.

I have a bunch of renderelements and a bunch of selectionsets both with certain names,
It is a finalrender RE so it has this function : addnode which adds objects to it.
So I want to match between REs and selsets so that certain REs gets the objects in certain selsets


 (
   for i=0 to ((re.NumRenderElements())-1) 
   where (matchPattern ((re.getrenderelement i).elementname) pattern:("*_light*" ))
    do
    (
 	For o =1 to selectionSets.count
 	where (matchpattern (getNamedSelSetName o) pattern:("fr_*"))
 	 do o=(
     		  for j in (getNamedSelSetItem o (for x=1 to getNamedSelSetItemCount o do x))
 			   do
 			   (
 				el = re.getrenderelement i
 				el.setmode(1) 
 				 el.addnode(j)
 				)
 	)
    )
   )

The problem in x, I think, it gives ok instead of numbers when i tried it alone with print it gives me the numbers then ok
I cann’t get a certain selset as objects why the result of selectionsets [1] for example equal selectionset:xxx and not xxx which is an array,isn’t it??

4 Replies

standard MAX renderElement doesn’t have methods setmode and addnode…

but…

to go thought all selections sets you can use:
for ss in selectionssets do (…)

to go thought all nodes in selectionset you can use:
for node in ss do (…)

any selectionset has the property “name”, so you can directly use ss.name to get the name

to get the selection set by name you can use:
selectionsets[“TheName”]

thank you very much

but
for ss in selectionssets do (…)
don’t result ss as one selectionset at a time it results all objects in all sets at once
even when I use that:

(
 For i =1 to selectionSets.count do
(
 For z in selectionSets  
where (matchpattern (getNamedSelSetName i) pattern:("fr_*"))
 do
 (
for  a=0 to ((re.NumRenderElements())-1) 
 where 	(matchPattern ((re.getrenderelement a).elementname) pattern:(("*" )+stnm))
 do 
 (for w=1 to z.count do
(el = re.getrenderelement a
el.setmode(1) 
el.addnode(z[w])
)																
)
)
)
)

i don’t understand the problem…
in loop of:
for ss in selectionsets … ss IS selectionset.


 for ss in selectionsets do format "name:% class:% node:%
" ss.name (classof ss) ss
 

you probably want to collect all nodes by selection set… in this case you have to use “for loop collect”:


 nodes_by_selset =  for ss in selectionsets collect #(ss, for node in ss collect node)
 format "count:% data:%
" nodes_by_selset.count nodes_by_selset
 

Again thank you very much for helping
I am sorry the problem was the name( pattern:((“*” )+stnm) should be z.name+(“light” )+stnm) only nothing else The code in my previous reply works with your help and now no problem at all
Thank you