Linking python tag userdata to null (ie compositing tag)
Hi, I'm transferring an expresso setup I have into a python tag object. I have my python tag attached to a null in the scene and I'd like to be able to see the userdata of the python tag attached to the null like I can if I add a Compositing tag. I tried this code below but that only copies the userdata instead of linking it. Any ideas would be super helpful!
import c4d from c4d import gui def main(): target = op[c4d.ID_USERDATA,5] #The null I want to transfer the userdata to obj = op #The userdata I want to transfer for id, bc in obj.GetUserDataContainer(): target.SetUserDataContainer(id, bc) block = op [c4d.ID_USERDATA,4] color = op [c4d.ID_USERDATA,2] block[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector(color)
A compositing tag is a hierarchical tag so its parameter group (and user data) is attached to the object it's applied to.
The Python tag isn't a hierarchical tag so it's not possible to have the same behavior.
Note a hierarchical tag doesn't set any kind of link mechanism with the object it's attached to. Its parameters are just shown in the attribute manager with the associated object and it still owns its user data.
Thanks y_puech, so is there no way to give a python tag the same functionality that comes when you add a plugin tag to an object? That seems to share userdata with the object it's attached to.
indexofrefraction last edited by indexofrefraction
hm... to me it is not clear what you want to do..
" I'd like to be able to see the userdata of the python tag attached to the null like I can if I add a Compositing tag "
the script runs in the tag, so op is the tag. to get the tagged object you use obj = op.GetObject()
so if you have a py tag with userdata you normally do something like
obj = op.GetObject()
obj[someId] = op[c4d.ID_USERDATA,someId]
or if you have the userdata in the object you can do
obj = op.GetObject()
print obj[c4d.ID_USERDATA,someId] # do smth with userdata
Yeah I have control of all my userdata and objects already. Maybe this linked file will help? Both objects have the same userdata on the attached tag but the plugin version attaches it's userdata to the parent object like the phong tag does.
The Test tag plugin is missing in the linked c4d file but I see the behavior with another tag plugin (Py-LookAtCamera SDK example).
I was wrong in my previous post. This behavior of the Attribute Manager is applied to tags that can be added only once to an object. This can't be done for tags that can be added multiple times.
Unfortunately the Python tag is registered with
TAG_MULTIPLEflag so it can be added multiple times to an object but the parameter tab isn't attached to its parent object.