Thu, Nov 28, 2:10 PM 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: Converting scripts for PP2012?


lesbentley ( ) posted Mon, 19 March 2012 at 8:50 AM · edited Thu, 28 November 2024 at 2:10 PM

I don't use a lot of Python scripts, but the ones I do use I rely on quite heavily. Chief amongst those is svdl's "SpawnCharacterP6 update".

I just upgraded to PP2012 (from P6), and as you will know, many (all?) py scripts made for earlier poser versions do not work in PP2012.

I know nothing about Python scripting personally, though I have managed to make some very simple hacks to one of svdl's scripts for saving poses (P6 version).

So the question is this: Is there anything I can do (as a Python illiterate) to convert "SpawnCharacterP6 update" so that it will work in PP2012? I would need clear instructions that assume no prior knowledge of Python.

A supplementary question: Is there a general method that would convert any py script to work in PP2012?


PhilC ( ) posted Mon, 19 March 2012 at 8:57 AM

All compiled PYC files will need to be recompiled in Poser 9/Poser Pro 2010 but uncompiled PY files may still work. Is your script a PY or PYC? If PYC then its author will need to recompile it for you.


lesbentley ( ) posted Mon, 19 March 2012 at 9:46 AM · edited Mon, 19 March 2012 at 9:50 AM

It's py, not pyc. Running the script in PP2012 I get a pop-up window with the message "This script requires Poser 6 SR2 or later", then nothing further happens. When running the script in P6 it presents a GUI.


bagginsbill ( ) posted Mon, 19 March 2012 at 10:33 AM

I followed your link to svdl's freestuff, downloaded the script, and ran it, no problem, in PP2012.

Did you do the same or are you trying to run some old copy you already had?


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


markschum ( ) posted Mon, 19 March 2012 at 10:35 AM

The error seems to be a generic error when the dialog code fails.

The script seems to assume the runtime is in the Poser program folder e.g

program files/e frontier/poser 7/runtime/libraries/pose   which may be wrong for PP2012.

It is writing an xml file which is then used for the dialog.   that is being put in  runtime/ui/spawncharactertext.xml

You could check if that file has been written.

 


bagginsbill ( ) posted Mon, 19 March 2012 at 10:38 AM

The message you got is from an exception being detected and the script is trying to help you understand the problem. By hiding the actual error, it is preventing us from understanding the problem. I hate it when people try to put a nice error message on every possible problem. It means we have no idea what is actually happening.

Certainly the problem is not that you are running something older than Poser 6 SR2, so that is a f***ing stupid thing to say.

Do you want to try to remove the "smart" error message so we can see what is really going wrong?

At the bottom it says:

 

try:
        dg=SpawnCharacterDialog(poser.Scene().CurrentFigure())
        dg.Show()
except FigureError:
        pass
except:
        print "This script requires Poser 6 SR2 or later"

Change it to this: dg=SpawnCharacterDialog(poser.Scene().CurrentFigure()) dg.Show()

(No indentation on that)

We just want the raw code to go ahead and succeed or fail without intervention. So I stripped all the silly "helpful" stuff and just leave the two lines that need to run. If they fail, you'll get a real Python error message - tell me what it says.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


bagginsbill ( ) posted Mon, 19 March 2012 at 10:41 AM

Mark may be on to something. I didn't actually run the script with a figure, so I reported too early that it ran fine. What I meant was it didn't give me the same error - it said specifically that I needed a millenium figure which I assumed meant it was running OK.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


bagginsbill ( ) posted Mon, 19 March 2012 at 10:43 AM · edited Mon, 19 March 2012 at 10:45 AM

It does not assume a specific full path - it asks Poser for the app location and then assumes the main runtime is under there. Which it is not.

Instead of os.path.dirname(poser.AppLocation()), poser.Libraries()[0] would be the new way to find the main runtime.


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


PhilC ( ) posted Mon, 19 March 2012 at 11:06 AM

It is writing but not reading the XML file.

