SelectionChanger problems



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

    On 25/04/2012 at 11:37, xxxxxxxx wrote:

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

    ---------
    I normally convert between edges, polygons, and points using the SMC version of the convert tool.
    I just found this SelectionChanger helper class in the SDK. But I can't seem to make it work.
    It doesn't do anything when I run it:

        BaseObject *obj = doc->GetActiveObject();  
     if(!obj)return FALSE;  
      
     PolygonObject *pobj = ToPoly(obj);  
     BaseSelect *sel = pobj->GetPointS();  
      
     SelectionChanger *sc = SelectionChanger::Alloc();  
     sc->InitFromSelection(sel, Mpoints, pobj);  
     sc->GetEdgeS();                                //<--Does not select any edges from my selected points!?  
      
     pobj->Message(MSG_UPDATE);  
     EventAdd();
    

    What am I doing wrong?

    -ScottA



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

    On 25/04/2012 at 16:15, xxxxxxxx wrote:

    Never mind. I think I've got it figured out.
    Apparently this class "returns" the points, edges, and polygons. But it doesn't actually "select" them.

    Here's an example of using this class to select edges based on the selected points. Just in case anyone else needs it:

    #include "..\..\..\..\resource\_api\c4d_libs\lib_selectionchanger.h"  
      
      
      BaseObject *obj = doc->GetActiveObject();  
      if(!obj)return FALSE;  
      
      PolygonObject *pobj = ToPoly(obj);             //Cast the active object to a polygon object type  
      BaseSelect *sel = pobj->GetPointS();           //Get the currently selected points of the object  
      BaseSelect *esel = pobj->GetEdgeS();           //Get the currently selected edges(this will probably be zero)  
      
      SelectionChanger *sc = SelectionChanger::Alloc(); //Create an instance of the SelectionChanger class  
      sc->InitFromSelection(sel, Mpoints, pobj);        //Initialize it with the selected points and the object  
      
      BaseSelect *newsel = sc->GetEdgeS();           //Store the selected edges (based on selected points) in a BaseSelect  
      
      CallCommand(16351);                            //Switch to Edges mode  
      newsel->CopyTo(esel);                          //Make the edges selected on the object in the scene  
      pobj->Message(MSG_UPDATE);                     //Update the changes  
      
      SelectionChanger::Free(sc);                    //Free the memory used in Alloc
    

    -ScottA


Log in to reply