DoCommand() not working

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

On 16/06/2012 at 13:38, xxxxxxxx wrote:

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

---------
I'm having problems with the DoCommand() method in my tool plugin.
All I want to do is use the SendModelingCommand to delete the selected polygon in my tool.

I select the polygon in my MouseInput() method.
Then I call to the DoCommand() to execute it and delete the polygon. But it doesn't do anything.

The MouseInput code :

    BaseContainer state;  
  while (GetInputState(BFM_INPUT_MOUSE, BFM_INPUT_MOUSELEFT, state)) //While the LMB is down   
  {  
    if (state.GetLong(BFM_INPUT_VALUE) == 0) break; //If the state value is 0. The LMB is no longer down..so don't enter the loop   
    
    LONG x = state.GetLong(BFM_INPUT_X); //Get the cursor's X screen coordinates  
    LONG y = state.GetLong(BFM_INPUT_Y); //Get the cursor's Y screen coordinates  
  
    GeShowMouse(MOUSE_POINT_HAND);       //Change the cursor's apperance when the mouse button is down  
    
    //Check if there is a valid poly id, otherwise deselect all polygons  
    if(polygonid>-1)   
    {  
        bs->Select(polygonid);           //Select the polygon that's currently highlighted  
  
        ModelingCommandData mdat;  
        BaseContainer bc;  
        mdat.bc = &bc;  
        DoCommand(mdat);                //Call to the DoCommand and execute it  
    }  
    else bs->DeselectAll();  
  }

The DoCommand code :

Bool PolygonTool::DoCommand(ModelingCommandData &mdat)  
{  
  BaseObject *op = mdat.doc->GetActiveObject();  
  PolygonObject *objPoly=(PolygonObject* )op;  
  
  mdat.mode = MODELINGCOMMANDMODE_POLYGONSELECTION; //Use this for dealing with polygon selections  
  mdat.flags = MODELINGCOMMANDFLAGS_CREATEUNDO;  
  GePrint("Am I working?");                                                        //This prints fine  
  if (!SendModelingCommand(MCOMMAND_DELETE, mdat)) return FALSE;  
  GePrint("Am I still working?");                                                 //<-----------Does not print!!  
  
  EventAdd();//Update all the changes   
  
  return TRUE;  
}

Notice that after the SendModelingCommand() code. Something bad happens and the last print does not work. I don't know if that has anything to do with the problem or not.

What am I doing wrong?

-ScottA

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

On 17/06/2012 at 08:51, xxxxxxxx wrote:

You've not set the mdat.doc and mdat.op (at least not with what you have shown for the code).

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

On 17/06/2012 at 11:48, xxxxxxxx wrote:

Thanks Robert.
That got it working.

-ScottA