When I updated my scripts to Poser 9/Poser Pro 2012 I also had trouble with these native Poser dialogs. Where ever possible I rewrote them to use wxPython.

All paths appear correct. It is possible that there is an incompatibility somewhere within the 35 lines of XML code. Good luck with finding that :)

Since it is a relatively straight forward GUI it may be quicker to rewrite it in wxPython than to find where the anomaly is.


lesbentley ( ) posted Mon, 19 March 2012 at 11:26 AM

@bagginsbill,

Quote - I followed your link to svdl's freestuff, downloaded the script, and ran it, no problem, in PP2012.

Did you do the same or are you trying to run some old copy you already had?

Yes, I downloaded a fresh copy, and installed in the ScriptsMenu folder under the primary (executive) Runtime.

No matter if I try to run it via File > Run Python Script, or via the Python Scripts menu, all I get is the message "This script requires Poser 6 SR2 or later". Then nothing else happens.

I had heard a lot of talk in the forums about old scripts not working in PP2012, so I assumed that was the issue. If it works for you in PP2012, then it looks like I have a different issue. I should probably add that I have not installed any updates to PP2012 yet, and that I am running 32 bit under Win XP SR3.

@markschum,

Quote - You could check if that file has been written.

Yes, the file has been written to the path:

C:Poser Pro 2012RuntimeuiSpawnCharacterText.xml

PP2012 is installed to the path:

C:Poser Pro 2012PoserPro.exe

The script is installed under that same path in ScriptsMenu.

The main content runtime for the installation is:

C:Documents and SettingsCustomerMy DocumentsPoser Pro 2012 ContentRuntime


lesbentley ( ) posted Mon, 19 March 2012 at 11:41 AM

@bagginsbill

I tried the edit you sugested

dg=SpawnCharacterDialog(poser.Scene().CurrentFigure())

dg.Show()

On running the script I got:

  File "C:Poser Pro 2012RuntimePythonposerScriptsScriptsMenuSC-Test-01.py", line 375
    dg=SpawnCharacterDialog(poser.Scene().CurrentFigure())
     ^
IndentationError: expected an indented block


markschum ( ) posted Mon, 19 March 2012 at 11:47 AM

I used the path as an example to show it was the wrong runtime for PP2012.

The text says the script was updated for V4.


markschum ( ) posted Mon, 19 March 2012 at 11:51 AM

try:
    dg=SpawnCharacterDialog(poser.Scene().CurrentFigure())
    dg.Show()
except FigureError:
    pass
except:
    print "This script requires Poser 6 SR2 or later"

 

when you remove the try and except lines you need to move the dg=  and dg.show to the beginning of the line. (same indent as the try: line)

 


lesbentley ( ) posted Mon, 19 March 2012 at 11:53 AM

@bagginsbill

Added tabe to your code and got:

  File "C:Poser Pro 2012RuntimePythonposerScriptsScriptsMenuSC-Test-03.py", line 378
    
              ^
SyntaxError: invalid syntax


bagginsbill ( ) posted Mon, 19 March 2012 at 12:05 PM

LB:

Do not add tabs - remove them. Remember I wrote this:

"(No indentation on that)"


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


lesbentley ( ) posted Mon, 19 March 2012 at 12:07 PM

Sorry BB, did not realize i was suposed ti remove the "try" line. Now I get:

Traceback (most recent call last):
  File "C:Poser Pro 2012RuntimePythonposerScriptsScriptsMenuSC-Test-05.py", line 374, in
    dg=SpawnCharacterDialog(poser.Scene().CurrentFigure())
  File "C:Poser Pro 2012RuntimePythonposerScriptsScriptsMenuSC-Test-05.py", line 73, in init
    self.SetStatusText("Enter morph name")
  File "C:Poser Pro 2012RuntimePythonposerScriptsScriptsMenuSC-Test-05.py", line 135, in SetStatusText
    self.dlg.SetText("status",StatusText)
TypeError: no such text field


lesbentley ( ) posted Mon, 19 March 2012 at 12:18 PM

