Wed, Dec 4, 1:29 PM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)

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: Renaming materials in Poser


flyerx ( ) posted Sat, 25 January 2003 at 6:16 PM · edited Wed, 04 December 2024 at 3:00 AM

Hello, Because of Poser's broken OBJ export functionality. I have been trying to make a script to rename the material names in a scene. As a trial I tried to first list all the material names in the scene but it keeps giving me syntax error. Here is the text of the scritp: import poser scene = poser.Scene() for actor in scene.Actors(): materials = actor.Materials() for material in materials: print material.Name() Here is the error: File "", line 6 print material.Name() ^ SyntaxError: invalid syntax I tried to store the material.Name() value into a string variable and print it but it showed the same error. Oddly if I add a carriage return at the end of the file a different error shows: Preview Traceback (innermost last): File "", line 5, in ? TypeError: loop over non-sequence This is not really encouraging. So much for easy to use phyton. If anynone knows what the source of the error is I would appreciate any hints. I am using Poser Pro Pack with SR3 FlyerX


flyerx ( ) posted Sat, 25 January 2003 at 6:17 PM

the above post had tabs in the loops.


ockham ( ) posted Sat, 25 January 2003 at 10:37 PM

I tried it, with some extra printing to see where the problem was happening, and I think the problem is some Actors (specifically the Lights, but probably others as well) have no materials. So when you try to loop over Materials(), you get errors when you run into such actors. Quick fix: import poser scene = poser.Scene() for actor in scene.Actors(): ~try: ~~for onemat in actor.Materials(): ~~~print onemat.Name() ~except: ~~pass (The tildes substitute for tabs.)

My python page
My ShareCG freebies


flyerx ( ) posted Sat, 25 January 2003 at 11:28 PM

thanks for the info. That works. Unfortunately It seems that I cannot rename materials without creating new ones. I am using poly.SetMaterialName(newmatname) but this method creates a new material instead of renaming the material. I tried material.Name(newmatname) and that did not have any effect. Maybe if I use SetMaterialName() and copy the material properties to the new material but that is rather cumbersome way of doing it. FlyerX


ockham ( ) posted Sun, 26 January 2003 at 9:11 AM

That sounds about right. The Python connection to Materials is skimpy at best; many of the actions that "ought" to be there are not there! So don't expect things to work the easy way in this department.

My python page
My ShareCG freebies


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.