Hi,
GetInputs/GetOuputs return a GraphNode. This Graphnode contains all the Inputs or the Outputs port that the Node contains but they are a child of this GraphNode. As this is still a GraphNode, you need to use one of those function. GetChildren, GetInnerNodes.
import c4d
import maxon
# Display the outputs ports of the selected nodes in the active NodeMaterial of the Active Nodespace.
def main():
# Retrieve the selected BaseMaterial
mat = doc.GetActiveMaterial()
if mat is None:
raise ValueError("There is no selected BaseMaterial")
# Retrieve the reference of the material as a node material.
nodeMaterial = mat.GetNodeMaterialReference()
if nodeMaterial is None:
raise ValueError("Cannot retrieve node material reference")
# Retrieve the current node space Id
nodespaceId = c4d.GetActiveNodeSpaceId()
# Retrieve the graph corresponding to that node space.
graph = nodeMaterial.GetGraph(nodespaceId)
if graph is None:
raise ValueError("Cannot retrieve the graph of this nimbus ref")
def DisplayOutputs(node):
# Will display node information
def PrintNodeInformation(port):
# Print here the needed information
print (port)
def DisplayChildren(node):
# Check if the node is valid and recursively display children.
if not node.IsValid():
return True
PrintNodeInformation(node)
node.GetChildren(DisplayChildren)
return True
# Retrieve the outputs port and the first level of children with GetChildren.
node.GetOutputs().GetChildren(DisplayChildren)
return True
# Retrieve the nodes that are selected and passed them to the function DisplayOutputs.
maxon.GraphModelHelper.GetSelectedNodes(graph, maxon.NODE_KIND.NODE, DisplayOutputs)
print('---------------- using Inner')
# using GetInnerNodes
def DisplayInner(node):
def PrintNode(port):
print(port)
return True
node.GetInnerNodes(maxon.NODE_KIND.OUT_MASK, False, PrintNode)
return True
maxon.GraphModelHelper.GetSelectedNodes(graph, maxon.NODE_KIND.NODE, DisplayInner)
if __name__ == "__main__":
main()
Cheers,
Manuel