HartyBart opened this issue on Jul 14, 2021 ยท 19 posts
adp001 posted Thu, 22 July 2021 at 8:30 AM
Here is a wrapper class for actors. Use it like a normal actor.
import sys
if sys.version_info.major > 2:
basestring = str
SCENE = poser.Scene()
class pActor(object):
"""
Save access to Actor methods.
For each method call SCENE.ActorByInternalName(self._iname).method([...]) is used.
"""
__slots__ = "_iname",
def __init__(self, ac=None):
if ac is None:
ac = SCENE.CurrentActor()
elif isinstance(ac, basestring):
try:
ac = SCENE.Actor(ac)
except poser.error:
ac = SCENE.ActorByInternalName(ac)
elif not isinstance(ac, poser.ActorType):
raise AttributeError("Need an actor or an actors name to proceed.")
self._iname = ac.InternalName()
def __call__(self):
return SCENE.ActorByInternalName(self._iname)
def __getattr__(self, item):
if not item.startswith("_"):
return getattr(SCENE.ActorByInternalName(self._iname), item)
if __name__ == "__main__":
actor = pActor() # get current actor
actor = pActor("Main Camera") # get main camera, conventional name
actor = pActor("MAIN_CAMERA") # get main camera, internal name
parm = actor.Parameter("Focal") # get a Parameter