Hello, Is there possibale to create a standard surface directly in new node editor (not expresso) ?
When I create a Redshift node material it always return a old RS material by default. now my solution is add a new standard surface shader and remove the old RS material , Is there a smart way to do this ?
(by the way, I know I can use CallCommand
fuction , but I working a a custom API with Redshift , so I need a controllable way )
Here is a little lines I do this :
import c4d
import maxon
StandardMaterialAssetID = maxon.Id("com.redshift3d.redshift4c4d.nodes.core.standardmaterial")
StandardOutputPortID = maxon.Id("com.redshift3d.redshift4c4d.nodes.core.standardmaterial.outcolor")
OutputMaterialAssetID = maxon.Id("com.redshift3d.redshift4c4d.node.output")
OutputSurfacePortID = maxon.Id("com.redshift3d.redshift4c4d.node.output.surface")
def CreateNodeMat(matname):
mat = c4d.BaseMaterial(c4d.Mmaterial)
nodeMaterial = mat.GetNodeMaterialReference()
nodespaceId = maxon.Id("com.redshift3d.redshift4c4d.class.nodespace")
addedGraph = nodeMaterial.AddGraph(nodespaceId)
nimbusRef = mat.GetNimbusRef(nodespaceId)
graph = nimbusRef.GetGraph()
endNodePath = nimbusRef.GetPath(maxon.NIMBUS_PATH.MATERIALENDNODE)
endNode = graph.GetNode(endNodePath)
predecessor = list()
maxon.GraphModelHelper.GetDirectPredecessors(endNode, maxon.NODE_KIND.NODE, predecessor)
bsdfNode = predecessor[0]
bsdfNodeInputs = bsdfNode.GetInputs()
with graph.BeginTransaction() as transaction:
STM = graph.AddChild('', StandardMaterialAssetID, maxon.DataDictionary())
inPort = endNode.GetInputs().FindChild("com.redshift3d.redshift4c4d.node.output.surface")
outPort = STM.GetOutputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.standardmaterial.outcolor")
bsdfNode.Remove()
outPort.Connect(target = inPort, modes=maxon.WIRE_MODE.NORMAL, reverse=False)
transaction.Commit()
doc.InsertMaterial(mat)
mat.SetName(matname)
if __name__ == "__main__":
CreateNodeMat("RS Node STD")