select object with VRayFastSSS2 material

I want to find and select all object in my scene which have assign VRayFastSSS2 material on it. I evaluate the below script, it print "ok" in maxscript listener, but didn't select any object from the scene? Hoping someone from here can help me, thank you.

select (for o in objects where o.mat == (getClassInstances VRayFastSSS2) collect o)

Comments

Comment viewing options

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

In both of examples we use

In both of examples we use getClassInstances VRayFastSSS2 to get all instances of VRayFastSSS2 material as an array.

Then in first example we iterate through all scene objects and check if array of VRayFastSSS2 (from previous step) contains current object's material and if it does collect this object. And then select objects that are collected

In second example we iterate through collected VRayFastSSS2 materials and collect objects that're dependents of this material.
And then again select collected objects

Suggest you to check maxscript reference for a in detail explanation

jahman's picture

getClassInstances

getClassInstances VRayFastSSS2 -- returns array
o.mat -- returns material if it's applied or undefined
These two will never be equal so it's meaningless to compare them.
You will always get an empty array as a result.

sss2 = getClassInstances VRayFastSSS2
select (for obj in objects where findItem sss2 obj.mat > 0 collect obj)

But what if your sss material is a submaterial?

That's the way to go

mtls = getClassInstances VRayFastSSS2
objs = #()
for m in mtls do join objs (refs.dependentNodes m)
select objs
jackieteh's picture

jahman, thank you for reply,

jahman, thank you for reply, both of your code are work!

i don't understand my code also got a selectMore obj, but why it didn't select anything?

could please explain abit detail about your code?

Regards,

Jackie Teh
website: https://www.sporadicstudio.com/

Comment viewing options

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