file_479693.jpg

 

The above image shows the code I am now using. Is this correct?

The message it generates is:

Traceback (most recent call last):
  File "C:Poser Pro 2012RuntimePythonposerScriptsScriptsMenuSC-Test-05.py", line 374, in
    dg=SpawnCharacterDialog(poser.Scene().CurrentFigure())
  File "C:Poser Pro 2012RuntimePythonposerScriptsScriptsMenuSC-Test-05.py", line 73, in init
    self.SetStatusText("Enter morph name")
  File "C:Poser Pro 2012RuntimePythonposerScriptsScriptsMenuSC-Test-05.py", line 135, in SetStatusText
    self.dlg.SetText("status",StatusText)
TypeError: no such text field


lesbentley ( ) posted Mon, 19 March 2012 at 12:22 PM · edited Mon, 19 March 2012 at 12:23 PM

@PhilC,

Quote - It is writing but not reading the XML file.

When I updated my scripts to Poser 9/Poser Pro 2012 I also had trouble with these native Poser dialogs. Where ever possible I rewrote them to use wxPython.

All paths appear correct. It is possible that there is an incompatibility somewhere within the 35 lines of XML code. Good luck with finding that :)

Since it is a relatively straight forward GUI it may be quicker to rewrite it in wxPython than to find where the anomaly is.

I'm sure you know what you are talking about (I don't :-)). I would not have a clue how to rewrite it in wxPython. So unless svdl, or someone else, updates the script for PP2012, it looks like I'm sunk.

It's not that there are no alternatives, but the alternatives are either more work, or cost money :scared:(I'm tight as a fishes ...).


bagginsbill ( ) posted Mon, 19 March 2012 at 1:15 PM

The error is interesting, but I don't know the API that is being relied upon here. I think this is reverse-engineered stuff going on as Poser never officially supported user-defined XML dialogs. The entire old UI was written this way, but now has all been replaced. I suspect that this kind of complex UI has to be re-implemented in wx.

Leaving the subject of Python script problems aside, what is the problem that is solved by this script? Is it so you can make a full body morph from the currently modified figure?

If so, is it not easier to just use the new PP2012 menu item Figure/Create Full Body Morph?

(There are many new things in Poser that make a lot of scripts completely pointless. Always learn the new features before you set about updating a script that no longer fills a gap.)


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)


lesbentley ( ) posted Mon, 19 March 2012 at 2:25 PM

Quote - [...] what is the problem that is solved by this script?

The script makes an INJ-REM pair of pz2 files from the current morphed state of the selected figure. All morphs that are expressed in the figure are consolidated into one morph per actor. A delta injection pose is written that will inject the morph into a PBMCC channel, you can choose which one. You can also choose precision filtering for the morph.

It only does one job, makes an INJ-REM, but it does it extremely well, giving me all the options I need with the minimum fuss and user intervention.


jonnybode ( ) posted Thu, 22 March 2012 at 11:27 PM

I feel your pain Lesbentley, this is one of my favourite scripts too.

Havent found an alternative for it to use in Poser Pro 2012 so I still have Poser Pro 2010 installed and create my characters inj/rem files there (unfortunately that excludes the weight mapped ones).



lesbentley ( ) posted Fri, 23 March 2012 at 3:12 AM

I have not tried this, but I strongly suspect that you will be able to load the WM figures in Pro 2010, for the purposes of running the script and making the INJ file. It should not matter that the weight map does not work. Just make sure you zero the rotations in the Joint Editor before running the script.

Still, it would be very nice to be able to do it all in PP2012.


xen ( ) posted Fri, 04 May 2012 at 3:44 AM

Has anyone managed to solve this problem?


Snarlygribbly ( ) posted Tue, 08 May 2012 at 3:24 AM

Quote - Has anyone managed to solve this problem?

I added this functionality to my general purpose SceneFixer script.

Free stuff @ https://poser.cobrablade.net/


xen ( ) posted Tue, 08 May 2012 at 1:32 PM

Thanks! Works great.


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.