Forum: Poser Python Scripting


Subject: Snap for Macs - in development

HartyBart opened this issue on Jul 16, 2021 ยท 12 posts


HartyBart posted Fri, 16 July 2021 at 2:27 AM Online Now!

The following was kindly posted by adp001 for a new user a few days ago, and slightly extended by me. It is working and adp001 suggested I post it here for further comments and development. As you may know, Ockham's vital Snap mover script used Tkinter for looping, and thus was not for Mac users of Poser. The script below is a working demo of the same, but using WX rather than Tkinter. Thus it can (should) work for Mac users, providing them with a vital addition to Poser 11 and possibly also 12.

###
# A Poser script that offers a Mac user version of Ockham's famous SnapTo.
# Moves items around in a Poser scene, in an easy 'teleporting' manner.
# By adp001, version 1.0 July 2021.
# Tweaked and commented by HartyBart. Version 1.1.
###
import poser
import wx

SCENE = poser.Scene()

# Get the currently selected Scene actor by its internal name.
actor_iname = SCENE.CurrentActor().InternalName()
# Prompts the user to select the destination target by clicking once on it.
msg = wx.BusyInfo("Select Target Actor")

def theloop():
    global  msg
    #Check we have the correct actor selected, before starting the loop.
    if SCENE.CurrentActor().InternalName() != actor_iname:
        del msg # Delete the user message box.
        actor_A = SCENE.ActorByInternalName(actor_iname)
        actor_B = SCENE.CurrentActor()
        # Parent the first and second actors, here A (mover) and B (destination).
        actor_A.SetParent(actor_B)
        # A nas now moved to the position of B. Clear the XYZ location parameters for A.
        for code in (poser.kParmCodeXTRAN, poser.kParmCodeYTRAN, poser.kParmCodeZTRAN):
            actor_A.ParameterByCode(code).SetValue(0)
            # Now finesse the location of the mover. Such that it is not on top of, or inside, B.
            # Adjust the Z and X values if you have larger structures to move around, such as houses.
            actor_A.SetParameter("Ytran",0.0)
            actor_A.SetParameter("Ztran",0.2)
            actor_A.SetParameter("Xtran",0.2)
        # Ensure that A is the selected actor, and re-parent it to UNIVERSE to it is free again.
        SCENE.SelectActor(actor_A)
        actor_A.SetParent(SCENE.ActorByInternalName("UNIVERSE"))
        # Have OpenGL redraw the Preview viewport for the scene.
        SCENE.DrawAll()
    else:
        wx.CallLater(300, theloop)

theloop()

snap2-2.jpg



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