Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)
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
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.
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
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.
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
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
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
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()
Hi.
You must have the SR3 installed for that to work.
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
You're very welcome.
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
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.
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.