Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 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
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
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
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.
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