On 24/06/2015 at 09:14, xxxxxxxx wrote:
Well I have figured it out. Let me say I want to teach you how I figured it out..
First I created User Data via the GUI, which allows me to create In/Exclude.. Then I created a Python Tag so that I could review this information from Python's eyes:
import c4d
def main() :
myop = op.GetObject()
desc = myop.GetDescription(c4d.DESCFLAGS_DESC_0) # method of C4DAtom
for bc, paramid, groupid in desc:
name = bc[c4d.DESC_NAME] # bc = basecontainer
if name:
print "-------"
print name
print "-------"
for index, value in bc:
print "Index: %i, Value: %s" % (index,str(value))
My in/exclude looked like this
-------
Transparent Shaders
-------
Index: 21, Value: 1009290
Index: 17, Value: <c4d.BaseContainer object at 0x1302458b8>
Index: 1, Value: Transparent Shaders
Index: 2, Value: Transparency
Index: 10, Value: 1
Index: 13, Value: (3, 1, 0)
Index: 24, Value: 1
Index: 26, Value: 1
I compared the index/value pairs of the In/Exclude with the other data to extrapolate foreign value(s).. I fumbled a lot with the BaseContainer but the moneyshot was actually at Index 21.. I knew that I can print constants to see their integer form, and I somehow knew to try it with c4d.DESC_CUSTOMGUI. Then, long story short, I found the correct values to get a working In/Exclude. It could be buggy, for all I know, but it's been working flawlessly for me so far. \
ud_transparency = c4d.GetCustomDataTypeDefault(1009290)
ud_transparency[c4d.DESC_NAME] = "transparency"
ud_transparency[c4d.DESC_SHORT_NAME] = "transparency"
ud_transparency[c4d.DESC_CUSTOMGUI] = 1009290
ud_transparency_datatype = nullo.AddUserData(ud_transparency)
ud_transparency_id = cur_ud_id
cur_ud_id += 1
In the above code, "nullo" was a null object that I wanted to add the userdata to. And so that's how you do it! I hope you enjoyed it.
P.S. all of these c4d.DESC_* constants can be found in PythonSDK, search c4d.description