Filter: Safe | Wed, Apr 8, 10:43 AM CDT

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Lobo3433, Staff Forum Coordinators: Anim8dtoon

Poser Python Scripting F.A.Q (Last Updated: 2026 Mar 27 4:38 pm)

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: Calling ADP (or anyone else that can help) : re UDPServer


mathman ( ) posted Sun, 03 May 2009 at 5:40 AM ยท edited Wed, 08 April 2026 at 10:41 AM

Hi all,

I have visited ADP's website, and noticed a pair of Python scripts packaged together. They are UDPServer and PPMaster.

If I understand the description correctly, these look like the answer to my prayers. I use PRPC in Poser 7 so that I can load up my characters, poses, lights etc from P3DO Explorer (mainly because I absolutely DESPISE the Poser Library with a passion). I've become used to this, and find this arrangement to be quite comfortable.

The drawback of this is that I can't run any other python script as long as this one is running.

This setup (UDPServer) looks as if it could possibly fix this problem, however I have read the description on ADP's page and still don't know how to get this setup running correctly.

At the moment, when I run UDPServer.py from within Poser, I get the following error messages : 

*Traceback (most recent call last):
  File "C:Program Filese frontierPoser 7RuntimePythonposerScriptsScriptsMenuADPUDPserver.py", line 617, in ?
    app=UDPApp(root,ip="192.168.0.198")
  File "C:Program Filese frontierPoser 7RuntimePythonposerScriptsScriptsMenuADPUDPserver.py", line 462, in init
    self.udp=poserUDP(IP=ip,portIn=portIn,portOut=portOut)
  File "C:Program Filese frontierPoser 7RuntimePythonposerScriptsScriptsMenuADPUDPserver.py", line 87, in init
    self.conIn.bind((self.IP,self.portIn))
  File "", line 1, in bind
socket.error: (10049, "Can't assign requested address")

Any help appreciated (I need a bit of hand-holding here, as my Python know-how isn't too great).

Many thanks and regards,
Andrew


gishzida ( ) posted Sun, 03 May 2009 at 5:54 AM

what is the IP of the machine you are running the script? Is it 192.168.0.198? I suspect that the IP should equal the IP address of the machine running the UDPServer script


PhilC ( ) posted Sun, 03 May 2009 at 6:37 AM
mathman ( ) posted Sun, 03 May 2009 at 6:37 AM

Thanks gishzida,

That problem solved ! .... I found out my IP Address via ipconfig and subbed it into the UDPServer script.

I've now got a little console that pops up and allows me to run PRPC and then go off and run something else. Problem now is that I can't get any of the python windows to sit on top of the Poser window, which means that I have to minimize the Poser window each time.

The other thing is that I tried firing up PPMaster.py, but this didn't seem to do anything.

So, by and large, I'm still in the dark with regards to these tools.

Any further help / clarification / enlightenment appreciated.

regards,
Andrew


mathman ( ) posted Sun, 03 May 2009 at 7:55 AM

Phil, thanks, that's nifty but doesn't quite suit me.

Its a bit quicker using P3DO Explorer, because while (say) M4 character is loading up, I can go and look for (say) the M4 morph injections. Furthermore, the P3DO Explorer interface lends itself better for me to go to the next file to load up.

With your script, however, I have to wait for M4 to load up before loading up the next file.

So, if I can use ADP's script to get around the P7 problem of only being able to run one python script at a time, then I'll be set up well :)

regards,
Andrew


Dizzi ( ) posted Sun, 03 May 2009 at 11:05 AM

And why don't you just close PRPC, when you want to run another script? Hotkey the PRPC script, if P3DO can't start it automatically. 



yarp ( ) posted Sun, 03 May 2009 at 11:50 AM

Mathman, note that there's a workaround to the inability to run Python scripts while Prcp is running in P3dO itself.
In P3dO Tools meny you should have a "Run Pyhton Script..." command.
It is easy enough to use since it will default to the latest opened Python script directory.

As Dizzi said starting Prpc automatically would be the solution, I intend to work on this as soon as P3dO 2.2 is out.

Also if there's a Port address collision while using Prpc, you may modify the default Port used by P3dO in Option dialog (plugins tab). But you have to modify the Prpc script manually to reflect that change. P-mail me if you need any assistance for this.

Yarp
www.senosoft.com

Yarp - author of P3DO Organizer for Poser


mathman ( ) posted Sun, 03 May 2009 at 4:51 PM

Thanks, yarp. I didn't know you could do this. In the event of a port address conflict, what would you change it to ? 

Dizzi - I have been trying to avoid the scenario of closing prpc, obviously it becomes annoying to close it and re-open it every time I wanted to run another python script. Also, I don't know what you mean when you say "hotkey the prpc script" ??


yarp ( ) posted Mon, 04 May 2009 at 12:00 AM

Just add 1 to the default Port address: 49161 instead of 49160. And so on if there's any other conflict.
You don't have to restart P3dO, but you have to edit the Prcp script and restart it in Poser.

Yarp - author of P3DO Organizer for Poser


Dizzi ( ) posted Mon, 04 May 2009 at 11:31 AM

