MCOMMAND_SPLIT,



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

    On 27/11/2009 at 14:52, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11 
    Platform:   Windows  ;   
    Language(s) :

    ---------
    I am trying to use SendModelingCommand() to call the split command in C4D.

    This is the code I am using.

      
    PolygonObject* objPoly;   
         objPoly=(PolygonObject* )obj;   
         if (!objPoly->IsInstanceOf(Opolygon))   
              return false;   
      
              LONG id = dc->id[0].id;   
      
              ModelingCommandData mdat;   
              BaseSelect *selected = objPoly->GetPolygonS();   
              if (!selected) return FALSE;   
              BaseDocument * doc=obj->GetDocument();   
              BaseSelect * backupSel=NULL;   
      
              LONG lngI=0;   
              LONG lngPolygonCount=objPoly->GetPolygonCount();   
              LONG lngSymPlane = data->GetReal(SYMMETRY_PLANE);   
              LONG lngMirroredSide = data->GetReal(MIRRORED_SIDE);   
      
              Vector * arrPoints=objPoly->GetPointW();   
              CPolygon * arrPolygons=objPoly->GetPolygonW();   
              CPolygon * hiddenPolygons=objPoly->GetPolygonW();   
                 
              mdat.mode = MODIFY_POLYGONSELECTION;   
              mdat.doc = doc;   
              mdat.bc = data;   
              mdat.op = objPoly;   
      
              backupSel =BaseSelect::Alloc();   
              if (!backupSel)return FALSE;   
      
              selected->CopyTo(backupSel);   
              blnSymmetryEnabled=FALSE;   
                 
         if (id == DELETE)   
            
         {   
      
              if (data->GetLong(SIDE_CHOOSER)==CHOOSE_A)   
              {     //Check to see which polys will be hidden   
                   selected->DeselectAll();   
                      
                   for (lngI=0;lngI<lngPolygonCount;lngI++)   
                   {     if (PolyOnEditableSide(arrPoints, arrPolygons, lngI, lngSymPlane, lngMirroredSide, lngOldPointCount, lngOldPolygonCount))   
                             selected->Select(lngI);   
                   }   
                   SendModelingCommand(MCOMMAND_DELETE, mdat);   
                   EventAdd(EVENT_FORCEREDRAW);   
                      
              }   
      
              else if (data->GetLong(SIDE_CHOOSER)==CHOOSE_B)   
              {     //Check to see which polys will be hidden   
                   selected->DeselectAll();   
                      
                   for (lngI=0;lngI<lngPolygonCount;lngI++)   
                   {     if (!PolyOnEditableSide(arrPoints, arrPolygons, lngI, lngSymPlane, lngMirroredSide, lngOldPointCount, lngOldPolygonCount))   
                             selected->Select(lngI);   
                   }   
                   SendModelingCommand(MCOMMAND_DELETE, mdat);   
                   EventAdd(EVENT_FORCEREDRAW);   
              }   
      
         }   
      
      
         if (id == SPLIT)   
         {   
      
              if (data->GetLong(SIDE_CHOOSER)==CHOOSE_A)   
              {     //Check to see which polys will be hidden   
                   selected->DeselectAll();   
                      
                   for (lngI=0;lngI<lngPolygonCount;lngI++)   
                   {     if (PolyOnEditableSide(arrPoints, arrPolygons, lngI, lngSymPlane, lngMirroredSide, lngOldPointCount, lngOldPolygonCount))   
                             selected->Select(lngI);   
                   }   
                      
                   SendModelingCommand(MCOMMAND_SPLIT, mdat);   
                   GePrint("Splitting A");   
                   EventAdd(EVENT_FORCEREDRAW);   
              }   
      
              if (data->GetLong(SIDE_CHOOSER)==CHOOSE_B)   
              {     //Check to see which polys will be hidden   
                   selected->DeselectAll();   
                      
                   for (lngI=0;lngI<lngPolygonCount;lngI++)   
                   {     if (!PolyOnEditableSide(arrPoints, arrPolygons, lngI, lngSymPlane, lngMirroredSide, lngOldPointCount, lngOldPolygonCount))   
                             selected->Select(lngI);   
                   }   
                   SendModelingCommand(MCOMMAND_SPLIT, mdat);   
                   GePrint("Splitting B");   
                   EventAdd(EVENT_FORCEREDRAW);   
              }   
      
         }   
      
              backupSel->CopyTo(selected);   
              BaseSelect::Free(backupSel);   
              blnSymmetryEnabled=TRUE;   
      
         return TRUE;   
      
    

    For some reason, the MCOMMAND_SPLIT is not doing anything. It selects all polygons on a certain side of the object and then runs the MCOMMAND_SPLIT but it's not doing anything..   Does anyone see a problem here?

    Thanks,

    ~Shawn



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

    On 28/11/2009 at 08:14, xxxxxxxx wrote:

    You need to get the new object from the AtomArray* result:

    // - Split PolygonSelection off into new Object  
    //*---------------------------------------------------------------------------*  
    BaseObject* GreeblerObj::SplitSelection(BaseObject* op, const Bool& deltags)  
    //*---------------------------------------------------------------------------*  
    {  
      // Initialize General ModelingCommandData  
      ModelingCommandData    gmcd;  
      gmcd.doc =            NULL;  
      gmcd.op =            op;  
      gmcd.bc =            NULL;  
      gmcd.mode =            MODIFY_POLYGONSELECTION;  
      gmcd.flags =        0L;  
      // Split selected polygons (tops) into new object  
      if (!(SendModelingCommand(MCOMMAND_SPLIT, gmcd) && gmcd.result))    return NULL;  
      BaseObject*    top =    static_cast<BaseObject*>(gmcd.result->GetIndex(0L));  
      AtomArray::Free(gmcd.result);  
      return top;  
    }
    

    Afterwards, you'll need to insert into the BaseDocument yourself if necessary.


Log in to reply