Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
Thanks Jeff. What a bummer. Once I catch the full error msg, I'll report it to CL.
Creator of PoserPhysics
Creator
of OctaneRender
for Poser
Blog
Facebook
Any chance that CurrentActor() is returning None, as in nothing selected? You might need to debug it by assigning the function calls to intermediate variables and printing them out. Assuming, of course, that doing so doesn't make the problem vanish ;-) Also, if you're doing a print, it should be able to handle the form: print "ActorName = ", poser.Scene().CurrentActor().Name() without the str() evaluation and string catenation. print can print tuples and dictionaries as well as functions evaluating to None. The inherent assumption (regardless of whether it's a P6 bug or not) of the combined statement is that none of the Scene(), CurrentActor() or Name() evaluations is going to return something that can't be evaluated by the next bit to be parsed - i.e. can't evaluate Name() method if CurrentActor() instance returns None.
Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.
In any case, it'd be much safer to check if you really get an object before trying to call methods:
scene = poser.Scene()<br></br>if (scene != None):<br></br> actor = scene.CurrentActor()<br></br> if (actor != None):<br></br> print actor.Name()<br></br>
Python doesn't like it if you try to call functions of a None object.
Thanks stewer :-) A code sample is, as usual, the most concise way of illustrating the point I was trying to make: Check before assuming.
Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.
I often use Python exception handling for cases like this:
try:
print poser.Scene().CurrentActor().Name()
except:
print "No actor selected!"
The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter
My galleryย ย ย My freestuff
Thanks for all the comments guys.... Stewer/svdl, my code already establishes that the scene and current actor are != None. The code is failing with a valid actor. In fact the code fails on... print str("hello") So it appears to be the str() function which is somehow becoming corrupted in the P6 session. The issue I've got is that there are a lot of people out there using scripts which have the str(...Name()) coding, and which ALWAYS work on P5. I agree that there is a work-around to remove the str() function - but that doesn't help if I want to convert a numeric to a string. The strange thing is that it works 99% of the time on P6 - it's just the 1% of times that it doesn't work, and you need to restart P6. So obviously there is something in there that is not right.
Creator of PoserPhysics
Creator
of OctaneRender
for Poser
Blog
Facebook
Oops. It usually works fine and sometimes crashes. No discernible pattern, right? Then it sounds like a memory management error in the C/C++ code. Very ugly bug, very hard to track down.
The pen is mightier than the sword. But if you literally want to have some impact, use a typewriter
My galleryย ย ย My freestuff
Thanks for the suggetions PoseWorks. I'd rather the bug was fixed than code around it! But if not, I'll look at your suggestions. Haven't tried str before - will check it out.
Creator of PoserPhysics
Creator
of OctaneRender
for Poser
Blog
Facebook
OK - i just got the problem again - and doing a File->Reinitialize Python fixed it. PoseWorks - I tried str but it couldn't find the method. I assume I need to input a particular library?
Creator of PoserPhysics
Creator
of OctaneRender
for Poser
Blog
Facebook
OK, I can now reproduce the error 100% of the time. Do the following: Start Poser With JamesCasual, run the SSS Wacro in the material room Then run a python script that simply contains the line print str(1) You should get the erro Traceback (most recent call last): File "", line 1, in ? TypeError: 'str' object is not callable Doing a File->Reinitialise Python will fix it (so the print str(1) actually prints 1. Is anyone else able to reproduce the error using the above sequence?
Creator of PoserPhysics
Creator
of OctaneRender
for Poser
Blog
Facebook
Yep nruddock - that fixed it - fantastic. Thanks so much.
Creator of PoserPhysics
Creator
of OctaneRender
for Poser
Blog
Facebook
Good point. Although better to fix the source of the problem, than code work-arounds. I've reported the problem to CL.
Creator of PoserPhysics
Creator
of OctaneRender
for Poser
Blog
Facebook
Attached Link: http://www.users.on.net/~pkinnane/P6%20Shader%20Compatibility.html
The fix is detailed at the above link.And again, nruddock, thanks a heap for the help on this. I've been getting the problem (and reports of it) for over a week and just couldn't work it out!
Message edited on: 04/01/2005 22:50
Creator of PoserPhysics
Creator
of OctaneRender
for Poser
Blog
Facebook
I'd been following the thread, but until you whittled it down to using that Wacro, it could have been (almost) anything.
"setLightStyle.py" has the same problem.
The simplest way of curing it would be to move the lines that do the actual work into a subroutine and call that like most of the other Wacros do.
One thought, getting people to edit their copy of the Wacro might cause problems when CL release an updater if it checks file timestamps or sizes.
Mmmmm, good point. I'll check it out.....
Creator of PoserPhysics
Creator
of OctaneRender
for Poser
Blog
Facebook
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.
Hi All A couple of times now I've had a python script which works in P5 fall over on the following statement in P6 print "ActorName = " + str(poser.Scene().CurrentActor().Name()) If I restart P6, the script then runs ok! I've had someone else report the issue to me too. If I remove the "str()" part, it also works. Has anyone else noticed this?
Creator of PoserPhysics
Creator of OctaneRender for Poser
Blog
Facebook