Fri, Nov 29, 6:47 AM 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: Undocumented PoserPython methods and options?


Cage ( ) posted Sat, 08 February 2014 at 7:27 PM · edited Fri, 29 November 2024 at 4:00 AM

The PPy documentation seems to lag significantly behind the addition and alteration of methods.  New Python options have been announced in the SR readme files for Poser Pro 2014, but I can't find documentation of them anywhere.  I can't find evidence of them by calling dir() on poser or poser.Scene().  They are... mysterious.  😕

[quote]

PoserPython
     •    Added methods to mark a scene as changed and to determine whether or not a scene was changed since the last save
     •    Added method for getting current document path
     •    Added notifications for camera changed and lights changed
     •    Added Python access to subdivided geometry

[/quote]

There are also undocumented options for documented methods.  One that really puzzles me is:

[quote]

CopyJointParmsFrom
Explanation
Copy the joint setup from a different figure to this figure.
Arguments
Pass the figure that you want to use as the source of the joint setup.
Syntax
CopyJointParmsFrom( figure),{ searchAllWeightMaps}

[/quote]

What does "searchAllWeightMaps" do?  How would one use it?  Dunno.  😕

Does anyone have information about these?  Does anyone know any other hidden options in Poser Python?  Cage is curious about these things.  :lol:

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Pret-a-3D ( ) posted Sat, 08 February 2014 at 8:06 PM

Hi.

poser.Scene().Changed() tells you if the scene has been changed
poser.Scene().SetChanged() sets the scene as changed

poser.Scene().DocumentPath() returns the path of the current scene

To access the subdivided geometry you can use this type of code:

# a = Actor
if (a.IsBodyPart() and a.ItsFigure()):
  if ((a.ItsFigure().SkinType() != poser.kSkinTypePOSER) and a.SubdivideWithFigure()):
    continue
  else:
    if (not (a.IsProp())):
      continue
g = a.SubdivGeometry()

For the new method about the camera and light changed see the addon baseclass source that is installed with Poser. 

Hope this helps.

Paolo

https://www.preta3d.com
FB: https://www.facebook.com/RealityPlugIn
Tw: @preta3d
G+: https://plus.google.com/106625816153304163119
The Reality Gallery: https://reality-plug-in.deviantart.com


Cage ( ) posted Sat, 08 February 2014 at 8:29 PM

Ooh!  Yes, that does help.  Thank you.  I've wanted poser.Scene().DocumentPath() for a long time.  It would have made so many things easier, over the years.  :lol:

So, how do others learn about these things?  How do you know this?  Does one have to be on the Poser beta team, or part of the Poser Team itself to have this inside knowledge?  😕

Thank you for the excellent, and prompt, answer!  :laugh:

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Pret-a-3D ( ) posted Sat, 08 February 2014 at 9:53 PM

I'm glad that that helped.

The Addon Framework of Poser 9 SR3 is something that was born out of the collaboration between the Poser team and myself.

When I contacted them about making Reality for Poser I told them that a new plugin framework was needed, and they graciously agreed. So I listed a series of APIs that were needed in order to write plugins efficiently.

For example, while the callback system existed before, it was unfiltered. What that means is that you can install a callback and then that callback is called every time a Poser event happens. That is quite wasteful in term of performance. Usually a callback needs to act only on a handfull of events.

I asked for a series of specific events like "tell me when an object is added" or "call me when a material is changed". It was also crucial to be able to install a plugin without having to change the startup script. Using the startup script can easily cause problems, as it happened in the past. 

With the new addon framework the plugin author simply installs a plugin inside the addons directory and it is loaded by Poser automatically.

During the development of Reality a few other calls became necessary but that was after Poser 9 SR3 was released so we had to wait for the next round. I asked for the other methods that I described in the previous message and the Poser team agree on implementing those APIs. A big thank goes to Stefan @ Smith Micro, who patiently implemented those functions.

BTW, I forgot to mention another API. This one allows you to observe when an object internal name is changed:

def objectsInternalRenamed(self, objects):
        if (self.isObserver):
            print "objects internal renamed"   

