Solved Unable to Add Objects for User Data with In/Exclusion Data Type

Hi,

Hi I'm trying to Add Objects for User Data with In/Exclusion Data Type but it doesn't seem to work.
It doesn't also error out. It's the same code I used for the In/Exclusion Data Type for the Selection Object, which works.

You can see the illustration here for Selection Object which works:
https://www.dropbox.com/s/e0zi466697btn8r/c4d213_unable_to_add_object_to_user_data_inexclusion_list01.mp4?dl=0

You can see the illustration here for User Data which doesn't work:
https://www.dropbox.com/s/2kur2ndwjcdq35k/c4d213_unable_to_add_object_to_user_data_inexclusion_list02.mp4?dl=0

Here is the code so far:

import c4d
from c4d import gui

def main():

    tag = op.GetTag(1022749)
    bc = c4d.GetCustomDataTypeDefault(c4d.CUSTOMDATATYPE_INEXCLUDE_LIST)
    bc[c4d.DESC_NAME] = 'obj_list'
    bc.SetLong(c4d.IN_EXCLUDE_FLAG_NUM_FLAGS, 1)
    bc.SetLong(c4d.IN_EXCLUDE_FLAG_INIT_STATE, 1)
    bc.SetLong(c4d.IN_EXCLUDE_FLAG_IMAGE_01_ON, 1018640)
    bc.SetLong(c4d.IN_EXCLUDE_FLAG_IMAGE_01_OFF, 1018641)

    desc_ID = tag.AddUserData(bc)  # Add userdata container

    obj_list_content = c4d.InExcludeData()

    obj_list_content.InsertObject(doc.SearchObject('Sphere'), 1)
    obj_list_content.InsertObject(doc.SearchObject('Cube'), 1)


    obj_list = tag[c4d.ID_USERDATA,desc_ID[1].id]

    obj_list = obj_list_content

# Execute main()
if __name__=='__main__':
    main()

Hello,
you are assigning a copy of your in/exclude list to obj_list and override the copy only.

# you are assigning a copy of your in/exclude list to obj_list.
    obj_list = tag[c4d.ID_USERDATA,desc_ID[1].id]
# you override the copy
    obj_list = obj_list_content

you can instead override the userdata itself. And if you look, that's what you are doing in the first example.


    tag[c4d.ID_USERDATA,desc_ID[1].id] = obj_list_content
    
    c4d.EventAdd()

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

Thanks for the explanation. Works as expected.