Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Mar 19 1:03 pm)
Copy nodes from one existing material to another existing material:
copy_material(material_A, material_B)
Copy an existing materials to any actor. Material is created if it does not exist already:
copy_material_to_actor(existing_material, target_actor)
Copy a set of materials from one poser object (actor or figure) to another object (actor or figure):
copy_materials(source, target)
Update: Set the correct render engine in Shadertree.
def copy_material(source_material, target_material, clean=True):
assert isinstance(source_material, poser.MaterialType)
assert isinstance(target_material, poser.MaterialType)
target_layer_names = [l.Name() for l in target_material.Layers()]
for source_idx, source_layer in enumerate(source_material.Layers()):
if source_layer.Name() not in target_layer_names:
target_material.CreateLayer(source_layer.Name())
target_layer_names = [l.Name() for l in target_material.Layers()]
target_idx = target_layer_names.index(source_layer.Name())
source_tree = source_material.LayerShaderTree(source_idx)
target_tree = target_material.LayerShaderTree(target_idx)
if clean:
for node in target_tree.Nodes():
if not node.Type() in "PoserSurface CyclesSurface":
node.Delete()
copy_shadertree(source_tree, target_tree)
for renderengine in (poser.kRenderEngineCodeFIREFLY,
poser.kRenderEngineCodeSUPERFLY,
poser.kRenderEngineCodePOSER4):
root_node = source_tree.RendererRootNode(renderengine)
if root_node:
troot = target_tree.NodeByInternalName(root_node.InternalName())
target_tree.SetRendererRootNode(renderengine, troot)
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.