Forum: Poser - OFFICIAL


Subject: Material Preset to Change ONLY Colors on a Blender Node?

perpetualrevision opened this issue on Aug 21, 2018 ยท 20 posts


ironsoul posted Thu, 23 August 2018 at 4:11 PM

Rough poc script below to see if we're thinking in the same area, putting the user interaction bit to one side at the moment + didn't see Karina's post before doing it so based on original pics

It assumes the Blender node to be changed on each prop is called "CTag" at the moment, this can be changed
Assumes the material with the blender node is active when the script is run
Need to render to see effect at moment


import poser

############################################
# Function returns Node within a shader tree
# that has the given name
############################################
def findNodeInMat( oMat, sName ):

    oFoundNode = None    
    oShaderTree = oMat.ShaderTree()
    oNodeSet =  oShaderTree.Nodes()

    for Node in oNodeSet:
        if Node.Name() == sName:
            oFoundNode = Node
            break

    return oFoundNode

###############################################################
# Copies blender colour nodes from source to destinattion
###############################################################

def CopyInputs(oSource, oDest):
    
    (cRed,cGreen,cBlue) = oSource.InputByInternalName("Input_1").Value()
    oDest.InputByInternalName("Input_1").SetColor(cRed,cGreen,cBlue)
    (cRed,cGreen,cBlue) = oSource.InputByInternalName("Input_2").Value()
    oDest.InputByInternalName("Input_2").SetColor(cRed,cGreen,cBlue)

    return


#####################################################################
# Main
####################################################################
scene = poser.Scene()

scn = poser.Scene()
cMat = scn.CurrentMaterial()

oCopyName = findNodeInMat(cMat,"CTag")
oActorSet = scn.Actors()

for oActor in oActorSet:
    
    if oActor.IsProp():
        oMats = oActor.Materials()
        
        for Mat in oMats:
           
            fNode = findNodeInMat(Mat,"CTag")
            if fNode:
                
                if fNode != oCopyName:
                    CopyInputs(oCopyName,fNode)