Hi,
Since there are no relevant APIs on the node editor commands, I'm trying to use the CallCommands. But they don't seem work with using nodes.
Script below. Creates a node. Selects it. And hopefully rearranges it/layouts it.
I included it four times. But when I execute it. It doesn't rearrange the nodes at all.
Is there a way around this?
import c4d
import maxon
from maxon import GraphModelHelper
import os
def main():
doc = c4d.documents.GetActiveDocument()
mat = doc.GetActiveMaterial()
nodeMaterial = mat.GetNodeMaterialReference()
nodespaceId = c4d.GetActiveNodeSpaceId()
nimbusRef = mat.GetNimbusRef(nodespaceId)
graph = nimbusRef.GetGraph()
with graph.BeginTransaction() as transaction:
GraphModelHelper.DeselectAll(graph, maxon.NODE_KIND.ALL_MASK)
node_01 = graph.AddChild("", "com.redshift3d.redshift4c4d.nodes.core.standardmaterial", maxon.DataDictionary())
node_02 = graph.AddChild("", "com.redshift3d.redshift4c4d.nodes.core.texturesampler", maxon.DataDictionary())
node_03 = graph.AddChild("", "com.redshift3d.redshift4c4d.nodes.core.texturesampler", maxon.DataDictionary())
maxon.GraphModelHelper.SelectNode(node_01)
maxon.GraphModelHelper.SelectNode(node_02)
maxon.GraphModelHelper.SelectNode(node_03)
c4d.CallCommand(465002363) # Arrange All Nodes
transaction.Commit()
c4d.CallCommand(465002363) # Arrange All Nodes
c4d.CallCommand(465002363) # Arrange All Nodes
c4d.EventAdd()
c4d.CallCommand(465002363) # Arrange All Nodes
if __name__ == "__main__":
main()