UNSOLVED How to Set UserData Group fold/unfold

Hi,
in c4d manager UserData dialog can set group Default Open,but i dont how to set fold/unfold in python .
my code:

bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_GROUP)
bc[c4d.DESC_NAME] = "group_test"
group_did = obj.AddUserData(bc)

bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_STRING)
bc[c4d.DESC_NAME] = "test"
bc[c4d.DESC_PARENTGROUP] = group_did
did = obj.AddUserData(bc)

Thanks for any help!

Hi @chuanzhen, while there is DESC_GUIOPEN this one is more to be used with CustomGUI like Color that can be extended, in your case you want to use DESC_DEFAULT, so this give us:

import c4d

def main() -> None:
    obj = op
    bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_GROUP)
    bc[c4d.DESC_NAME] = "group_test1"
    bc[c4d.DESC_SHORT_NAME] = "group_test1"
    bc[c4d.DESC_DEFAULT] = True
    bc[c4d.DESC_TITLEBAR] = True
    group_did = obj.AddUserData(bc)
    
    bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_STRING)
    bc[c4d.DESC_NAME] = "test"
    bc[c4d.DESC_PARENTGROUP] = group_did
    did = obj.AddUserData(bc)
    
    c4d.EventAdd()

if __name__ == '__main__':
    main()

Cheers,
Maxime.

@m_adam Setup succeeded, but the group GUI did not unfold

use python
group.gif

c4d Use Default Open ,group unfold
group1.gif

c4d not Use Default Open ,but group not fold
group2.gif

Can you try using bc.SetInt32(c4d.DESC_DEFAULT, True) instead.

Cheers,
Maxime.

@m_adam Still can't succeed
In the same Attribute Manager window, for multiple objects with the same UserData, it seems that it is impossible to control the opening or closing of a group alone. If I open (or close) the group of one object, the group corresponding to other objects will also be opened (or closed)

Sadly we are not able to reproduce your issue, 3 dev tested and we all not able to reproduce.
SO being not reproducible on our end, it's pretty hard to find a solution.
Would it be possible for you to re-install Cinema 4D in a new empty directory, and try to reproduce your issue and report here every steps if you still can reproduce your issue with this fresh install.

Regarding your last message, right for multiple object this is not possible to Open/Close only for a subset of the initial selection.

Cheers,
Maxime.

Maybe the misunderstanding here comes from the normal behavior of the Attribute Manager.
One can not force a group open with this flag. The flag does only influence the open state, when the group for a given entity type (be it an object, tag or material of a certain type) gets shown first. As soon as the user touches the group (either opening or closing it), the Attribute Manager will use user's choice instead for all entities of this type.

Thanks for help @a_block , @m_adam . I think the answer to this question is that we can't control the open/close of the group