Quick help with V-Ray example python script

Hi,

I really don’t know anything about python, so was just wondering on how to modify your example script:

from vray.utils import *

l=findByType(“Node”) # Get all Node plugins
p=l[0].get(“material”) # Get the material of the first node
brdf=p.get(“brdf”) # Get the BRDF for the material
brdf.set(“color_tex”, Color(.5, .5, .5)) # Set the BRDF color to red

How do I get the line below to change ALL materials in the scene, not just the first node?

p=l[0].get(“material”) # Get the material of the first node

And second part, how does one issue a command to get this to appear in the “Post Translate Python Script” area in the GUI. :slight_smile:

So basic I know! :slight_smile:

Do you want to override all materials with a grey color?

Best regards,
Vlado

Hi,

Yes Vlado.

I know it’s possible with Maya’s Render Layers but I consider it too much of a risk to use in projects because it breaks.

Doing this post translate would be the safest bet.

Try this one:```
from vray.utils import *

create a grey BRDF

greyBrdf=create(“BRDFDiffuse”, “greyBrdf”)
greyBrdf.set(“color”, Color(0.5, 0.5, 0.5))

set the material of all scene nodes

sceneNodes=findByType(“Node”) # Get all Node plugins
for node in sceneNodes: # for each node
node.set(“material”, greyBrdf)


Best regards,
Vlado

Many thanks Vlado!