Hello,
I'm new in python's world. I would like to know what peace of code I can wrhite to get any ID of nodes and nodes' ports.
I'm running C4D R21 under MAC OS.
In that case I'm trying to generate global and local matrice ports but it would be nice if I can use this to find any ports I need.
Here is a peace of code I've done, that generates some nodes and ports.
I've done some research but I'm a bit confused about how to do it.
import c4d
def main():
# Create a null object and add an Xpresso tag to it.
null = c4d.BaseList2D(c4d.Onull)
null[c4d.ID_BASELIST_NAME] = "ESSAIM - DROTEK-NL"
xpresso_tag = c4d.BaseList2D(c4d.Texpresso)
null.InsertTag(xpresso_tag)
# Crée la texture de référence Led
c4d.CallCommand(202586)
Ref_Led = doc.GetFirstMaterial()
Ref_Led[c4d.MATERIAL_USE_COLOR] = False
Ref_Led[c4d.MATERIAL_USE_REFLECTION] = False
Ref_Led[c4d.MATERIAL_USE_LUMINANCE] = True
Ref_Led[c4d.ID_BASELIST_NAME] = "REF_DROTEK-NL_LED"
# Get the node master and the root noode of that graphview.
master = xpresso_tag.GetNodeMaster()
root = master.GetRoot()
# Crée de nouveaux nodes dans l'éditeur python et ouvre les ports nécessaires
Hierarchie_node = master.CreateNode(root, c4d.ID_OPERATOR_HIERARCHY, x=10, y=10)
Hierarchie_node[c4d.GV_HIERARCHY_START_ID] = "DL"
Hierarchie_node[c4d.GV_HIERARCHY_ITERATION_ID] = "P"
Indice_objets = master.CreateNode(master.GetRoot(),400001152,None,100,10)
ListeDeLiens_node = master.CreateNode(root, c4d.ID_OPERATOR_LINK, x=250, y=10)
Obj_Essaim = master.CreateNode(root, c4d.ID_OPERATOR_OBJECT, x=600, y=10)
Obj_Essaim.AddPort(c4d.GV_PORT_INPUT, c4d.GV_OBJECT_OPERATOR_OBJECT_IN, flag = c4d.GV_PORT_FLAG_IS_VISIBLE)
Obj_cloner = master.CreateNode(root, c4d.ID_OPERATOR_OBJECT, x=100, y=100)
Obj_cloner.AddPort(c4d.GV_PORT_OUTPUT, c4d.GV_OBJECT_OPERATOR_OBJECT_OUT, flag = c4d.GV_PORT_FLAG_IS_VISIBLE)
mo_donnee = master.CreateNode(master.GetRoot(),1019010,None,250,100)
# Get all in ports of the math node and select the first one.
mo_donnee_out = mo_donnee.GetOutPorts()
mo_donnee_out = mo_donnee_out[0] if mo_donnee_out else None
Obj_Ref_Led = master.CreateNode(root, c4d.ID_OPERATOR_OBJECT, x=600, y=100)
Obj_Ref_Led.AddPort(c4d.GV_PORT_INPUT, c4d.GV_OBJECT_OPERATOR_OBJECT_IN, flag = c4d.GV_PORT_FLAG_IS_VISIBLE)
# Lie les ports entre eux
"""
# Get all out ports of the constant node and select the first one.
const_node_out = const_node.GetOutPorts()
const_node_out = const_node_out[0] if const_node_out else None
# Get all in ports of the math node and select the first one.
math_node_in = math_node.GetInPorts()
math_node_in = math_node_in[0] if math_node_in else None
# Connect the constant node to the math node.
if const_node_out and math_node_in:
const_node_out.Connect(math_node_in)
"""
# Add our object to the scene graph and let Cinema update.
doc.InsertObject(null)
c4d.EventAdd()
"""liaison des bons objets aux nodes créés."""
# Définition des objets
cloner = doc.SearchObject("DROTEK-NL") # Récupère l'objet selon son nom.
Rerefence_LED = doc.SearchMaterial("REF_DROTEK-NL_LED") # Récupère le matériaux selon son nom.
Obj_cloner[c4d.GV_OBJECT_OBJECT_ID] = cloner # Lie le cloner "DROTEK-NL au Node "cloner" crée précédement.
Obj_Ref_Led[c4d.GV_OBJECT_OBJECT_ID] = Rerefence_LED
if __name__=='__main__':
main()
Can you help me on that point ?
Thank you