Forum: Poser Python Scripting


Subject: Copy shader tree?

vholf opened this issue on Mar 12, 2009 · 17 posts


vholf posted Thu, 12 March 2009 at 11:12 PM

Hi, I'm trying to copy an entire shader tree of a material to paste it on another material, do I have to manually set every node and inputs?

Here's part of the code I'm trying:

for mat in currentFigure.Materials():
    if mat.Name() in matsToCopy:
        print mat.Name()
        # Delete current nodes
        for node in mat.ShaderTree().Nodes():
            if node.Name() <> poser.kNodeTypeCodePOSERSURFACE:
                mat.ShaderTree().DeleteNode(node)
        # Copy nodes from selected mats
        for node in cShaderTree.Nodes():
            if node.Name() <> poser.kNodeTypeCodePOSERSURFACE:
                new_node = mat.ShaderTree().CreateNode( node.Type() )
                new_node = node

But of course that only copies the name, things like texture maps, inputs and such wont get copied, any idea?