Sweep Nurbs Question



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

    On 14/09/2011 at 19:42, xxxxxxxx wrote:

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

    ---------
    Hey Everyone,

    I have a sweep Nurbs under which place a cubic spline and a circle spline.  Then, I make the sweep nurbs editable via SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd);

    The result is that the main object has two children object which are the caps that were created.  What I woiuld like to do then , is connect the caps to the main body and then optimize that to connect the caps to the main body.  This is of course all via code and not manually.

    Could someone explain to me how I would do this?

    I understand how to run optimize via SendModelingCOmmand..   and I have found that the Connect + Delete command can be called via CallCommand(16768);  But I can't seem to make it work..  When I add the call command, c4d crashes.

    Here is the code I am trying to use.  :)

      
      
    //CONVERT TO POLYGON OBJECT  
      //==========================================================//  
      ModelingCommandData mcd;  
      mcd.op = objsweep;  
      
    #ifdef C4D_R12  
      mcd.mode = MODELINGCOMMANDMODE_ALL;  
    #else  
      mcd.mode = MODIFY_ALL;  
    #endif  
      
      mcd.doc = doc;  
      SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd);  
      BaseObject *res = static_cast<BaseObject*>(mcd.result->GetIndex(0));  
      
      PolygonObject *polyObj = (PolygonObject * )res;  
      if(!polyObj) return NULL;  
      //==========================================================//  
      
      CallCommand(16768);  //Connect and Delete  
      
      // MESH OPTIMIZE  
      //==========================================================//  
      ModelingCommandData mcd3;  
      BaseContainer bc3;  
      bc3.SetReal(MDATA_OPTIMIZE_TOLERANCE, 0.01);  
      bc3.SetReal(MDATA_OPTIMIZE_POINTS, TRUE);  
      bc3.SetReal(MDATA_OPTIMIZE_POLYGONS, TRUE);  
      bc3.SetReal(MDATA_OPTIMIZE_UNUSEDPOINTS, TRUE);  
      mcd3.bc = &bc3;  
      
      mcd3.op = polyObj;  
      
    #ifdef C4D_R12  
      mcd3.mode = MODELINGCOMMANDMODE_ALL;  
    #else  
      mcd3.mode = MODIFY_ALL;  
    #endif  
      
      mcd3.doc = doc;  
        
      if(SendModelingCommand(MCOMMAND_OPTIMIZE, mcd3)){}  
      
      polyObj->Message(MSG_UPDATE);  
      //==========================================================//  
      
    

    Any help you could offer would be great.  :)



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

    On 15/09/2011 at 01:28, xxxxxxxx wrote:

    From where do you call this, from GetVirtualObjects?

    cheers,
    Matthias



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

    On 15/09/2011 at 03:29, xxxxxxxx wrote:

    Woops,  sorry!  Yes, it is called from GetVirtualObjects()



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

    On 15/09/2011 at 06:47, xxxxxxxx wrote:

    I've just been through this very same thing so I feel your pain. I don't think you can use CallCommand from GVO. What I did was take the object returned from the CurrentStateToObject and did another SendModelingCommand on it using MCOMMAND_JOIN. Since that also returns a new object you can delete the object returned from the first SendModelingCommand call ('res' in your case) and return the connected one. Or do an optimize on it then return it (I didn't need the optimized version).

    Seems to work for me, anyway.



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

    On 15/09/2011 at 08:45, xxxxxxxx wrote:

    CallCommand within GetVirtualObjects is fatal and forbidden. As suggested use SendModelingCommand to join and optimize objects.

    cheers,
    Matthias



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

    On 15/09/2011 at 08:49, xxxxxxxx wrote:

    Just to add, always keep in mind that GetVirtualObjects sole purpose is to return an object or a group of objects. Every change to the document or the interface is strictly forbidden. If you think about it that it runs in a multithreaded context it makes sense.

    cheers,
    Matthias



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

    On 15/09/2011 at 09:15, xxxxxxxx wrote:

    Thanks guys.  I will do that. 
     
    @Matthias.  Thanks for the Info.  That makes perfect sense.  GVO and I have had a love hate relationship for a while now.  HAHA  I am always trying to push her beyond her limits..  LOL
     
    Thanks again!
     
    ~Shawn



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

    On 16/09/2011 at 08:30, xxxxxxxx wrote:

    Howdy,

    Remember, that to get around some of the limitations due to thread safety, you can sometimes use a separate document, held in memory only, to do your building. I don't know what the efficiency of that method is, though. It's probably dependent on how many calls or calculations are needed to perform the task.

    Adios,
    Cactus Dan


Log in to reply