this is what I would like to achieve:
- copy userdata (only one vector element) from object 'b' to object 'a'
- remove all userdata elements from object 'a'
- copy userdata (only one float element) from object 'c' to object 'a'
This is what works so far:
Removing all userdata from object 'a':
for id, bc in aObj.GetUserDataContainer(): aObj.RemoveUserData(id)
Copy userdata from object 'b' to 'a'
for id, bc in bObj.GetUserDataContainer(): aObj.SetUserDataContainer(id,bc)
But here comes the problem: after I copied one userdata element (type: vector) from object 'b' to object 'a', I can't then just remove all userdata from object 'a' and then copy another userdata element (type: float) from object 'c' to (the apparently not entirely cleaned) object 'a'. It seems to me that even after the remove function the previous userdata type is still cached. As a result to this, I get this error when I try to enter any vector data to this userdata element:
TypeError: __setitem__ expected c4d.Vector, not float
When I remove all userdata manually from object 'a' using the GUI it works, but using code like "RemoveUserData" seems to be not the same. In other words: how can I replace a userdata element from type A by another element from type B using python ?
I attached a file for testing:
3 null objects:
object 'b' has float userdata element
object 'c' has vector userdata element
object 'a' is the target object
Select the python script tag and select the userdata tab. You can run these 3 functions:
- remove all
- b to a (float)
- c to a (vector)
- run function "b to a (float)"
-> float userdata element will be copied to object 'a'
- run function "remove all"
-> userdata of object 'a' is gone
- run function "c to a (vector)"
-> vector userdata structure is created on object 'a' but vector data can't be set:
TypeError: __setitem__ expected float, not c4d.Vector
- check the userdata of object 'a': the gui shows the vector element but the "c to a" function can't set any vector data (?)
- remove the userdata of object 'a' manually and run function "c to a" again ... this time it works
Really strange. Do I miss any additonal (update-) commands besides "RemoveUserData" in order to really remove any userdata and set new userdata types ?