Forum: Poser Python Scripting


Subject: Useful Code Snippets

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


FVerbaas posted Tue, 30 July 2019 at 9:44 AM Forum Coordinator

A simple function to copy matrerial collections between figures and props. if the target (a prop or a figure) has a material defined with a name that also appears in the materials list of the source, that material definition (shader) in the target will be overwritten by the material of the source.

def copyMaterialDefinitions(source, target):
    srcmats = source.Materials()
    tgtmats = target.Materials()
    for srcmat in srcmats:
        matnam = srcmat.Name()
        srcmat.SaveMaterialSet(matnam)
        try:
            target.Material(matnam).LoadMaterialSet(matnam)
        except:
            pass