Accessing various scene objects and tag objects
-
On 17/05/2013 at 18:39, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform:
Language(s) :---------
Hi, I am up and running writing C++ tag plugins and Visual Studio 2010 and the debugger and C4D cooperate nicely. What I am really struggling with, is how to access certain elements.Bool CopyRig::GetDEnabling(GeListNode* node, const DescID& id, const GeData& t_data, DESCFLAGS_ENABLE flags, const BaseContainer* itemdesc)
{
This works:
if (id[0].id == MYTAGPLUGIN_LINK_SOURCE)
bla bla
}
Here I have a LINK field, where I pick an object.
How do I determine if an object has been picked at all, and then how do I access that object?
I have written Python plugins, and had no real problems with this. But the code is obviously not transferable so I must start all over again.Another thing. The Joint object seems to be hard to find.. I have linked in #include "lib_ca.h" and various other files. When using GetTypeName() it returns, yes, "Joint". But not matter what I do to try to declare a Joint variable, VS says there is an unknown identifier.
Yes, I have a loooong way to go it seems. I wish there were a document somewhere describing just how to access a tag's various properties (especially linked objects).
The next thing I want to do is to clone objects and move them and make them children of other objects. Lots of new stuff to learn..-Ingvar
-
On 17/05/2013 at 19:09, xxxxxxxx wrote:
BaseTag* tag = static_cast<BaseTag*>(node); BaseDocument* doc = tag->GetDocument(); if (!doc) return FALSE; // Get tag container BaseContainer* bc = tag->GetDataInstance(); if (!bc) return FALSE; // Get Object Link BaseObject* op = bc->GetObjectLink(MYTAGPLUGIN_LINK_SOURCE, doc); if (!op) return FALSE;
-
On 17/05/2013 at 19:53, xxxxxxxx wrote:
Great, this works!
Now, I want to get further.
The linked object is a Joint (a bone).
So I tried this:CAJointObject* jntA = static_cast<CAJointObject*>(bc->GetObjectLink(MYTAGPLUGIN_LINK_SOURCE, doc));
Problem is, the jntA object is not NULL, even if I link a cube
And Joints (bones) in C4D have lots of properties I want to access. Code completion (Intellisense) does not show much of them, but this:
jntX->GetBone(...);
might work. Who knows.
Ok, I can now get the Baseobject part of the linked object and use its properties and methods.
What remains, is to test wheter a Joint really is linked in or not, and then access the properties of the Joint (its "bone").-Ingvar
-
On 17/05/2013 at 20:29, xxxxxxxx wrote:
You can restrict what the Link box can receive in either the Resource file (.res) or in the code.
For the .res, you do something like this:
LINK MYTAGPLUGIN_LINK_SOURCE { ACCEPT { /*Ojoint's ID number as in your previous post'*/; }; }
In the code, you do it this way:
// NodeData.Message //*---------------------------------------------------------------------------* Bool MyPlugin::Message(GeListNode* node, LONG type, void* data) //*---------------------------------------------------------------------------* { if (!node) return FALSE; // Something is hovering over one of your plugin's Description elements if (type == MSG_DESCRIPTION_CHECKDRAGANDDROP) { MsgCheckDragAndDrop(static_cast<DescriptionCheckDragAndDrop*>(data), static_cast<BaseTag*>(node)); return TRUE; } return SUPER::Message(node,type,data); } // MsgCheckDragAndDrop - Message MSG_DESCRIPTION_CHECKDRAGANDDROP //*---------------------------------------------------------------------------* void MyPlugin::MsgCheckDragAndDrop(DescriptionCheckDragAndDrop* dcdd, BaseTag* tag) //*---------------------------------------------------------------------------* { // Accept/Decline if (!dcdd) return; if (!tag) return; // Object LinkBox if (dcdd->id[0].id == MYTAGPLUGIN_LINK_SOURCE) { BaseObject* element = static_cast<BaseObject*>(dcdd->element); if (!element) return; // Validate the drop before allowing the item to reside in the LinkBox! dcdd->result conveys that validation dcdd->result = (element->IsInstanceOf(Ojoint)); } }
If the .res restriction isn't disallowing everything but Ojoint, I would recommend the 'in the code' method for robustness.
For clarity, this particular message is sent while the user has dragged something over the Attributes Manager with your plugin being displayed within it and before the user can drop it over the description element.