UNSOLVED CUSTOMGUI_CYCLE: SetContainer: TypeError: an integer is required (got type set)

Hi, everyone,

I can't get to make .SetContainer work.

I'm doing this through a python tag, file attached.

I looked everywhere, and I've seen the code on a few websites, I don't understand why it's not working.
Is there a change I've missed?
My goal is to make the element selected so that I can use this component to make a sort of quick selector between objects.

import c4d
from c4d import gui
from c4d import documents

def MkUD(Object):
    children = Object.GetChildren()
    count = len(children)
    bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG)
    bc.SetString(c4d.DESC_NAME, 'Objects')
    cycle = c4d.BaseContainer()
    cycle.SetString(0, 'si')
    cycle.SetString(1, 'sai')
    print (cycle)
    bc.SetContainer(c4d.DESC_CYCLE, cycle) # I can see the UD when I comment this line
    Object.SetUserDataContainer([c4d.ID_USERDATA, 1], bc) # but nothing inside...

def main():
    obj = doc.SearchObject("Null")

I get:

<c4d.BaseContainer object at 0x000001DF3FF609C0>
Traceback (most recent call last):
  File "Python", line 20, in main
  File "Python", line 15, in MkUD
TypeError: an integer is required (got type set)

I'm on R25
Thanks for your help, so frustrating.

Hello @renobozo,

thank you for reaching out to us and welcome to the Plugin Café. We cannot reproduce your problem here on our machines. Your error indicates that c4d.DESC_CYCLE is not an integer on your machine as it should be, but a set. Could you print out the value of c4d.DESC_CYCLE? You might have accidently overwritten the value, but should have been fiexed by a restart.


The result:
The script:

"""Simple example that does create cycle user data parameters in the selected

The cycle values are populated with the names of the children of the selected 
object. To be run as a script manger script. Requires an object to be selected
which should have some children.

import c4d

def CreateUserData(node: c4d.BaseList2D):
    """Creates a user data parameter in #node.
    param = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG)
    param.SetString(c4d.DESC_NAME, 'Objects')
    param.SetInt32(c4d.DESC_CUSTOMGUI, c4d.CUSTOMGUI_CYCLE)
    cycle = c4d.BaseContainer()
    # I assume you wanted to populate the cycle with the children.
    for i, child in enumerate(node.GetChildren()):
        cycle.SetString(i, child.GetName())
    param.SetContainer(c4d.DESC_CYCLE, cycle)

    # You have to pass either a collection type or DescId for the parameter id here.
    if not node.SetUserDataContainer((c4d.ID_USERDATA, 1), param):
        raise RuntimeError("Could not set user data parameter.")
    did = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(2))
    if not node.SetUserDataContainer(did, param):
        raise RuntimeError("Could not set user data parameter.")

def main():
    """Entry point.
    if op is None:
        raise RuntimeError("Please select an object.")

if __name__ == '__main__':