[Closed] using maxscript to switch off mat displacement
Hi guys
How can i check off displacement of all the materials used in the scene thru maxscript? I have a scene with almost 700 objects and all of them are having displacement…its not getting rendered and i need to switch the displacement off.
I could see in the listner how to do it for one material
meditMaterials[1].displacement_map_on = off
but how do i access all the scene materials ??
regds
sandy
Hi Sandy,
This is actually a bit tricky, as there are many different types of materials and not all of them have this property .texmap_displacement_on not to mention the fact that there are also materials that have sub-materials!
So, the way we get around this is to search for every instance of the class VRayMTl and then change that property in every one we find. If we wanted to change a property in a standard material then we would search for all of the instances of the standardmaterial class in the scene and adjust the appropriate property.
item=VRayMtl
for n in (getclassinstances item) do n.texmap_displacement_on=false
Josh.
And here’s my take on it
(
-- Set displaceState
local dispState = false
-- Create undo buffer
if not theHold.holding() do theHold.Begin()
-- Start material loop
for mat in material.classes where (local mats = getClassInstances mat target:sceneMaterials).count != 0 and \
(local props = (for propName in getPropNames mat where matchPattern propName pattern:"*disp*" collect propName)).count != 0 do
(
format "% : %
" mat props
for m in mats do
for prop in props where isKindOf (getProperty m prop) BooleanClass do
(
setProperty m prop dispState
)
)
-- Commit displacement buffer
theHold.Accept ("Materials | Set displacement to : " + dispState as string)
)
It will work for all materials that have disp in their properylist. Unfortunatly it doesn’t work for standard materials as it seems the displacement map name has to be accessed through the mapEnabled array attribute. The alias is not exposed to getPropNames…
But it will do mrArchDesign mat and all other materials that have a property with “disp” in it,
-Johan
Thnks for looking into this but it didnt work…i created two archn design mats with a map in disp slot…the script didnt check them off…i just a message saying ok…
In the actual situation, i’ve a lot of mats in multisubobject material which have displacement on them which i need to turn off…
You can try this script:
http://www.scriptspot.com/3ds-max/scripts/modifier-modifier-zorb
Just go to the “Material” tab (can take a while to collect all the material in the scene!!) and double click on the material class you wish to mass edit, then find the displacement_map_on checkbox to turn off
It works fine with the arch_design mats, and they can be in multi subs or wherever.
The only problem i know is that it can get a bit iffy when you have standard materials that are set to different types (anistrophic/metal etc)
Hope it helps.
My script only works for scenematerials, so materials that are actually used in the scene by objects, it won’t affect materials in the material editor that are not assigned to an object.
-Johan
Geez, and I gave you all of the clues!
item=Arch___Design__mi
for n in (getclassinstances item) do n.displacement_map_on=false
Works on every instance of a A&D material in the scene, even probably the ones in the scene of the guys sitting next to you.
J.
But Joshua, mine looks so much more cool, I even added comments and stuff, look even undo is there too…
But yeah, yours works too
-Johan
Hey Johan I’m not going head to head with you, I’ll be blown out of the water! <:
J.