Notifications
Clear all

[Closed] Selecting Objects with an instanced modifier

I’m Trying to write a script that will cycle through all the modifiers on the selected object & select all objects with the same Instanced modifier. It was simple to do it for instanced objects but for a noob in maxscript like me, the above was hard.
BTW I’m trying to keep it simple.

Thanks in advance.

4 Replies

try this

macroScript SelInstMod – by COOPER–
category:”_Tools”
(
on execute do
(
myobjs = #()
sourceobj = selection[1]
sourcemod = modPanel.getCurrentObject()
myobjs[1] = sourceobj

for i in objects where i != sourceobj do 
(
for j = 1 to i.modifiers.count do
	(
	if i.modifiers[j] == sourcemod then append myobjs i
	)
)
select myobjs 
)

)

Thanks Secco That helped a lot.
But this does not cycle thru the modifiers apparently, Rather it selects the objects that has the same instance of the modifier highlighted. Which means there must be a way to put it inside a loop that will cycle through the modifiers in the stack and filter and add to selection any object that contains an instance of the modifier.

But that will work for now. It gives more control. especially that most objects I’m using have 3 modifiers at most.

this should do what you want:

(
   obj = selection[1]
   dependentObjects = #()
   -- for max 2008 or higher OR with the Avguard Extensions use:
   for m in obj.modifiers do join dependentObjects (refs.dependentNodes m)
   -- for pre-2008 max without Avguard Extensions use:
   --for m in obj.modifiers do join dependentObjects (for r in (refs.dependents m) where isValidNode r collect r)
   select dependentObjects
   )

check out refs.dependents etc in the docs

Thanks Gravey that was great. Exactly what I need, a script that doesn’t look at each object in the scene and see if it has an instance, which makes it a bit faster for very large scenes with hundreds of objects.

And thanks again secco I learned from your script too