Fri, Nov 29, 8:46 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: Poser 6 Dialogs


PoseWorks ( ) posted Tue, 22 March 2005 at 1:16 PM ยท edited Tue, 26 November 2024 at 8:21 AM

Reviewing the new cross-OS dialogs added in P6...

SIMPLE DIALOGS

USAGE
Call them from poser.DialogSimple: ie, poser.DialogSimple.AskActor(). AskMenu does not work as documented--the options must be a list of strings, not a series of string arguments.

poser.DialogSimple.AskActor("Pick an actor!")
poser.DialogSimple.AskInt("Type a number.")
poser.DialogSimple.AskFloat("Type a number.")
poser.DialogSimple.AskMenu("Favorites", "What is Jame's favorite food?", ["Cheese","Pudding","Chocolate"])
poser.DialogSimple.MessageBox("Hello Poser!")
poser.DialogSimple.PickImage()
poser.DialogSimple.YesNo("Was this a good upgrade?")

RETURNS
So far, I can't get AskActor to return anything other than None. AskInt/AskFloat will return an integer or a float, respectively or None if the text entered is not evaluate as an integer/floating point. AskMenu returns the selected string or None. Note that AskMenu defaults to None, even if that's not on the list. MessageBox always returns None. PickImage returns the file path of the chosen image. YesNo returns 1 or 0. Canceling any dialog returns None.

BUGS
AskActor loses focus when started, the user must click on the window in the taskbar to regain focus. (Win XP)

ADVANCED DIALOGS
A look inside of compressPoserFiles.py reveals:

self.dlg = poser.Dialog(file="./Runtime/ui/compressFilesDlg.xml", title="compressFiles.py", message = message + "nnnnnn", width=550, height=250)
self.dlg.AddButtonCallback(name="fileBrowser", callback=self.dirBrowserCB)
self.dlg.AddButtonCallback(name="compressGeom", callback=self.compressGeomCB)
self.dlg.AddButtonCallback(name="deleteAfter", callback=self.deleteAfterCB)
self.dlg.SetText(name="fileBrowser", text=initDir)
self.browse = poser.DialogDirChooser(parentDialog=self.dlg, message="Choose folder to begin search", startDir=self.Directory())

This code does nothing in windows. Any Mac users out there who can report/give screens? The ability to create plug-ins with Poser's GUI engine (meaning XML and PSD) seems tantalizing close.

Message edited on: 03/22/2005 13:21


stewer ( ) posted Tue, 22 March 2005 at 5:20 PM

"This code does nothing in windows." You need to call the dialog's Show() method. I'm not sure - is the Render IO/Render Passes script included? wrote it during the late beta phase, but I'm not sure if it made it in the gold master. That one should also give you an idea on how to use the built-in dialogs, and it runs on Windows.


stewer ( ) posted Tue, 22 March 2005 at 5:27 PM

AskActor() works like the actor selection in the Pose room, so you can get the user's selection with poser.Scene().CurrentActor(). -Stefan


nruddock ( ) posted Tue, 22 March 2005 at 6:06 PM

There is a RenderPasses.py, is that likely to be the one ?


PoseWorks ( ) posted Tue, 22 March 2005 at 6:34 PM

Beautiful! Thanks for the info, stewer.


stewer ( ) posted Wed, 23 March 2005 at 12:34 AM

There is a RenderPasses.py, is that likely to be the one ? That should be the one, yes. Didn't it make it to the default RenderIO buttons? Anyhow, this script renders a separate pass for each light, plus one ambient pass plus one occlusion pass, and it uses a XML/PSD UI for user interaction.


nruddock ( ) posted Wed, 23 March 2005 at 4:04 AM

Yes it's got it's own button. Helps with understanding the ui xml files as well.


an0malaus ( ) posted Wed, 23 March 2005 at 9:58 PM

@PoseWorks, as stewer says, you need the dialog's Show() method called. Here's an example (hopefully not too OT) which works in P5 on Mac (expect to be waiting weeks to get my boxed P6 in OZ) and pops up an OS X styled file chooser dialog, rather than an XML styled one: initDir = poser.AppLocation() fileIndex = string.rfind(initDir, separator) initDir = initDir[:fileIndex] + ":Runtime:libraries:Pose" figure = scene.CurrentFigure() initFile = figure.Name() + "_FBM" + pz2ext getSaveFile = poser.DialogFileChooser(type=poser.kDialogFileChooserSave, message="Save Full Body Morph Pose File as:", fileName=initFile, startDir=initDir) if (getSaveFile.Show()): pz2File = getSaveFile.Path() pz2File = pz2File[:string.rfind(pz2File,pz2ext)] + pz2ext # Append extension if missing scene.SaveLibraryPose(pz2File) # Create Icon ... The code above doesn't involve any button callbacks as there is no XML parent dialog displayed prior to the File Save. I discovered the poser.DialogFileChooser (as opposed to DialogDirChooser) by searching the P5 binary for strings and looking at the XML files. Parameters were determined by guesswork and trial & error.



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


PoseWorks ( ) posted Fri, 25 March 2005 at 1:21 PM

file_206241.jpg

The dialog works in P5 (OSX) as well? Very interesting. Note that it does not work in P5 for the PC. Some things I've learned about XML for Poser's GUI widgets: >>COMMANDS<< Cancel window (command="7002") Ok window (command="7001") Resize window (behaviorProcID="5") Drag window (behaviorProcID="4") Ignore click (passclick="1") >>COLORS<< White -1 Black 0 >>FONTS<< Helvetica -1 Times 0 Helvetica Bold 1 Times Bold 2 Still trying to figure out what kind of color system Poser uses. It seems to like large numbers, but they're not in any form I'm accustomed to (RRRGGGBBB, for instance) and don't seem very consistent to me. Any ideas?


nruddock ( ) posted Fri, 25 March 2005 at 1:50 PM ยท edited Fri, 25 March 2005 at 1:52 PM

The colour number are probably the decimal equivalent of the hex value.
-1 = 0xFFFFFFFF (signed long)

Try the following :-

-16777216 = 0xFF000000
16711680 = 0x00FF00000
65280 = 0x0000FF00
255 = 0x000000FF

and see which ones correspond to the primary colours.

Message edited on: 03/25/2005 13:52


PoseWorks ( ) posted Fri, 25 March 2005 at 5:24 PM

Yep, 255 gives you blue, 65280 green, 16711680 red. Thanks!


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.