Own defined userdata ID

On 15/06/2013 at 01:55, xxxxxxxx wrote:

Hi everybody,

I have just a quick question:
Is it possible via python script, or directly in C4D, to create a user data with an own defined ID?
Normally C4D automatically gives the ID's, but I whant to choose the ID myself!
So how can I achieve this? python? coffee? c4d itself?

Thank you once for the effort!


PS.: Sorry for my bad english, I am still lerarning this language^^

On 15/06/2013 at 12:06, xxxxxxxx wrote:


thanks for the fast answer, but I already found this page. And with this documentation it is only possible to create new userdata with their type, name and container. But the ID will still be set automaticly!
But I for example whant to create a userdata with the type "text" and the name "insert your name" with the ID 51.

So how can I set an ID by myself?


On 15/06/2013 at 23:41, xxxxxxxx wrote:

Only 2 methods below, there's one called SetUserDataContainer().


On 16/06/2013 at 01:21, xxxxxxxx wrote:


at first I whantet to thank you for your post and your reply.
but I see that my language is tied really too short!

so now here a little more detail for my problem:
I found this function

Originally posted by xxxxxxxx

called SetUserDataContainer().

two days ago in the python sdk, downloadable at the maxon website.

Because I am new to python, I tried this little skript:

bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_LONG)
  bc[c4d.DESC_NAME] = "Test"
  newId = c4d.DescID(c4d.DescLevel(100, c4d.DTYPE_SUBCONTAINER, 0),c4d.DescLevel(0))
  print newId
  print type(newId)
  obj.SetUserDataContainer(newId, bc)

But I can't figure out, what my mistake is!
the documentary is very short and so I can't read something about it! I am really sorry for stealing your time with this "simple problem" like it is one for you, I guess!


On 16/06/2013 at 01:43, xxxxxxxx wrote:

import c4d
MY_ID =  42
def main() :
    if op:
        bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_LONG)
        bc[c4d.DESC_NAME] = "Test"
        # also correct but unnecessarily complicated
        did = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA), c4d.DescLevel(MY_ID))
        # better - easier to read, also note that user data are a special case 
        # of description ids which consist of more than one id, for normal
        # description ids you can pass the integer directly.
        did = [c4d.ID_USERDATA, MY_ID]
        op.SetUserDataContainer(did, bc)
if __name__=='__main__':

On 16/06/2013 at 03:55, xxxxxxxx wrote:

.. so why didn't you tell us earlier that you did already have a try? And what is your actual problem? I'm not at home, so
without a description of why the code you have shown does not work, I can only guess or not give you a direct answer.

On 16/06/2013 at 13:44, xxxxxxxx wrote:


Originally posted by xxxxxxxx

.. so why didn't you tell us earlier that you did already have a try? And what is your actual problem?

yea, you are right about that. And I am really sorry about my inefficient question. I was very stressed the last few days and was not capable of finding the time for a good
problem description.

But I really thank you guys for helping me. Now it is working really fine and I had also the time to read throw the documentation. And with the code, littledevil posted, it was really easy to understand how the container works.

Only one last thing is not clear to me, also after the things I learned!
Creating a container for one userdata is clear to me now.
Also how to create a userdata group:

bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_GROUP)

but how can I now put some userdata into this gorup, and some not?
I can only put all in that one group, or none.
But sometimes I have 3 different groups and maybe one of them also has a sub group.

So would you be so nice and post a little "mini" skript in order to show me how to do that with an example?
That would be really nice of you!


PS.: Sorry again for last time and thanks again!

On 16/06/2013 at 14:38, xxxxxxxx wrote:

ah, never mind, I searched in the posts of "littledevil" and found an old one where he listed all functions with there meaning.
So I hope, I can solve the problem myself. I am not quite sure, but I will try my best 😉
thank you again for all your help and maybe 'til the future^^