How to access material properties via Maxscript

Hi all,

I’m hoping this is very easy and I am just being thick, but I seem to be unable to work out how to add a texture map to the diffuse channel of a Vray material via Maxscript. Is this easy enough?? Basically I want to add maps to diffuse and opacity automatically. This is how I am adding it when using a standard material :

theMaterial.diffusemap = bitmapTex bitmap:theMap

Any help greatly appreciated.

Paul

You can use the showproperties MaxScript function to list all available MaxScript properties of the V-Ray material. For the diffuse texture in particular, you could use something like this:theMaterial.texmap_diffuse=bitmapTex bitmap:theMap

Best regards,
vlado

To show the properties of a material in the first slot of the material editor type this is in the listener window

show meditmaterials[1] -- ([1] is the slot number that you want to see the properties for)

Once that shows you’ll see down the list :

…
.texmap_diffuse : texturemap
.texmap_diffuse_on : boolean
.texmap_diffuse_multiplier : float
.texmap_reflection : texturemap
…

the property texmap_diffuse is what you’re after, you’ll see it takes a texturemap as an input.

Thanks Vlado, i’ll try that..

Thanks Moondoggie,

That’s exactly what i needed..

Just for “best coding practices”, it’s always best to test to make sure a property exists before attempting to change/set it. For instance


mat = meditMaterials[1]

if (isProperty mat "texmap_diffuse") then 
    -- change or do something to the mat.texmap_diffuse (like assign a new bitmap texture)
else
    format "Mat: [%] does not have a property 'texmap_diffuse'\n" mat.name

Oh ok. Thanks for the tip..