There is a third-party module to serialize and deserialize the user data of any BaseList2D
object in python dict format. Here's an example:
c4d.ID_USERDATA: {
(c4d.ID_USERDATA, 1): {
c4d.DTYPE_: c4d.DTYPE_REAL,
c4d.DESC_NAME: 'Data',
c4d.DESC_SHORT_NAME: 'Data',
c4d.DESC_MIN: 0,
c4d.DESC_MAX: 1,
c4d.DESC_STEP: 0.01,
c4d.DESC_UNIT: c4d.DESC_UNIT_PERCENT,
c4d.DESC_CUSTOMGUI: c4d.CUSTOMGUI_REAL,
c4d.DESC_PARENTGROUP: (700, 5, 0),
},
(c4d.ID_USERDATA, 2): {
c4d.DTYPE_: c4d.DTYPE_GROUP,
c4d.DESC_NAME: 'Group',
c4d.DESC_SHORT_NAME: 'Group',
c4d.DESC_ANIMATE: c4d.DESC_ANIMATE_OFF,
c4d.DESC_COLUMNS: 1,
c4d.DESC_TITLEBAR: 1,
c4d.DESC_DEFAULT: 1,
c4d.DESC_PARENTGROUP: (),
},
(c4d.ID_USERDATA, 3): {
c4d.DTYPE_: c4d.DTYPE_LONG,
c4d.DESC_NAME: 'Data',
c4d.DESC_SHORT_NAME: 'Data',
c4d.DESC_UNIT: c4d.DESC_UNIT_INT,
c4d.DESC_CUSTOMGUI: c4d.CUSTOMGUI_LONGSLIDER,
c4d.DESC_MIN: 0,
c4d.DESC_MAX: 100,
c4d.DESC_STEP: 1,
c4d.DESC_PARENTGROUP: ((700, 5, 0), (2, 1, 0)),
},
}
The module is not fully tested, but it's enough for me for my daily scripting work. The processing of parameters is implemented in a way described by @ferdinand . Sort of like the .res
file used by plugins developing, the json data defines the details of a parameter. If you feel like it, you can implement it yourself by refering to following functions:
DumpParams
DumpParamDetails
DumpUserDataDetails
LoadUserData
...
Considering sometimes there's a huge amount of parameters, I spent a lot of time to judge and handle dirty parameters, namely the parameter has been changed, there is still no perfect way. If you don't care whether the parameter is dirty, problem goes easier. Maybe do some filters by restricting DescLevel.creator
to a specific value etc.