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

    SelectionChanger problems

    Scheduled Pinned Locked Moved SDK Help
    2 Posts 0 Posters 220 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 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

      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 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

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