Hi @i_mazlov , thanks for the great answer.
I've learned a lot
Cheers~
君心Jay
Hi @i_mazlov , thanks for the great answer.
I've learned a lot
Cheers~
君心Jay
I would appreciate it if you could demonstrate the correct way to connect the red lines in the chart.
import c4d
import maxon
from redshift_api import redshift_id as rsID
def create_psr():
mat = doc.GetActiveMaterial()
if mat is None:
raise ValueError("There is no selected BaseMaterial")
nodeMaterial = mat.GetNodeMaterialReference()
if nodeMaterial is None:
raise ValueError("Cannot retrieve node material reference")
nodespaceId = c4d.GetActiveNodeSpaceId()
nimbusRef = mat.GetNimbusRef(nodespaceId)
if nimbusRef is None:
raise ValueError("Cannot retrieve the nimbus ref for that node space")
graph = nimbusRef.GetGraph()
if graph is None:
raise ValueError("Cannot retrieve the graph of this nimbus ref")
root = graph.GetRoot()
nodes = []
root.GetChildren(nodes, maxon.NODE_KIND.NODE)
with graph.BeginTransaction() as transaction:
TexNodeID: maxon.Id = maxon.Id(rsID.StrNodeID("texturesampler"))
rsmathabsvectorID: maxon.Id = maxon.Id(rsID.StrNodeID("rsmathabsvector"))
rsmathabsID: maxon.Id = maxon.Id(rsID.StrNodeID("rsmathabs"))
TexNode: maxon.GraphNode = graph.AddChild(maxon.Id(), TexNodeID)
P_rsmathabsvector: maxon.GraphNode = graph.AddChild(maxon.Id(), rsmathabsvectorID)
S_rsmathabsvector: maxon.GraphNode = graph.AddChild(maxon.Id(), rsmathabsvectorID)
R_rsmathabs: maxon.GraphNode = graph.AddChild(maxon.Id(), rsmathabsID)
TexNodeScaleInputPort: maxon.GraphNode = TexNode.GetInputs().FindChild(
rsID.StrPortID("texturesampler", "scale"))
TexNodeOffsetInputPort: maxon.GraphNode = TexNode.GetInputs().FindChild(
rsID.StrPortID("texturesampler", "offset"))
TexNodeRotateInputPort: maxon.GraphNode = TexNode.GetInputs().FindChild(
rsID.StrPortID("texturesampler", "rotate"))
P_rsmathabsvectorOutPort: maxon.GraphNode = P_rsmathabsvector.GetOutputs().FindChild(
rsID.StrPortID("rsmathabsvector", "out"))
S_rsmathabsvectorOutPort: maxon.GraphNode = S_rsmathabsvector.GetOutputs().FindChild(
rsID.StrPortID("rsmathabsvector", "out"))
R_rsmathabOutPort: maxon.GraphNode = R_rsmathabs.GetOutputs().FindChild(
rsID.StrPortID("rsmathabs", "out"))
P_rsmathabsvectorInputPort: maxon.GraphNode = P_rsmathabsvector.GetInputs().FindChild(
rsID.StrPortID("rsmathabsvector", "input"))
S_rsmathabsvectorInputPort: maxon.GraphNode = S_rsmathabsvector.GetInputs().FindChild(
rsID.StrPortID("rsmathabsvector", "input"))
R_rsmathabInputPort: maxon.GraphNode = R_rsmathabs.GetInputs().FindChild(
rsID.StrPortID("rsmathabs", "input"))
P_rsmathabsvectorOutPort.Connect(TexNodeScaleInputPort, modes=maxon.WIRE_MODE.NORMAL, reverse=False)
S_rsmathabsvectorOutPort.Connect(TexNodeOffsetInputPort, modes=maxon.WIRE_MODE.NORMAL, reverse=False)
R_rsmathabOutPort.Connect(TexNodeRotateInputPort, modes=maxon.WIRE_MODE.NORMAL, reverse=False)
GroupNodes = []
GroupNodes.append(TexNode)
GroupNodes.append(P_rsmathabsvector)
GroupNodes.append(S_rsmathabsvector)
GroupNodes.append(R_rsmathabs)
TexNodeScaleOutPort: maxon.GraphNode = TexNode.GetInputs().FindChild(
rsID.StrPortID("texturesampler", "scale"))
groupRoot = maxon.GraphNode()
groupRoot = graph.MoveToGroup(groupRoot, maxon.Id("PSRgroupID"), GroupNodes)
P_InputPort = maxon.GraphModelHelper.CreateInputPort(groupRoot, "scaleid", "缩放")
S_InputPort = maxon.GraphModelHelper.CreateInputPort(groupRoot, "offsetid", "偏移")
R_InputPort = maxon.GraphModelHelper.CreateInputPort(groupRoot, "rotateid", "旋转")
PSR_OutputPort = maxon.GraphModelHelper.CreateOutputPort(groupRoot, "psrid", "输出")
transaction.Commit()
c4d.EventAdd()