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:
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.
Here's the Python code I am using:
def main() :
ActObj = doc.GetActiveObject()
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
xtag = c4d.BaseTag(c4d.Texpresso)
if ActObj is not None: #check if there is no object
tag = op.GetFirstTag() # returns the first tag of the object
nodemaster = tag.GetNodeMaster()
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)
On 19/09/2010 at 12:10, xxxxxxxx wrote:
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) )
On 19/09/2010 at 13:31, xxxxxxxx wrote:
Not sure what it all means but it's working fine now.
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?