Sun, Oct 6, 6:46 AM CDT

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: I can't get this script to apply to all materials (Please help!)


destro75 ( ) posted Thu, 01 June 2006 at 5:57 AM · edited Sun, 21 July 2024 at 6:56 AM

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


nruddock ( ) posted Thu, 01 June 2006 at 2:34 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.


destro75 ( ) posted Thu, 01 June 2006 at 6:32 PM

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


Privacy Notice

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.