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
    • Recent
    • Tags
    • Users
    • Login

    Problem with CurrentStateToObject

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 412 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 03/09/2011 at 08:42, xxxxxxxx wrote:

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

      ---------
      I have a generator plugin. In GetVirtualObjects I want to do a CurrentStateToObject on a sweep nurbs, because I need a polygon object to work with. Here's the code I'm using:

        
      BaseObject *res = NULL, *newop = NULL;   
      ModelingCommandData cd;   
      BaseContainer bcmcd;   
      AutoAlloc<BaseDocument>tdoc;                                               // temporary document   
      newop = static_cast<BaseObject*>(lnk->GetClone(COPYFLAGS_0, NULL));        // 'lnk' is a sweep nurbs object   
      tdoc->InsertObject(newop, NULL, NULL, FALSE);   
      cd.doc = tdoc;   
      cd.op = newop;   
      cd.mode = MODELINGCOMMANDMODE_ALL;   
      bcmcd.SetBool(MDATA_CURRENTSTATETOOBJECT_INHERITANCE, TRUE);   
      bcmcd.SetBool(MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION, TRUE);   
      cd.bc = &bcmcd;   
      if(!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, cd))   
          return NULL;   
      res = static_cast<BaseObject*>(cd.result->GetIndex(0));   
      

      This all works fine, as long as the sweep nurbs has a contour spline and a path spline in the usual way. However, if I put a Mograph tracer object in as the path spline, generating splines using a particle emitter, it fails. Instead of returning a polygon object, for some reason CSTO returns a null object with just the contour spline in it. That's even though there's a perfectly good object in the viewport, and if I do a CSTO on it manually using the Objects menu in the OM, it returns the polygon object I would expect.

      I'm obviously doing something wrong but I can't see what. Can anyone see why this isn't working? I've tried doing a CSTO on the tracer object first then inserting it back into the temporary document, but all I get is a crash.

      Would really appreciate some help with this one.

      Thanks,

      Steve

      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 06/09/2011 at 01:51, xxxxxxxx wrote:

        Sorry to bump this but does no-one have any thoughts on how to do this? I've tried every combination of cloning the object, cloning the document, all the options in SendModelingCommand, still nothing. All I get returned is a null.

        Thanks,

        Steve

        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 06/09/2011 at 09:21, xxxxxxxx wrote:

          Well, I finally solved this one. For anyone else ever trying to do the same thing, the solution is very simple. Instead of creating a new document, just clone the original object (the sweep nurbs in this case), DON'T insert it into any document, then do the CSTO on the clone. You can then use the returned object to access its points/polygon data.

          Since you haven't changed anything in the original document, this is legal and all you need to do is delete the clone as well as the object returned from the SendModelingCommand call before exiting.

          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 07/09/2011 at 00:52, xxxxxxxx wrote:

            Thanks for posting your solution!

            Best regards
            /Filip

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