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

    Change variables when closing tag

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 237 Views
    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 Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 16/04/2008 at 10:01, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   10.5 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Here's another problem: I have to set some data in the object's containers when the tag is closed. Right now this is done by the following source code:

      > <code>
      > void MoCap::SetBackIDs (){
      >
      >      BaseDocument *doc = GetActiveDocument();
      >      GePrint ("doc");
      >      BaseTag *tag = doc->GetActiveTag();
      >      GePrint ("tag");
      >      BaseObject *op = doc->GetFirstObject();
      >      GePrint ("op");
      >      BaseObject *current;
      >      GePrint ("current");
      >      BaseContainer *opContainer = op->GetDataInstance();
      >      GePrint ("opContainer");
      >      
      >      while (op!= NULL){
      >           GePrint ("while");
      >      opContainer = op->GetDataInstance();
      >      opContainer->SetBool (DESC_USED, FALSE);
      >      opContainer->SetLong (DESC_JOINT_ID, 0);
      >      current = op->GetDown();
      >      if (current == NULL)
      >           current = op->GetNext();
      >      if (current == NULL)
      >           current = op->GetUp()->GetNext();
      >      op = current;
      >      }
      >
      > }
      > </code>

      while the method SetBackIDs is called within the destructor of my Plugin:

      > <code>
      > ~MoCap(void) {SetBackIDs();}
      > </code>

      I'm sure that this is not very clever. It works, but when finishing Cinema the destructor is called again and only finds the document. When searching for the active tag or the first object, Cinema crashes. How do I solve this one?

      Thx

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 16/04/2008 at 10:32, xxxxxxxx wrote:

        1. Call SetBackIDs() in the tag's Free() method. Technically, one should never use a class's destructor to do 'work' - only to release memory owned by the class.

        2. Verify pointers in SetBackIDs() and Cinema 4D won't crash. ETA: For instance, you don't check 'op' until after calling op->GetDataInstance() - do it before this.

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 18/04/2008 at 05:47, xxxxxxxx wrote:

          Hi, thx. The Free()method seems indeed the better way.

          Still there is the problem of crashing. How do I exactly verify the pointers? Something like
               if (!doc->GetFirstObject())return;
          doesn't seem to work.

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