Add User Data from Multiple Objects to a Null

  • On 17/05/2016 at 11:00, xxxxxxxx wrote:


    Ultimately I want to create an object plugin called "Rig."
    - You place multiple objects that have User Data as children of the Rig object.
    - The rig object copies the User Data of each child and then adds them to itself.
    - It then creates an Xpresso tag and connects it's User Data to the childrens user data
    - If a child is removed or deleted, the rig updates itself.

    So if I have a two objects with user data and I put them under the "Rig" object, that rig Object will have the user data of the two objects and it can control them.

    Current Code
    I have a scene with a null named "Null" and two objects with User Data on them.  When I run this the User Data from obj get overwritten by obj2.  How can I add the obj2 user data and not overwrite the obj user data on the Null object?

    import c4d
    from c4d import gui
    #Welcome to the world of Python

    def main() :
        target = doc.SearchObject("Null")
        #print target
        obj = doc.SearchObject("Red-EpicDragonBody")
        #print obj
        obj2 = doc.SearchObject("WoodenCamera-Baseplate19mmRedSet")

    for id, bc in obj.GetUserDataContainer() :
           target.SetUserDataContainer(id, bc)
           print id

    for id, bc in obj2.GetUserDataContainer() :
            target.SetUserDataContainer(id, bc)
            print id

    if __name__=='__main__':

  • On 18/05/2016 at 01:35, xxxxxxxx wrote:


    the user data is overwritten because you overwrite it. The IDs of user data parameters are unique on an object but not globally. So the user data parameters of object A have the IDs 1,2,3 ...  and the user data parameters on object B also have the IDs 1, 2, 3 … .

    So if you merge them together in one container you must create a new, offset ID for the user data of the second object or use AddUserData().

    Best wishes,

  • On 27/05/2016 at 06:59, xxxxxxxx wrote:

    Hello Matt,

    was your question answered?

    Best wishes,

  • On 27/05/2016 at 17:43, xxxxxxxx wrote:

    Hey Sebastian,

    Thanks for the reply.  In theory, I understand that the ID have to be unique.  But I need to figure how to actually implement it!



Log in to reply