3dcheapskate opened this issue on Sep 22, 2021 ยท 13 posts
adp001 posted Thu, 23 September 2021 at 2:57 AM
Maybe the following makes it more transparent to you:
def get_or_create(actor, parm_name):
"""Helper function to get or create a parameter"""
p = actor.Parameter(parm_name)
if not p:
p = actor.CreateValueParameter(parm_name)
return p
SCENE = poser.Scene()
def init(actorname, framenr_start=0, modulo_value=360):
def __callback__(parm, value):
actor = parm.Actor()
mod = actor.Parameter("Modulo Value").Value()
actor.Parameter("Result").SetValue(value % mod)
return value
actor = SCENE.Actor(actorname)
# Make sure the following parameters exist
get_or_create(actor, "Frame Counter").SetValue(framenr_start)
get_or_create(actor, "Modulo Value").SetValue(modulo_value)
get_or_create(actor, "Result")
# Set callback
actor.Parameter("Frame Counter").SetUpdateCallback(__callback__)
# For demo tart with the currently selected actor in this case.
init(SCENE.CurrentActor().Name())