On 17/05/2016 at 11:00, xxxxxxxx wrote:
Hi,
GOAL:
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__':
main()