You can assign keyboard shortcuts to python scripts that reside in Poser's ScriptMenu. If you rename for example the "PRPCd.py" to "PRPCd###Alt+Ctrl+p.py", you can run the script by pressing Alt+Ctrl+p.



mathman ( ) posted Mon, 04 May 2009 at 4:35 PM

Ah so!
Thanks, Dizzi :)


yarp ( ) posted Mon, 04 May 2009 at 4:40 PM

Coool, this is so cool.
Thank for the Tip Dizzi. There's for sure a lot to do with this.
This hotkey is the missing link to automating Prpc from a third party application.

Yarp - author of P3DO Organizer for Poser


Dizzi ( ) posted Mon, 04 May 2009 at 4:50 PM

Actually, it works without hotkeying, too. Doing it for a few years already:
Copy PRPC-Link to clipboard (so less chance of really ugly things happening if another application steals focus), focus Poser Window, Sendkeys.
But hotkeys make it of course easier (no clipboard action needed).

For those interested (delays from various user tests):

With hotkeys:
SetForegroundWindow(poserHandle);
  System.Threading.Thread.Sleep(100);
  SendKeys.SendWait(shortcutcode);

Without hotkeys:
  Clipboard.SetText(filename);
  SendKeys.Flush();
  SetForegroundWindow(poserHandle);
  System.Threading.Thread.Sleep(100);
  SendKeys.SendWait("%f{UP}{UP}{UP}{UP}{UP}{UP}{ENTER}"); //ALT+f, LEFT ARROW, DOWN ARROW
  SendKeys.Flush();
  System.Threading.Thread.Sleep(500); //another delay need for VISTA
  SendKeys.Flush();
  SendKeys.SendWait("^v{ENTER}");



yarp ( ) posted Tue, 05 May 2009 at 3:41 AM

Thanks for the code I will give it a try this morning.
The hotkey stuff is only working with P7 (there was no script menu in P6).

I was aware of the technic you describe above, but I hadn't give it a try. I was looking for an internal solution by trying to communicate directly with Poser Python dll.
But I have done nothing so far, so I should better stop thinking about reinventing the wheel.

Just a suggestion, you could replace the first sleep with a while loop. Something like:

nTicksOld = GetTickCount();
do {
  if (GetForeGroundWindow()==poserHandle)
     break;
  nTicks = GetTickCount();
} while (nTicks-nTicksOld<100);

But Vista is a real pain and the only solution for the other sleep is to get rid of it ;)

Yarp - author of P3DO Organizer for Poser


mathman ( ) posted Tue, 05 May 2009 at 7:13 PM

yarp :-- starting prpc automatically sounds like a fantastic leap ahead ! .... look forward to that.
Dizzi and yarp :-- i'm not sure what you are doing in your discussion but it looks impressive.


yarp ( ) posted Tue, 05 May 2009 at 11:25 PM

I guess so. It has been on my todo list for long but I sometime need a good kick to go ahead. Starting Prpc automatically is now working (at least with P7), I will make it available soon on my website (should be next friday).

Yarp - author of P3DO Organizer for Poser


mathman ( ) posted Wed, 06 May 2009 at 4:02 AM

WOOHOO.. can hardly wait :)


Dizzi ( ) posted Wed, 06 May 2009 at 7:49 AM

Sure my code could be improved with GetForeGroundWindow. But I'd suggest to use a counter variable and Sleep(1) in your loop (GetTickCount can overflow and active waiting isn't really the way to go :-)).



yarp ( ) posted Thu, 07 May 2009 at 12:00 AM

mathman, I will p-mail it to you. After all, this is thank to you that I gave it a look.

Overflow ? Thanks didn't knew that. One should carrefuly read the Msdn for each and every function and I've been using that one rather intensively. Clear now.
Frankly, I don't like to use Sleep because I've got the feeling I'm wasting the CPU. I agree that Sleeping 100 miliseconds is not a big deal  It's just me.
So the code is safe like this and waiting up to 1s (in case the system hangs):

DWORD dwTicksOld = GetTickCount();
DWORD dwTicks;
do {
  if (GetForeGroundWindow()==poserHandle)
     break;
  dwTicks = GetTickCount();
} while (dwTicks>dwTicksOld && dwTicks-dwTicksOld<1000)

Yarp - author of P3DO Organizer for Poser


mathman ( ) posted Thu, 07 May 2009 at 12:16 AM

wow, thanks yarp !! :)


Dizzi ( ) posted Thu, 07 May 2009 at 1:43 PM

Quote - Frankly, I don't like to use Sleep because I've got the feeling I'm wasting the CPU.

Well, what do you have against sleep? Just sleep 1ms, but don't use a loop with GetTickCount(). A GHz CPU will call GetTickCount() millions of times getting back the same ms value... That's bad ;-)



yarp ( ) posted Fri, 08 May 2009 at 1:36 AM ยท edited Fri, 08 May 2009 at 1:46 AM

You're right, a 1ms Sleep is a good thing. btw There was a bug because of this (should have been dwTicks>=dwTicksOld instead of dwTicks>dwTicksOld).
Actually, the call to GetForeGroundWindow has a cost too, so the Loop iterate only about 20 times in 100ms on my Vista computer.

Yarp - author of P3DO Organizer for Poser


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.