Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search

Py4d: Xpresso Node User Data Output Port

Author
Message
  Topic Search Topic Search
ernia View Drop Down
Member
Member


Joined: 2010 Sep 18
Location: USA
Online Status: Offline
Posts: 6
Direct Link To This Post Topic: Py4d: Xpresso Node User Data Output Port
    Posted: 2010 Sep 18 at 7:06am

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()


Edited by ernia - 2010 Sep 18 at 8:33am
A right-brainer needs to code like a fish needs a bicycle.
Back to Top
s_rath View Drop Down
Member
Member


Joined: 2010 May 04
Location: Ne / Düsseldorf
Online Status: Offline
Posts: 319
Direct Link To This Post Posted: 2010 Sep 19 at 12:10pm
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


Edited by s_rath - 2010 Sep 19 at 12:14pm
Back to Top
ernia View Drop Down
Member
Member


Joined: 2010 Sep 18
Location: USA
Online Status: Offline
Posts: 6
Direct Link To This Post Posted: 2010 Sep 19 at 1:31pm
Thanks Sebastian.
Not sure what it all means but it's working fine now.

Arik
A right-brainer needs to code like a fish needs a bicycle.
Back to Top
sergey kritskiy View Drop Down
Member
Member


Joined: 2011 Nov 26
Online Status: Offline
Posts: 16
Direct Link To This Post Posted: 2013 Mar 28 at 7:54am
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?
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.