Forum: Poser Python Scripting


Subject: Need help with simple material script

232bird opened this issue on Sep 27, 2011 · 19 posts


232bird posted Wed, 28 September 2011 at 12:43 PM

Lol yep, I did too.  Now everything works.

I tried to add to the script to make it recurse through all figures and materials.  Came up with this.

import poser
#declare variables
scene = poser.Scene()
allfigs = scene.Figures()
#set FOR loop to recurse through figures
for figure in allfigs:
#declare materials
mats = figure.Materials()
#FOR loop to recurse through materials
for material in mats:
#declare shader tree down to diffuse node
 shaderTree = material.ShaderTree()
poserSurface = shaderTree.Node(0)
diffuseNode = poserSurface.InputByInternalName("Diffuse_Color")
#apply color
try:
mat.diffuseNode.SetColor(1.0,0.2,0.2)
except:
pass
#refresh scene
shaderTree.UpdatePreview()
scene.DrawAll()
print "Done"

 at line 11, "for material in mats", I get the error 

for material in mats:
^
SyntaxError: invalid syntax 

What I am trying to do with that line is go through all materials for a figure and apply the color to each.