Thu, Dec 12, 7:14 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 Dec 02 3:16 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: Snap-To Script Update


Uncanny_Film ( ) posted Mon, 24 April 2023 at 9:47 AM · edited Wed, 04 December 2024 at 1:03 PM

Can someone Update this script to work with Poser 12?

Thanks.




#-----------------------------------------------------------------------------

# Snap-to

# Jan 9,06

# Copyright (c) 2006 by David G. Drumright (ockham)

# Select the 'mover' before hitting the script.

# Hit the script, then select the 'destination'.

# The 'mover' will go to the dest.

#-----------------------------------------------------------------------------


import poser

import string

scene=poser.Scene()


Mover=scene.CurrentActor()

if not Mover.IsProp() and not Mover.ItsFigure(): exit


from Tkinter import *


#-----------------------------------------------------------------------------

# Next section is TK

#------------------------------------------------------------


class App:

    def __init__(self, master, textMessage):

        self.master = master

        master.title("Snap-to")


        self.StatusEntry = Entry(self.master,width=60)

        self.StatusEntry.grid(row=0,column=0)


        self.master.protocol('WM_DELETE_WINDOW', self.HandleCancel)



    # - - - - - - - - - - - - - - - - - -

    def ShowStatus(self,S): # Just saving repetition

        self.StatusEntry.delete(0,END)

        self.StatusEntry.insert(0,S)

        self.StatusEntry.update_idletasks()


    # - - - - - - - - - - - - - - - - - -


    def Update(self):


        if scene: scene.ProcessSomeEvents(1)


        self.ShowStatus("%s is mover.  Waiting to select destination..." % Mover.Name())


        Dest=scene.CurrentActor()

        # Two ways to be a different object.  Either the Name is

        # different, or the part is on a different figure.

        Diff = 0

        DF=Dest.ItsFigure()

        MF=Mover.ItsFigure()

        if string.upper(Dest.Name())=='BODY':  Diff = 0

            # Somewhat tricky.

            # It appears that the BODY gets quietly selected very briefly before you

            # select a part, so we can't act on the BODY.


        elif Dest.Name() != Mover.Name(): Diff = 1


        elif DF and MF and (DF.Name() != MF.Name()): Diff = 1


        if Diff:

            if string.upper(Dest.Name())=='BODY':

                DestX=Dest.ParameterByCode(poser.kParmCodeXTRAN).Value()

                DestY=Dest.ParameterByCode(poser.kParmCodeYTRAN).Value()

                DestZ=Dest.ParameterByCode(poser.kParmCodeZTRAN).Value()


            else:

                scene.DrawAll()

                # Locate actual center of dest.

                Geom=Dest.Geometry()

                MinX= 10000.0

                MinY= 10000.0

                MinZ= 10000.0

                MaxX=-10000.0

                MaxY=-10000.0

                MaxZ=-10000.0

                for v in range(Geom.NumVertices()):

                    WV=Geom.WorldVertex(v)

                    if   WV.X() > MaxX: MaxX=WV.X()

                    elif WV.X() < MinX: MinX=WV.X()

                    if   WV.Y() > MaxY: MaxY=WV.Y()

                    elif WV.Y() < MinY: MinY=WV.Y()

                    if   WV.Z() > MaxZ: MaxZ=WV.Z()

                    elif WV.Z() < MinZ: MinZ=WV.Z()

                DestX=(MaxX+MinX)/2.0

                DestY=(MaxY+MinY)/2.0

                DestZ=(MaxZ+MinZ)/2.0

            Mover.ParameterByCode(poser.kParmCodeXTRAN).SetValue(DestX)

            Mover.ParameterByCode(poser.kParmCodeYTRAN).SetValue(DestY)

            Mover.ParameterByCode(poser.kParmCodeZTRAN).SetValue(DestZ)

            scene.SelectActor(Mover) # return to the item we're trying to move

            scene.DrawAll()


            self.master.destroy() # Done.


        else: # Keep watching

            root.lift()

            root.after(100, self.Update)



    # - - - - - - - - - - - - - - - - - -


    def HandleCancel(self):

        self.master.destroy()


#------------------------------------------------------------

# Activate the loop

#------------------------------------------------------------


root = Tk()

app = App(root, '')

app.Update()

root.mainloop()


#------------------------------------------------------------

# End TK loop.

#-----------------------------------------------------------------------------








Win10 - AMD 2nd Gen Ryzen Threadripper 2950X, 16-Core, 32 Thread 4.4 GHz - 128GB Ram - X2 GeForce RTX 3060 Ti - 3D-connexion  

Poser 12 | Octane Render |  Real-Flow | 3DCoat | Speed Tree | Adobe Premiere  |  Adobe After Effects |  Adobe Audition |  Adobe Photoshop


HartyBart ( ) posted Mon, 24 April 2023 at 9:54 AM

It's been done. It's free on ShareCG as "SnapTo for Poser 12".



Learn the Secrets of Poser 11 and Line-art Filters.


Uncanny_Film ( ) posted Mon, 24 April 2023 at 1:41 PM

HartyBart posted at 9:54 AM Mon, 24 April 2023 - #4463231

It's been done. It's free on ShareCG as "SnapTo for Poser 12".

Got it.

Thanks




Win10 - AMD 2nd Gen Ryzen Threadripper 2950X, 16-Core, 32 Thread 4.4 GHz - 128GB Ram - X2 GeForce RTX 3060 Ti - 3D-connexion  

Poser 12 | Octane Render |  Real-Flow | 3DCoat | Speed Tree | Adobe Premiere  |  Adobe After Effects |  Adobe Audition |  Adobe Photoshop


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.