Xpresso Node Port ID's

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/09/2011 at 13:28, xxxxxxxx wrote:

I was hoping someone could point me to a list of all of the Xpresso Node Port ID's.

I am currently writing a script that creates an Xpresso tag on a cube, and then creates a node, of the cube, on the Xpresso graph view.  I would like to access the Object Properties > Size.Y port.  I can not figure out what the ID for that port.  I have tried guessing "c4d.ID_BASEOBJECT_OBJECTPROPERTIES_SIZE_Y", but that does not seem to work.

Any ideas?

Thanks

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 08/09/2011 at 15:12, xxxxxxxx wrote:

I think you'll have to use DescID for this.
The kind of code only a mother (or a C++ user) could love.

#This example creates an xpresso node with positionX & scaleY output ports  
#Make sure you have an xpresso tag selected before executing it   
  
import c4d  
  
def main() :  
  
  #Get the node master of selected xpresso tag...Make sure you have the xpresso tag selected first!  
  nm = doc.GetActiveTag().GetNodeMaster()   
  
                                              
  #Create the object's xpresso node  
  node = nm.CreateNode(nm.GetRoot(), c4d.ID_OPERATOR_OBJECT,insert=None, x=200, y=200)  
  
  
  #Using DescID... Combine the POSITION option, with the VECTOR option. And then assign them to a variable("posX")  
  #Using DescID... Combine the SCALE option, with the VECTOR option. And then assign them to a variable("scaleY")  
  posX = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_ABS_POSITION), c4d.DescLevel(c4d.VECTOR_X));  
  scaleY = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_ABS_SCALE), c4d.DescLevel(c4d.VECTOR_Y));  
  
  
  #Add the position.x output port to the object node using the stuff we have in memory  
  #Add the scale.y output port to the object node using the stuff we have in memory  
  node.AddPort(c4d.GV_PORT_OUTPUT, posX)  
  node.AddPort(c4d.GV_PORT_OUTPUT, scaleY)  
  
  
  #prints the name of the node to the console   
  print node.GetOperatorContainer()[c4d.GV_OBJECT_OBJECT_ID].GetName()  
  c4d.EventAdd()  
    
  
if __name__=='__main__':  
  main()

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 14/09/2011 at 08:27, xxxxxxxx wrote:

Thanks for the reply ScottA.  I've tried using the code you provided.

#Using DescID... Combine the POSITION option, with the VECTOR option. And then assign them to a variable("posX")  
  #Using DescID... Combine the SCALE option, with the VECTOR option. And then assign them to a variable("scaleY")  
  posX = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_ABS_POSITION), c4d.DescLevel(c4d.VECTOR_X));  
  scaleY = c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_ABS_SCALE), c4d.DescLevel(c4d.VECTOR_Y));  
  
  
  #Add the position.x output port to the object node using the stuff we have in memory  
  #Add the scale.y output port to the object node using the stuff we have in memory  
  node.AddPort(c4d.GV_PORT_OUTPUT, posX)  
  node.AddPort(c4d.GV_PORT_OUTPUT, scaleY)

It works, (it creates Transformed Position .X and Transformed Scale .Y ports) but it doesn't create the port I was hoping to gain access to (Object Properties > Size > Size.Y)  Is it just not possible to create this port automatically?

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 14/09/2011 at 10:16, xxxxxxxx wrote:

Finally figured it out.

This code:
node1out = node1.AddPort(c4d.GV_PORT_OUTPUT, (1100, 1001))

Will add Size.Y output port.

I was able to figure out the numbers by typing "print(PRIM_CUBE_LEN, VECTOR_Y)" in the console window.

However, now the xpresso node with Size.Y is yellow.

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 14/09/2011 at 10:47, xxxxxxxx wrote:

It's yellow because you are telling the node to output the size of something. But it doesn't have any inputs to look at to know what it is you want to change the size of.

It's considered better practices to use the text based ID's whenever you can:
node1out = node.AddPort(c4d.GV_PORT_OUTPUT, (PRIM_CUBE_LEN, VECTOR_Y))

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 14/09/2011 at 11:04, xxxxxxxx wrote:

Shouldn't the Size.Y be referencing the cube?

The goal of this script is to create a cube inside of a null object.  In Xpresso, I want to multiply the Size.Y of the cube by 0.5 and use the result as the Position.Y of the cube.

If I do this manually, everything works fine.

Here is my code.

import c4d

def main() :
    null = c4d.BaseObject(c4d.Onull)
    doc.InsertObject(null)

cube = c4d.BaseObject(c4d.Ocube)
    doc.InsertObject(cube,null)

