Forum: Poser Python Scripting


Subject: Poser Python Tutorials to get up to speed?

kuroyume0161 opened this issue on Jul 12, 2002 ยท 13 posts


kuroyume0161 posted Fri, 12 July 2002 at 12:18 AM

Hi, I've discovered Poser Python! Well, being a programmer in real life, this isn't anything totally new to me (C/C++/Java/Perl). Still, a new language is a new language and there are 90 pages of nothing but methods in the ProPack User Guide. It'll be easy enough to learn Python scripting. It's the application of it within Poser to get the desired results that'll be confusing. So, I'm wondering where might one find some good tutorials online. Already have Schrand's "Poser 4 Pro pack f/x & Design" to get started. Anything beyond this? I see the Python site mentioned above. Anything specifically for Poser there? Thanx and pardon my newbieness, Kuroyume

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


bushi posted Fri, 12 July 2002 at 12:39 AM

I haven't seen any beginning PoserPython tutorials online yet. I'm currently working on some tutorials specific to PoserPython but don't have any available to the public at this time. Since you're a seasoned programmer, the links you mentioned above would be a really good place to start for Python. Another area that you'll want to dig into (and deeply) is tkInter. That's the GUI for Python that's also in PoserPython. Till I get the tutes up, I'd suggest looking at the example scripts that are in the runtime/Python path and dropping by here for answers to problems. BTW your 'newbieness' is just fine. ;-)


kuroyume0161 posted Fri, 12 July 2002 at 11:53 AM

Thank you bushi! I'll have to go to the Python site and check out the manuals and tutorials there and go through the examples in Poser4. Arghh! More GUI stuff to learn. Java Swing is bad enough. :) Now the trick will be to not mix up the two when programming... Kuroyume

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


kuroyume0161 posted Fri, 12 July 2002 at 12:23 PM

Forgot to ask: Can you recommend a good book on Python. I always like to have something like this to get the hang of a new language quickly. Thanks again, Kuroyume

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


bushi posted Fri, 12 July 2002 at 1:30 PM

Yes, as a matter of fact I was going to post a follow-up note about that subject but got distracted. Here are four that I highly recommend: Python - Visual Quickstart Guide Chris Fehily Peachpit Press Learning Python Mark Lutz & David Ascher O'Reilly Python and Tkinter Programming John E. Grayson Manning Python Pocket Reference Mark Lutz O'Reilly Of the four, the Quickstart Guide and Grayson's tkInter book are the best.


stewer posted Fri, 12 July 2002 at 3:44 PM

Where if you already know other programming languages, you won't need any books on it. Just open the API reference in your browser and dig through a few example Poser scripts - you'll figure it out. My view is that you don't learn Python, you just start using it - it is by far the easiest language I've ever met, yet there's hardly anything missing from it.


kuroyume0161 posted Fri, 12 July 2002 at 6:12 PM

While agree that it looks easy to learn, there are a few idiosyncracies that I want to get used to (such as Dictionaries and Python's particular flavor of exception handling, for example). And, yes, there's hardly anything missing from it! Python looks a lot like Java in its implementation (classes, objects, methods, API imports, GUI support, threads, and so on). When I start getting strange errors from the interpreter, though, it will be good to know why they are occurring and how to correct them without an overabundance of wasted time. Java is also pretty easy, but to get to the real heart of the APIs, especially for application programming, you need the API references (as will be a good thing for Python). But you also need to know how to correctly use them. Thus, in the case of Java, I have about 12 books (3 reference, 3 general, 1 AWT, 1 Swing, 2 2D Graphics, 1 Java3D, and 1 Java Advanced Imaging) to achieve this. Without these, the support application that I'm currently writing for Poser 4 would be on the scrap heap. Nevertheless, it'll be fun to learn and I'm not expecting too much difficulty in that. Already enjoyed the "bulgeActor" script. I'm just one of those people who has to know everything in order to do whatever I want. Damned selfish of me, huh? :) BTW, Bushi, thanks for the book list. I have them saved for later reference. Kuroyume

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