For that to work you need to do this in the constructor of the plugin:

self.addonInfo['apiversion'] = '1.1'

Cheers.

Paolo

https://www.preta3d.com
FB: https://www.facebook.com/RealityPlugIn
Tw: @preta3d
G+: https://plus.google.com/106625816153304163119
The Reality Gallery: https://reality-plug-in.deviantart.com


Cage ( ) posted Sun, 09 February 2014 at 11:52 AM · edited Sun, 09 February 2014 at 12:02 PM

Oh, wow.  So you are exactly the person to ask about these particular functions.  I'm glad you're sharing this information.  :thumbupboth:  This is some good stuff.  I was also unaware of Reality for Poser.  😊  I guess I was sort of... away from Poserdom for a bit, there.  Missed some things.

I hope they manage to add information like this to the formal Poser Python documentation before too long.  When information like this is only available on the forums, it tends to get lost.  :sad:

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.


Pret-a-3D ( ) posted Sun, 09 February 2014 at 11:56 AM

It's the least that I can do to share the details with the community. I'm sure that Smith Micro will update the documentation soon.

Cheers.

Paolo

https://www.preta3d.com
FB: https://www.facebook.com/RealityPlugIn
Tw: @preta3d
G+: https://plus.google.com/106625816153304163119
The Reality Gallery: https://reality-plug-in.deviantart.com


deastham ( ) posted Wed, 12 February 2014 at 6:36 AM

Hi Pret-a-3D,

Sorry to hijack (sort of), but I have a related question. I am writing an exporter, and when the geometry is subdivided, it is exported with seams between the sections. Manual testing has shown that even when Smooth Polygons is turned on, the mesh is set to single skin and the subdivision is set to 1 or higher, SubdivGeometry comes back as None for one of Rex's body parts, but his hair (which shouldn't be subdividing) returns something for SubdivGeometry. What am I doing wrong? I have been using Actor.Geometry() before now, but would like to be able to export Rex's geo with the subdivision info intact (exporting to 3Delight for a personal project, no release or competition planned :P).

Thank you in advance for any help,

Jadan


Pret-a-3D ( ) posted Wed, 12 February 2014 at 10:16 AM

Smooth Polygon is not affecting the subdivision in Poser. You need to select the Poser Unimesh in the Skinning menu.

After that follow my example above. BTW, that code is actually not mine, Stefan provided it.

Cheers.

Paolo

https://www.preta3d.com
FB: https://www.facebook.com/RealityPlugIn
Tw: @preta3d
G+: https://plus.google.com/106625816153304163119
The Reality Gallery: https://reality-plug-in.deviantart.com


deastham ( ) posted Wed, 12 February 2014 at 11:00 AM

Thank you Paolo and Stefan. I will play around with this tonight and report back.


deastham ( ) posted Wed, 19 February 2014 at 8:44 AM · edited Wed, 19 February 2014 at 8:49 AM

I am not able to get SkinType() to work.. 

figureSkinType = actor.ItsFigure().SkinType()
returns the error AttributeError: 'NoneType' object has no attribute 'SkinType'

I see a method to set the skin type, but nothing to set it.

My code follows.. what am I doing wrong? I am trying to check the skin type so that I can check for (valid) subdivision geometry. SubdivGeometry returns true where tnere is none, so I am changing my methods.

Thank you for any help.

import poser

scene = poser.Scene()
actorlist = scene.Actors()
for actor in actorlist:
figure = actor.ItsFigure()

if actor.IsBodyPart():
   print actor.Name() + " is a body part."
   try:
      figureName = figure.Name() # This is the only way I can get the name
   except:
      pass

   print actor.Name() + " belongs to " + figureName
   figureSkinType = actor.ItsFigure().SkinType()


Pret-a-3D ( ) posted Wed, 19 February 2014 at 8:48 AM
deastham ( ) posted Wed, 19 February 2014 at 9:45 AM

Ah, thank you. I had incorrectly assumed the latest DLM version had the SR3 applied. It's working now. Thank you! :D


Pret-a-3D ( ) posted Wed, 19 February 2014 at 9:51 AM

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.