Notifications
Clear all

[Closed] Selecting object by raytraced material

Hi
I’m new to Maxscript and I would like to create a script to select all the object in the scene which have a raytrace map in their material (diffuse or reflection slot)

I already tried a few things but failed. I think it can be done with one single for loop.

select (for o in objects where o.material … = raytrace () collect o)
=> I wonder how to reach the material maps after o.material

Can anyone help me?

3 Replies

Create a box, assign a standard material to the box and type:

show $.material

You’ll find out all of the properties a material has, this one looks interesting!

.reflectionMap

If you put a raytrace material in the slot and type

classof $.material.reflectionMap

It spits out


  Raytrace

evaluate:

(classof $.material.reflectionMap) == Raytrace
 [i]true[/i]

True! Perfect! You’ll also want to check the classof $.material for RaytraceMaterial to get the actual RT Mat.

^ Use these to help you figure out these problems in the future

If you’re using VRay Materials, then calling .diffuseMap will throw an exception, use the method described above to find it’s properties! Also check for isProperty $.material #reflectionMap to see if it exists so it doesn’t throw an error.

Best of luck Scripting,
Colin

Moondoggie
I couldn’t dream for a better reply than yours, thanks a lot for your very useful help!!!

It’s all clear now

Absolutely, Happy scripting!

-Colin