Py4d: Xpresso Node User Data Output Port

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

On 18/09/2010 at 07:06, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   12.021 
Platform:      Mac OSX  ; 
Language(s) :       PYTHON  ;

---------
My first post here ;)

Problem: when I use Python to set up a userdata output port on an xpresso node on the active object, it turns yellow and won't work, yet when I drag the same object into the xpresso tag setup and set the output port to the userdata it looks and works as expected. Seems to be just the userdata output port that is the problem, as other output ports work fine when set using Python.

I suspect that I am not making an internal connection somewhere--or that it possibly is broken.

Any ideas?

Here's the Python code I am using:

import c4d

def main() :
    ActObj = doc.GetActiveObject()

Make the user data boole button on active object

bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_BOOL) #create default container
    bc[c4d.DESC_NAME] = "Pucker"                        #rename the entry

Pucker = ActObj.AddUserData(bc)           #add userdata  and set to container
    ActObj[Pucker] = False                          #assign a value

#c4d.EventAdd()                                   #update

Create the xPresso tag on the active object

xtag = c4d.BaseTag(c4d.Texpresso)
    if ActObj is not None: #check if there is no object
        ActObj.InsertTag(xtag)

tag = op.GetFirstTag() # returns the first tag of the object
    nodemaster = tag.GetNodeMaster()

Generate node with port

nodeObjOut = nodemaster.CreateNode(nodemaster.GetRoot(), c4d.ID_OPERATOR_OBJECT, insert=None, x=250, y=200)

nodeObjOut.AddPort(c4d.GV_PORT_OUTPUT, [c4d.ID_USERDATA, 1])

nodemaster.Message(c4d.MSG_UPDATE) #send update to nodemaster
    c4d.EventAdd() #set an event to c4d core to update (never use in an expression)

main()

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

On 19/09/2010 at 12:10, xxxxxxxx wrote:

Hi ernia,

for user data you need to specify some additional IDs. I also recommend to inform the node about the new port by setting "message=True".

USERDATA_NUMERO = 1 #change this
nodeObjOut.AddPort(c4d.GV_PORT_OUTPUT, c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER, 0), c4d.DescLevel(USERDATA_NUMERO)), message=True)

For custom datatypes like gradient, splinedata, ... you should define their type as well ( c4d.DescLevel(USERDATA_NUMERO, c4d.DTYPE_GRADIENT, 0) )

Cheers, Sebastian

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

On 19/09/2010 at 13:31, xxxxxxxx wrote:

Thanks Sebastian.
Not sure what it all means but it's working fine now.

Arik

On 28/03/2013 at 07:54, xxxxxxxx wrote:

Wow, I've been looking for AddPort for Userdata for ages!

Sebastian, is it documented somewhere? Is there a way I could get there by myself?