Solved Select the object on which the plugin Tag is associated

Hi there,

My learning curve is improving, but I'm still a newbie here...
I wrote my first plugin, but I noticed that when you click on the TAG associated to an object, that does not select the object itself.

Is there a way to have the object selected when the user select its associated Tag plugin?

I had a look on several function like doc.SearchObject() or doc.SetActiveObject() but I'm not sure what the best practices are to do so.

Does this call must be place into the Message() when a flag is raised or should it be placed into the Execute() (from what I understood, I think that is not the right place)?

If someone have some advices or tips about this it would be more than welcome.

Hello,

Thanks for the advices @ferdinand, I think I'm gonna change some parts of my code to avoid this and keep the C4D conventions; I think that I can find a workaround on this.

Cheers,
Christophe

From a user perspective: Please, please, please do not do this. You are breaking the established GUI interactions that are needed for other functionalities. If you select the tag's object when the tag is selected, you can no longer select and delete or move the tag individually. It's a huge no-no. Don't.

Hello @mocoloco,

thank you for reaching out to us. This is technically possible, but we would advise against doping it as it would break with interface conventions of Cinema 4D as pointed out by @Cairyn. While the user could still move the tag individually in such setup, he/she could no longer delete your tag without deleting the object it is attached to.

Nonetheless: To get the object associated with a tag, you can either call BaseTag.GetObject() or the more general purpose BaseList2D.GetMain(). Cinema 4D's scene graph is split into many smaller isolated graphs, e.g., the tag relations are not part of the object relations. GetMain() is the connection handle for (most of) these subgraph connections. So, a tag will return its object with GetMain(), an object its BaseDocument (which is also a GeListNode\BaseList2D, i.e., node, in Cinema) and so on.

Cheers,
Ferdinand

MAXON SDK Specialist
developers.maxon.net

Hello,

Thanks for the advices @ferdinand, I think I'm gonna change some parts of my code to avoid this and keep the C4D conventions; I think that I can find a workaround on this.

Cheers,
Christophe

I changed my code to use BaseDocument.SearchObject(self, name) and it is working perfectly without compromising anything.

Thanks again,
Cheers,

Christophe