GetDocument() returning null [SOLVED]
-
On 09/11/2014 at 05:53, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;---------
Hi Folks,
I've got the following code in an ObjectData plugin's function that runs on the click of a command, to open a dialog window:BaseObject *obj = (BaseObject* )this; BaseDocument *doc = (BaseDocument* )obj->GetDocument(); if(doc == NULL) { GePrint("Object is passing a NULL doc.."); return FALSE; } dlg.SetDocument(doc); // custom dialog function return dlg.Open(...);
The object is in the scene, it's in the AM, I can go through it's tabs etc. But the document is always returning null. What am I missing here?
WP. -
On 09/11/2014 at 06:09, xxxxxxxx wrote:
Howdy,
Is the "this" pointer pointing to the correct object?
Adios,
Cactus Dan -
On 09/11/2014 at 07:28, xxxxxxxx wrote:
My guess is that 'this' is in fact a pointer to an ObjectData. You can't cast that to a BaseObject. Use NodeData::Get() to get the node, then use the node's GetDocument() function to get the document.
Steve
-
On 09/11/2014 at 23:19, xxxxxxxx wrote:
Thanks Dan/Steve,
'this' was indeed a reference to an ObjectData. I've replaced that with the NodeData pointer and it's now working a treat!
Cheers,
WP.