stewer posted Sat, 13 July 2002 at 2:20 AM

On getting strange errors: Make sure your source file ends with a newline character and that you always use tabs, not spaces.


kuroyume0161 posted Sat, 13 July 2002 at 10:05 AM

I read that the interpreter has a thing for tabs. Luckily, I prefer tabs over spaces for indentation as well. :) One of those strange errors was from the "Poser 4 Pro Pack f/x & Design" book in the bulgeActor script that was presented. It was entered exactly as it appeared in the book and was checked against the text on the CD, but it kept returning with an error about a null object (geom) in this case. Found the Poser script that does the same thing, but without a separate method, and saw that the validity check on geom had been removed in the book script, so included this from that script: if(not geom): continue verts = geom.Vertices() ... but it returned with 'continue not properly in loop' (?). Well, this was driving me batty since, on the face of it, I could see nothing wrong with it, so I just reversed the logic to remove the 'continue': if(geom): verts = geom.Vertices() .... That worked. Keeps that extra stack reference to get out of the if(), but it does the job. This is one of those idiosyncracies, especially with interpreted languages. They tend to be less tolerant in stepwise execution. Once the 'design philosophy' for Python is understood, it shouldn't be much of an issue. Kuroyume

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


bushi posted Sat, 13 July 2002 at 9:43 PM

One of the nice features in Python is the exception handling. The 'try: ... except:' statement is really useful for trapping errors and scads of other odds and ends. I use it a lot in tkInter to test for presently existing widgets when I'm destroying frames and the like.


kuroyume0161 posted Sun, 14 July 2002 at 6:41 PM

Java has the same feature with 'try catch()' which is very useful. As soon as I saw that in Python, I knew what it was for. Makes debugging and error handling easy as pi/0 ;) Strict OOP is definitely the wave of the future (well, until something better comes along, anyhow). Kuroyume

C makes it easy to shoot yourself in the foot. C++ makes it harder, but when you do, you blow your whole leg off.

 -- Bjarne Stroustrup

Contact Me | Kuroyume's DevelopmentZone


jbrugion posted Wed, 17 July 2002 at 5:59 PM

Sorry about the glitch in Poser 4 Pro Pack f/x & Design. When looping over the geometry's you almost always need to try/except the actor.Geometry() call because there is no other way of finding out if the actor, such as the Body, has a real geometry or not. FYI, there are a couple of other coffin corners in the Poser-Python implementation. try looping over: actor.Geometry().Vertex(vertIndex).X() where actor is a high poly part, like the head, and the vertIndex runs the range over the number of verts in the geometry. MAKE SURE YOU CAN CRASH YOUR SYSTEM WHEN YOU TRY THIS! Now, after rebooting, try : vertices=geometry.Vertices() then loop over vertices[vertIndex] to get to each vertex instead of doing the Geometry().Vertex(vertIndex).X() As near as I can tell, Python creates a copy of the geometry every time you call Geometry().Vertex(). Soooo... if you loop over the vertices in Vicky's head you get something like 10,000 x 10,000 polygons being created in your system RAM. There are some other memory leaks in the interface. Watch your system monitor when you do things to see if your start bleeding too much memory. Curious Labs is aware of this bug but I got it to them after SR3 was allready in the can. Presume that Poser 5 will have a fix.


jcarp posted Sat, 03 August 2002 at 1:12 PM

Attached Link: http://www.python-eggs.org/links.html

Here's a useful collection of links. There's a Learning Python section. You might want to keep in mind that Propack's version of the interpreter is 1.5.2. Some of the world has moved on to v 2.2, so some of the more recent stuff, like: the Deitels' Python How to Program Martelli and Ascher's The Python Cookbook Lundh's The Python Standard Library and a lot of what people talk about in mailing lists will talk some about new features. BTW, " 'continue' not properly in loop " means you're trying to use 'continue' outside a loop. 'continue' doesn't have any meaning outside a loop--since it means "go to the top of the loop NOW."