Fri, Nov 22, 1:13 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: Making a conforming garment


Anthony Appleyard ( ) posted Sat, 26 May 2018 at 10:59 AM · edited Thu, 21 November 2024 at 8:06 PM

When making a conforming garnent, one tedious job is copying all relevant origins and endpoints to the garment from whatever it conforms to. For that purpose, I wrote this Python script. Please test it and comment on it

import poser
import string
import os
import sys

def findactor(fig,fn):
    if fig==None:
        return None
    acts1=fig.Actors()
    for ac1 in acts1:
        if ac1.InternalName().startswith(fn):
            return ac1
    return None

scn = poser.Scene()
act = scn.CurrentActor()
fig=act.ItsFigure()
if fig == None:
    print "I am starting at a ",act.Name()
    raise("I need to be on a character, or a prop owned by a character")
else:
    print "I am starting at ",fig.Name(),"'s ",act.Name()
acts=fig.Actors()
cfig=fig.ConformTarget()
if cfig==None:
    print fig.Name(),"is not a conformer."
    raise("error")
else:
    print fig.Name(),"conforms to",cfig.Name()
cacts=cfig.Actors()
for act in acts:
    na=act.InternalName().split(':')[0]+':'
    print "testing",act.InternalName()
    if na=="CenterOfMass:": continue
    if na=="GoalCenterOfMass:": continue
    print "checking",fig.Name(),"'s",na
    ca=findactor(cfig,na)
    if ca==None:
        print "not found",cfig.Name(),"'s",na
        continue
    print "conforming",fig.Name(),"'s",act.Name(),"to",cfig.Name(),"'s",ca.Name()
    (ox,oy,oz)=ca.Origin()
    (ex,ey,ez)=ca.EndPoint()
    act.SetOrigin(ox,oy,oz)
    act.SetEndPoint(ex,ey,ez)
    print "set origin to",ox,oy,oz,", endpoint to",ex,ey,ez
poser.ProcessCommand(1559)
#scn.DrawAll();


FVerbaas ( ) posted Fri, 15 June 2018 at 12:18 PM
Forum Coordinator

OK making my way back into the Python range. One question is how you handle the exceptions you raise. Those make Pyhon exit?


Anthony Appleyard ( ) posted Sun, 22 July 2018 at 5:24 AM

To FVerbaas: By letting the raise instruction display its message and then exit.


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.