Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    GetDocument() returning null [SOLVED]

    SDK Help
    0
    4
    343
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 09/11/2014 at 06:09, xxxxxxxx wrote:

        Howdy,

        Is the "this" pointer pointing to the correct object?

        Adios,
        Cactus Dan

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post