xtag = c4d.BaseTag(c4d.Texpresso)
    null.InsertTag(xtag)

nodemaster = xtag.GetNodeMaster()
    print nodemaster.GetOwner().GetName()

node1 = nodemaster.CreateNode(nodemaster.GetRoot(),c4d.ID_OPERATOR_OBJECT,None,100,100)
    node1[c4d.GV_OBJECT_OBJECT_ID] = cube

node1out = node1.AddPort(c4d.GV_PORT_OUTPUT, (c4d.PRIM_CUBE_LEN, c4d.VECTOR_Y))
    print node1.GetOperatorContainer()[c4d.GV_OBJECT_OBJECT_ID].GetName()

c4d.EventAdd()

if __name__=='__main__':
    main()

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 14/09/2011 at 11:36, xxxxxxxx wrote:

Try this line of code without the extra parenthesis:

  
node1out = node1.AddPort(c4d.GV_PORT_OUTPUT, c4d.PRIM_CUBE_LEN, c4d.VECTOR_Y)

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 14/09/2011 at 11:55, xxxxxxxx wrote:

That did the trick.  Thanks for the help ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 14/09/2011 at 12:17, xxxxxxxx wrote:

Oops.
Scratch that. I just noticed that doing that removes the .Y from the node.

I'm not sure why the xpresso node isn't working properly when the Size.Y port is added.
There must be some other missing step needed to tell C4D to update the changes.
I'm afraid I'm out of ideas.

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 15/09/2011 at 12:55, xxxxxxxx wrote:

Yeah, it doesn't make sense.  When I try to do the same thing with Relative Position.Y the node works fine.

import c4d

def main() :
    null = c4d.BaseObject(c4d.Onull)
    doc.InsertObject(null)

cube = c4d.BaseObject(c4d.Ocube)
    doc.InsertObject(cube,null)

xtag = c4d.BaseTag(c4d.Texpresso)
    null.InsertTag(xtag)

nodemaster = xtag.GetNodeMaster()
    print nodemaster.GetOwner().GetName()

node1 = nodemaster.CreateNode(nodemaster.GetRoot(),c4d.ID_OPERATOR_OBJECT,None,100,100)
    node1[c4d.GV_OBJECT_OBJECT_ID] = cube

node2 = nodemaster.CreateNode(nodemaster.GetRoot(),c4d.ID_OPERATOR_OBJECT,None,300,100)
    node2[c4d.GV_OBJECT_OBJECT_ID] = cube

node1out = node1.AddPort(c4d.GV_PORT_OUTPUT, (c4d.PRIM_CUBE_LEN, c4d.VECTOR_Y))
    print node1.GetOperatorContainer()[c4d.GV_OBJECT_OBJECT_ID].GetName()

node2in = node2.AddPort(c4d.GV_PORT_INPUT, (c4d.ID_BASEOBJECT_REL_POSITION, c4d.VECTOR_Y))
    print node2.GetOperatorContainer()[c4d.GV_OBJECT_OBJECT_ID].GetName()

c4d.modules.graphview.RedrawMaster(nodemaster)

node1out.Connect(node2in)

c4d.EventAdd()

if __name__=='__main__':
    main()

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/09/2011 at 11:25, xxxxxxxx wrote:

Looks to be a bug 😕

I found that you can side step this by using a "real to vector" node.

So rather than trying to get at the sub component right away you get the entire vector package.
examples are best.

import c4d
from c4d import gui
#Welcome to the world of Python
  
  
def main() :
    xtrude = c4d.BaseObject(5116)
    xtag = c4d.BaseTag(1001149)
    
    
    doc.InsertObject(xtrude)
    xtrude.InsertTag(xtag)
    
    gv = xtag.GetNodeMaster()
    
    xtrude_node = gv.CreateNode(parent = gv.GetRoot(),id = c4d.ID_OPERATOR_OBJECT )
    xtrude_node[c4d.GV_OBJECT_OBJECT_ID] = xtrude
    mov = xtrude_node.AddPort(c4d.GV_PORT_INPUT, [c4d.EXTRUDEOBJECT_MOVE])#(c4d.EXTRUDEOBJECT_MOVE,c4d.VECTOR_Y)) ####report_bug
    
    r2v = gv.CreateNode(parent = gv.GetRoot(),id = c4d.ID_OPERATOR_REAL2VECT )
    r2v_x_in = r2v[c4d.GV_REAL2VECT_INPUT_X]
    r2v_out = r2v.GetOutPorts()[0]
  
    r2v_out.Connect(mov)
    c4d.EventAdd()
  
if __name__=='__main__':
    main()