On 12/03/2013 at 16:46, xxxxxxxx wrote:
Here's some utility functions and examples how I deal with an In/Ex list in an ObjectData plugin and button presses and UI updates. These are methods in that ObjectData derived class (i.e., my plug-in). Some is pseudo so don't literally try and use this. More to see how another person approaches it.
#-----------------------------------------------------------------
def __init__(self, node, op) :
node.InitAttr(op, c4d.InExcludeData, [c4d.YOUR_INEX_HERE])
#-----------------------------------------------------------------
CALLED WHENEVER A BUTTON IS PRESSED
def HandleButton(self, id, op) :
"""Make an if statement to do something depending on DescID"""
#SAMPLE: if id['id'][0].id == 2008: self.__dropdowngrey = False
#if id['id'][0].id == c4d.NAMELISTBUTTON: self.__NAMEPRINTFUNCTION(op)
#-----------------------------------------------------------------
CALLED WHENEVER AN ATTRIBUTE CHANGES
def UpdateChange(self, op) :
"""Any time a user changes an attribute this gets called"""
print 'someone changed a user doodad'
#-----------------------------------------------------------------
RECEIVE MESSAGES FROM C4D
def Message(self, op, type, data) :
#Check for button press to call HandleButton function
if type == c4d.MSG_DESCRIPTION_COMMAND: self.HandleButton(data, op)
#Check for any attribute changes to call UpdateChange function
if type == c4d.MSG_DESCRIPTION_CHECKUPDATE: self.UpdateChange(op)
return True
#-------------------
def \__NAMEPRINTFUNCTION(self, op) :
list = op[c4d.YOUR_INEX_HERE]
for i in xrange(list.GetObjectCount()) :
#get the object, then get the name and print it