Thu, Nov 28, 4:03 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 Sep 18 2:50 am)

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: Parsing Class for Poser files - Comments/Suggestions


tromnek ( ) posted Thu, 06 January 2005 at 10:04 PM · edited Thu, 28 November 2024 at 3:21 PM

file_166052.txt

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 · edited Fri, 07 January 2005 at 6:49 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

file_166053.txt

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 · edited Sun, 09 January 2005 at 12:08 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.


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.