Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
ok, www.python.org for the manuals on python itself. There is a pdf file in Poser that gives you the poser specific commands.
You are aware that saving your file as a pz3 (scene) file will save everything ? what you describe is fairly common for a series of pics all using the same basic set.
the self.master.destroy bit is from tkinter and is not required if you are doing a single pass program
you need to select the figure to save the pose for and select the camera being saved.
the library to save in must be specified but yo can code it as a relative path
and you can create the folder manually to suit each project.
poselib = ":runtime:libraries:pose:myposeset:"
camlib = ":runtime:librariesmyposeset:"
posenam = fig.Name + nnnn
savenam = poselib +posenam
scene.SaveLibraryPose( savenam )
scene.SaveLibraryCamera( )
a simple dialog like this
dialog = poser.DialogSimple.YesNo(message)
if dialog == 1:
print " Continuing with script."
will let you put out a message and get a yes/no reply
I will try to write something tomorrow for you .
It took me a while to work out why you would want to do this, but I think I get it now. I quite often use the animation slider in a non-linear way, to render a series of variations on a single scene; sometimes with nothing more than different camera angles, sometimes with small or not-so-small variations in the figures' poses. It's an efficient way to wring the maximum use out of a single scene set-up.
However I've sometimes been in the situation where I want to alter the scene considerably, which means going through the timeline and saving poses, cameras and lights for the parts I want to re-use. This proposed script would be very useful for that.
Mind if I fiddle along with this?
The more the merrier...!
Let me try to shine a ray of light or two into my thinking, and perhaps that will spur some insights from a coding perspective:
Like a situation comedy, the comics re-use the same set, with the same actors and props, over and over.
To press on with the 'set' paradigm, I build a 'virtual set' with all the needed 'locales' in the .pz3 file ... for example, if it were 'Seinfeld', the pz3 file contains Jerry's apartment, the Soup Nazi's kitchen, Kramer's apartment, etc. but all sharing common walls between them.
If the comic needs a new locale, I just build it into the set and move forward with that pz3 file, keeping the existing locales fixed for compatibility with saved poses and cameras.
Some expanded thinking on the 'self-indexing' feature...
Thus the proposed script should greatly simplify the task of FINDING the poses and camera setups used in previous episodes, for utilization in new episodes. Because restoring the pose or camera info is easy... but FINDING the right info to restore is the hard part!
So I haven't noodled with example script provided just yet, but will start cracking on it this weekend.
Regards & Thanks!
Danborn
The script will prompt with the current figure name for a yes/no response and it will list the generated names for the pose and camera. That name is the figure or camera name with a 4 digit frame number appended.
The path to the correct folder is added to the filename for the save.
Amending the script to prompt for a project name would not be hard , and automatically creating the folders isn't difficult either. There is no way I know of to get the pz3 file name from in Poser.
Doing all the figures is a simple loop, props are a little harder but doable.
The current script does all frames , not all keyframes, so If you build scenes at 10,20,30 etc it will need to be changed.
A couple of things remain. There seems to be an inconsistency between SaveLibraryPose, which by default saves single frame poses and automatically supplies the .pz2 extension, and SaveLibraryCamera which saves animated camera settings and requires the script to supply the extension.
I've fixed the extension bug and a few others - the changes I made are marked by comments in the attached script. I can't find how to tell SaveLibraryCamera to save single frame settings - the Python methods manual says there's a parameter which I've set to zero, but I still get animated cm2s.
did you try scene.SaveLibraryCamera(“RuntimeLibraries MyCamera.cm2”, 0,2,2) for a single frame of camera at frame 2?
I dont have poser running at the moment so I cant test.
My copy of python methods gives path, multiframe, start frame , end frame as parameters for savelibrarycamera. multiframe = 0 for single frame.
I tried
scn.SaveLibraryCamera( camnam, 0, n, n )
but it still saved an animated camera - in Poser 7 at least. None of the parameters I'm applying to SaveLibraryPose or SaveLibraryCamera seem to be working, both are just doing their defaults. (I tried adding a parameter to SaveLibraryPose to include morphs, but that didn't have any effect either.)
Bear in mind that I'm a total Python newb, so I may have missed something obvious. ;)
I have a save camera script nearly done , The paramater names are not quite what I expected but thats not hard to fix. Should be done today.
I was thinking that the morphs should be saved with the pose, so that the character gets set correctly. If thats not whats needed it may be easier to use one of the pose saver scripts that already exist instead of the python savelibrarypose.
Quote - I was thinking that the morphs should be saved with the pose, so that the character gets set correctly. If thats not whats needed it may be easier to use one of the pose saver scripts that already exist instead of the python savelibrarypose.
Sometimes you would want to apply the poses to the same character - this would be likely with a comic book type scenario. Other times you might want to change the character, in which case the ideal would be to keep the expression morphs but ditch the rest. I don't know of any way to do that without maintaining a list of which morphs are which for each defined character. It's a lot easier to opt not to save any morphs in that case, I think.
Why not just save the scene, then for the next figure:-
Load the scene.
Find the next figure in the library.
Load to the scene using the "Replace" option rather than the more used "Add to".
The new figure will replace the existing figure, and here is the kicker it will take on its animated pose.
Cameras will remain unchanged.
Click:save
Click:select next figure
Click:change fig button
Hope that helps.
I had an initial glitch because I tried to create my libraries in an external runtime and hadn't spotted that it uses the main runtime by default. Both scripts seem to have done their jobs, anyway, so thanks once again.
If I foresee using this often, which is a possibility, I may merge the pose and camera scripts into one. On the other hand, there may be situations where I might want to save one aspect and not the other. I was going to procrastinate, but I couldn't decide when to start. :)
For now, I had only one figure that I wanted to keep anyway - and I can imagine that in a multi-figure scene, I'd probably not want to save all their poses. Running the script on each individual is no big effort, after all. I suppose one could get really fancy and select the required figures from a list, but I'm not that keen. :)
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.
G'day All,
Noob to Poser & Python here, but am fairly-well versed in CAD and scripting automation. Basically, I'm using the animation keyframes in Poser as a comic-strip storyboard. The net result are gross changes in camera, poses and props between keyframes, and no interpolating animation is (or will ever be) required.
So what I'd like to accomplish is 'capturing' camera position and figure poses frame-by-frame to the Library for each comic strip, for reuse in future episodes going forward.
Currently I'm doing this manually, and it's been a real pain in my date!
User Setup:
To keep it simple, I envision capturing just poses for the 'selected' figure, and operating on the 'selected' library collections for poses and cameras. And to further simplfy, I envision using the frame number as the library pose and camera position save-name -- thus the library collections created will be self-indexing to the comic strip episode frames from whence they came.
So to begin, the user first selects the desired figure, and the desired library collections for poses and cameras.
Python Script Pseudocode:
Am pretty handy with a text editor (UltraEdit), VBA, VBS, Perl and Regular Expressions, but Python is new territory. Now the user...
Runs the script, and a confirmation dialog box is shown naming the user's selected figure, and and Library pose and camera collections that will be updated, with options for 'OK' and 'Cancel'.
If user clicks OK, then loop thru the frames (partially based on a scrap of code I found thanks to Mr. Okham), red is my psedocode:
for n in range(scene.NumFrames()):
scene.SetFrame(n)
# Pad-out n with leading zeros, as required...
nnnnnn = Pad(n)
# Auto-overwrite any existing library elements of the same name...
scene.SaveLibrary("Pose", nnnnn)
scene.SaveLibrary("Camera", nnnnn)
self.master.destroy()
In the time it took me to write this, I could've indexed perhaps one of my comic strips. And there's dozen more to do with many more on the way. Going forward, as I come down the learning curve on Python, I envision adding multiple characters and props to the loop, and I do promise to share the results as a token of my appreciation for the leg-up here.
So if any of you 'Pythoncologists' out there have an extra few minutes to flesh-out this straw horse, I'd be much obliged...
Cheers!
Danborn