Forum: Poser Python Scripting


Subject: Parsing Class for Poser files - Comments/Suggestions

tromnek opened this issue on Jan 06, 2005 ยท 11 posts


tromnek posted Thu, 06 January 2005 at 10:04 PM

Here is a class I wrote to easily parse poser files. You can get the items in the file along with their hierarchial depth. Run the script and press the button to select a .pz2 pose file. The demo will print out some items. Also read the comments in the source code. I'm soliciting comments and suggestions. I use this with some other classes to create partial body poses 'on-the-fly' from .pz2 files. I'll post that on another thread. tia

duckmango posted Fri, 07 January 2005 at 1:42 AM

Ok, I've tried both demos, and I think they're just terrific. Very impressive -- well done, and thanks for posting the code.

Here's a couple of quickie comments:

  1. PP generates a syntax error with += statements. Demos work fine in P5, as well as in standalone python.

  2. One pose file to generate many partial poses...yes, I can see the utility in that. Are you also thinking of extending this to character files, e.g., parse a character file into Mat poses? JCM poses?

(sigh...could've used something like this a month ago...)


tromnek posted Fri, 07 January 2005 at 6:46 AM

Thanks, I'll modify the += statements. I could really use a copy of the python.dll and the library from poser pro so I can test stuff better. It should be able to handle MAT and JCM by creating a linked list with regex that pick what you want

Message edited on: 01/07/2005 06:49


duckmango posted Fri, 07 January 2005 at 3:26 PM

So let's see if I'm following the code correctly: If I want to, for instance, just count the number of times 'targetGeom' occurs in a pose file, I would create a linked list (actor->channel->parameter) plus associate a counting routine for the 'dosomethingimportant' method in the parameter node, right?


tromnek posted Fri, 07 January 2005 at 7:12 PM

Yes. Actually, you could just have one element in the list (parameter) that identifies 'targetGeom'. This would find 'targetGeom' anywhere, regardless of it's position in the hierarchy. You need the whole list (actor->channel->parameter) only if you specifically are looking for 'targetGeom's that below an 'actor->channel'. Attached is a new version that fixes a small bug I just found. I made a last minute change before my last posts and didn't notice it in my testing.

tromnek posted Fri, 07 January 2005 at 9:51 PM

Here is an example for materials. It's using a function to pick only the Torso and Head materials

      def pickonlysome(rtn):
        if rtn['materials'][0] in ( 'SkinTorso', 'SkinHead' ):
          return 1
        return 0
      reMAT   = re.compile( r'bmaterials+(.+)b', re.IGNORECASE )
      reValue = re.compile( r'(.+)', re.IGNORECASE )
      Materials= ParmList( 'value', reValue, dosomethingimportant )
      Materials.newparent( 'materials', reMAT, pickonlysome )

      # Pass the linked list to the class and let it rip.
      junk = ParmExecuter( inStr, Materials )

Searching a big cr2 file takes some time. The above example took 25 seconds for a 41MB file.


an0malaus posted Sun, 09 January 2005 at 2:17 AM

Wow, this is cool stuff! [Bookmark]



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


GWeb posted Sun, 09 January 2005 at 5:44 AM

I am not sure what this is about. Can someone please fill me in? Is this about CR2 on the fly with PZ2 as a backend? Tromnek, I still wonder how you were able to write code in PY. Now you just said you need Python.DLL from Poser PP. Would you please tell us how you were able to get external DLL to work with standalone Python. Thanks


tromnek posted Sun, 09 January 2005 at 12:07 PM

These classes assist in parsing poser files (probably any type) so that you can find specific parameters and values, then execute a user defined function each time they are found in a file.
Since it is very generic, they can be used in a variety of situations. Currently, I'm using them to filter a pose file (.pz2) so that my user defined function can set rotation and translation parameters on only selected body parts in a figure.

I'll start another thread to try and address your other more generic poser-python question.

Message edited on: 01/09/2005 12:08


GWeb posted Mon, 10 January 2005 at 2:03 AM

So if I change the value in PZ2 and it will DrawAll() in the scene on the fly?


tromnek posted Mon, 10 January 2005 at 7:04 AM

These classes are very basic and only locate parameters in a poser file and give your script an opportunity to do what ever you wish with that parameter. I'll clean up the script that I'm currently using to filter .pz2 files and post it later this week. Maybe a real example will help illustrate their use.