Hi community!
Questions:
How can I get the datetype of a selected port(GraphNode)?
Problem:
I want to get a type of a maxon.GraphNode
aka a port type. Like picture below, I select three port with very basic port type, and I wang to get the type of the port to do some further conditions, but I have trouble with this task.
I didn't find a api looks like build for this task , I try to get it with the codes and return like this, I can get color/ metalness which had a default value, but not the bump port. (the type returned is not like the GUI, but it can work.)
Color port
Name: standardmaterial@WO3Q2uk5Kp4pRHlNJ_Douc<com.redshift3d.redshift4c4d.nodes.core.standardmaterial.base_color
Value: 0.21404114365577698,0.21404114365577698,0.21404114365577698
ID: com.redshift3d.redshift4c4d.nodes.core.standardmaterial.base_color
Type: net.maxon.parametrictype.col<3,float64>
Metalness port
Name: standardmaterial@WO3Q2uk5Kp4pRHlNJ_Douc<com.redshift3d.redshift4c4d.nodes.core.standardmaterial.metalness
Value: 0
ID: com.redshift3d.redshift4c4d.nodes.core.standardmaterial.metalness
Type: float64
Codes:
import c4d
import maxon
def main():
mat = doc.GetActiveMaterial()
nodeMaterial = mat.GetNodeMaterialReference()
nodespaceId = c4d.GetActiveNodeSpaceId()
graph = nodeMaterial.GetGraph(nodespaceId)
def GetName(node):
if node is None:
return None
nodeName = node.GetValue(maxon.NODE.BASE.NAME)
if nodeName is None:
nodeName = node.GetValue(maxon.EffectiveName)
if nodeName is None:
nodeName = str(node)
return nodeName
def RetrieveInformationOfPort(port):
if port is None:
return True
portName = GetName(port)
portValue = port.GetDefaultValue()
print(f"Name: {portName}")
print(f"Value: {portValue}")
print(f"ID: {port.GetId()}")
print(f"Type: {portValue.GetType().GetId()}")
return True
maxon.GraphModelHelper.GetSelectedNodes(graph, maxon.NODE_KIND.PORT_MASK, RetrieveInformationOfPort)
c4d.EventAdd()
if __name__ == "__main__":
main()
Thanks for your times.
Cheers~