Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
Shift-click to apply to all materials, only works from the Wacro buttons in the material room, not the drop down list that "User Defined" gives.
When you run it from the File menu, scene.WacroMaterials() contains the set of materials that your last action in the Material room worked on (i.e. it's a "sticky" list).
If you look at the scripts I wrote to apply things to all materials, you'll see the required construction.
Because the list scene.WacroMaterials() returns is sticky, there is no logic that will distinguish whether a script is being run from the Wacro buttons or the file menu, so if you need it to run on on one or all materials, you must assign it to a Wacro button.
Okay cool. I fixed it.
import poser
print "Starting Script"
scene = poser.Scene()
OutlineVal = 0.00001
figs = scene.Figures()
for fig in figs:
mats = fig.Materials()
for mat in mats:
tree = mat.ShaderTree()
iNodes = tree.NumNodes()
iCurrent = 0
while (iCurrent < iNodes):
WorkNode = tree.Node(iCurrent)
print "%s" % (WorkNode.Name(),)
if (WorkNode.Type() == poser.kNodeTypeCodeTOON):
WorkNode.Input(4).SetFloat(OutlineVal)
print " Node Set: %f" % (OutlineVal,)
iCurrent += 1
tree.UpdatePreview()
scene.SetCurrentRenderEngine(poser.kRenderEngineCodeFIREFLY)
renderoptions = scene.CurrentFireFlyOptions()
renderoptions.SetDrawToonOutline(1)
renderoptions.SetToonOutlineStyle(poser.kOutlineCodeTHINPEN)
print "Done"
Now it scrolls through all materials on all figures. I had a nagging feeling this morning that this might be the case. I should have listened to my instincts. Anyway, thanks for the help!
Lou
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
Hey all,
I have no idea why I can't get this script to apply to all materials in the scene. Am I missing something here? I tried running it through the User Defined button in the Wacros in the Mat Room (holding Shift while clicking, and not holding Shift.) I also tried running it through the Run Python Script option in the File menu. Any help is appreciated.
import poser
print "Starting Script"
scene = poser.Scene()
mats = scene.WacroMaterials()
OutlineVal = 0.00001
for mat in mats:
tree = mat.ShaderTree()
iNodes = tree.NumNodes()
iCurrent = 0
while (iCurrent < iNodes):
WorkNode = tree.Node(iCurrent)
print "%s" % (WorkNode.Name(),)
if (WorkNode.Type() == poser.kNodeTypeCodeTOON):
WorkNode.Input(4).SetFloat(OutlineVal)
print " Node Set: %f" % (OutlineVal,)
iCurrent += 1
tree.UpdatePreview()
scene.SetCurrentRenderEngine(poser.kRenderEngineCodeFIREFLY)
renderoptions = scene.CurrentFireFlyOptions()
renderoptions.SetDrawToonOutline(1)
renderoptions.SetToonOutlineStyle(poser.kOutlineCodeTHINPEN)
print "Done"
Thanks in advance!
Lou