PDA

View Full Version : using maxscript to switch off mat displacement


SandeepMaithani
07-11-2011, 04:20 PM
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

j-man
07-11-2011, 04:29 PM
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.

JHN
07-11-2011, 11:18 PM
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 "% : %\n" 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

SandeepMaithani
07-12-2011, 06:22 AM
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....

floopyb
07-12-2011, 07:05 AM
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.

JHN
07-12-2011, 07:46 AM
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

SandeepMaithani
07-12-2011, 08:20 AM
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

i did apply the materials on objects...

JHN
07-12-2011, 09:05 AM
Weird, maybe post a sample scene?

-Johan

j-man
07-12-2011, 10:44 AM
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.

JHN
07-12-2011, 11:58 AM
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

j-man
07-12-2011, 12:13 PM
Hey Johan I'm not going head to head with you, I'll be blown out of the water! <:

J.

SandeepMaithani
07-12-2011, 01:14 PM
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.

woha...bang on..thnks buddy

denisT
07-12-2011, 02:36 PM
...
But yeah, yours works too...


going the way of minimalism:

if (mats = getclassinstances Arch___Design__mi).count > 0 do
mats.displacement_map_on = off

JHN
07-12-2011, 04:23 PM
try (getClassInstances Arch___Design__mi).displacement_map_on = off catch()


Or to apply only to scene materials


try (getClassInstances Arch___Design__mi target:sceneMaterials).displacement_map_on = off catch()


:)

-Johan

CGTalk Moderation
07-12-2011, 04:23 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.