And It is possiable to expose a inport without a input node?
AKA : can I do this when I create node mat in python?
Thank you for reaching out to us. Could you please clarify what you mean by "expose an inport without an input node"? The command "Show in Node Editor" will reveal the node on which this command has been invoked. When a port has no input, i.e., there is no node, then there is nothing to reveal.
Maybe I am not aware of a functionality of Cinema 4D here or misunderstanding you?
I want to create a Node mat with some pre-exposed ports(python)(It's painful to search so many daily port) ,like this picture said:
Show in Node Editor
Hi @Dunhou, you should define the value maxon.NODE.ATTRIBUTE.HIDEPORTINNODEGRAPH of the port to False like so port.SetValue(maxon.NODE.ATTRIBUTE.HIDEPORTINNODEGRAPH, maxon.Bool(False)). When calling SetValue it is important to pass a maxon data as the current Python system is not able to automatically guess the expected result.
Find bellow a more complete example that expect you selected a Standard Node Material and will expose all fresnel port of all BSDF node in the node editor.
from c4d import gui
# Main function
mat = doc.GetActiveMaterial()
if mat is None:
raise ValueError("can't create a BaseMaterial")
# Retrieve the graph of the current NodeSpace
nodespaceId = c4d.GetActiveNodeSpaceId()
nimbusRef = mat.GetNimbusRef(nodespaceId)
if nimbusRef is None:
raise ValueError("can't retrieve the nimbus ref for that node space")
graph = nimbusRef.GetGraph()
if graph is None:
raise ValueError("can't retrieve the graph of this nimbus ref")
# Assume that the given node is a BSDF node and will display it's Fresnel port.
# This function will be passed to FindNodesByAssetId.
fresnelPort = node.GetInputs().FindChild("fresneltype")
if not fresnelPort:
raise ValueError("can't find a fresnel port")
# Display the port in the node editor
with graph.BeginTransaction() as tr:
# This is mandatory to use a maxon.Bool, as Python is not able to
# deduce the expected type in this situation.
# Execute DisplayFresnelonBSDF on all BSDF nodes of the graph
maxon.GraphModelHelper.FindNodesByAssetId(graph, "net.maxon.render.node.bsdf", False, DisplayFresnelonBSDF)
# Execute main()