Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
It's been done. It's free on ShareCG as "SnapTo for Poser 12".
Learn the Secrets of Poser 11 and Line-art Filters.
HartyBart posted at 9:54 AM Mon, 24 April 2023 - #4463231
Got it.It's been done. It's free on ShareCG as "SnapTo for Poser 12".
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
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.
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