Forum: Poser Python Scripting


Subject: Useful Code Snippets

structure opened this issue on Jun 27, 2019 ยท 94 posts


structure posted Sat, 29 August 2020 at 2:34 PM Forum Coordinator

apply a material ( not a pose ) to an unparented prop

import os
import poser                                                # get poser
reset = False                                               # set reparent variable
scene = poser.Scene()                                       # define scene
actor = scene.CurrentActor()                                # get the actor

if len( actor.Materials() ) > 0:                            # make sure the actor has materials
    if actor.IsProp():                                      # is this actor a prop?
        if actor.Parent().Name() == "UNIVERSE":             # is this actor parented?
            actor.SetParent( scene.Actor("GROUND") )        # set actor parent
            reset = True                                    # inform script we need to reparent prop

    material = actor.Materials()[0]                         # get actors preview material
    material.LoadMaterialSet(
        os.path.join(poser.TempLocation(), "test.mt5" ))    # load material
    if reset:
        actor.SetParent( scene.Actor( "UNIVERSE") )         # if we need to reparent - do so

    scene.DrawAll()

Locked Out