Forum: Poser Python Scripting


Subject: Pre-populate save dialog with current filename/path

3doutlaw opened this issue on Dec 11, 2012 · 10 posts


3doutlaw posted Tue, 11 December 2012 at 10:28 AM

Is there a way to do this?  I got a copy of Philc's Save PZ3 with Thumb, which is cool....but it defaults to no filename and a default path (no where near my desired location) for any PZ3 I have opened.

I'd like to enhance it, and open that file save dialog with the current filename and path

Didn't see anything re: this, in the Poser Python reference manual.


markschum posted Tue, 11 December 2012 at 10:58 AM

Is it a free script ?   If not Phil would have to answer the question.

 

The save command in Poser python does not  run a dialog, it just uses whetever name is supplied. The original document name is not available unless you load it via script and save the name somewhere. (to Poser 7)


3doutlaw posted Tue, 11 December 2012 at 11:11 AM

Yes, it appears to be, from header:

Script to save a thumbnail along with a PZ3 file

by PhilC http://www.philc.net

Use for whatever you like but at your own risk.


markschum posted Tue, 11 December 2012 at 11:18 AM

ok, can you post where you got it ?  I have my own version but would like  a copy of Phils.


3doutlaw posted Tue, 11 December 2012 at 11:28 AM

Sure, Primorge posted it over in another thread in Poser forum... 

(thats why i checked out the contents before moving ahead...)

I'll PM Philc to be sure...but I was going under the impression from the header its fine, since its pretty clear.  I guess someone could have altered that though?


markschum posted Tue, 11 December 2012 at 11:42 AM

the line

find the full path to the Poser folder

pathname = os.path.split(poser.AppLocation())[0]

sets the poser application folder as the start of the path for the file choos3er dialog.

you can simply change that line to point to whatever folder you want like

 

pathname = "c:documents and settingsownermy documentsposer_scenes"

the double slashes are required by python since the is a control character.

 

 


PhilC posted Tue, 11 December 2012 at 11:49 AM

Yes it is a freebie, the original post with the script may be found here:-

http://www.philc.net/forum/viewtopic.php?t=2572


PhilC posted Tue, 11 December 2012 at 12:27 PM

If you want a default file name simply include in the startDir path

startDir = os.path.join(pathname, "default.pz3")


3doutlaw posted Tue, 11 December 2012 at 1:24 PM

I was actually trying to get the "current" filename, not a default.  So if I opened an already existing  (not new) pz3, it would use its existing name and path as the starting point in the file chooser.

...on another unrelated note, I notice that if you hit "Cancel", it crashes Poser9 (or at least my Poser9).

I added the below before the Return in getpath (basically just checks to see if you left the default filename with asterisk in it):

if PZ3path.find("*") != -1:
    doIt = 0


markschum posted Tue, 11 December 2012 at 4:42 PM

You can add some information using the CreateValueParameter  in the scene to let you store things for Poser later. Poser itself does not keep the scene filename anywhere. Its a common request.

If you write a loader script to  get the filename of the pz3, load that scene , and save the scene filename in a ValueParameter its a bit easier. However if you save the scene using Posers menu your parameter will be wrong. 

I dont know if they added something in Poser later than 7 but it would be in the Poser Methods manual if it exists.