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

    GetSelectionTag From Object

    Scheduled Pinned Locked Moved SDK Help
    6 Posts 0 Posters 511 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 14/01/2012 at 01:13, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   12 
      Platform:      
      Language(s) :

      ---------
      Hi,
      I'm Trying to get the selected Polygons of an object which where save into a polygon selection tag. 
      My Plugin is a ObjectData Plugin and I've not found a  way to get the Polygon selection. 
      I've searched in this forum and found some stuff but it's not helping since i can't access the function GetPolygonSelection() and neither GetSelection. 
      Is there a workaround?

      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 14/01/2012 at 01:25, xxxxxxxx wrote:

        It's easy enough:

        1. get your selection tag and make sure you check that it's a polygon selection, e.g.:
          
        SelectionTag *st;   
        // first get the tag from the object   
        // ...   
        // check it's a poly selection:   
        if(st->GetType() & Tpolygonselection)   
        
        1. now you can get the BaseSelect from the tag:
          
        BaseSelect *bs = st->GetBaseSelect();   
        
        1. do what you want with the selected polygons. See the function IsSelected() in the SDK for a quick way of iterating through the selected polygons.

        Steve

        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 16/02/2012 at 10:03, xxxxxxxx wrote:

          It still wont work

          SelectionTag st = SelectionTag.Alloc(C4dApi.Tpolygonselection);
                              BaseSelect bs = st.GetBaseSelect();
          bs.Select(3);/tried 0 1 2 3
          

          I also set the cube as active object before the posted code.
          but as you can see the polygonselection isnt active its not selected.
          If it worked the top polygon should be selected.

          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 16/02/2012 at 11:48, xxxxxxxx wrote:

            If the end result you're trying to achieve is to execute the selections that are saved in your selection tags. Then you can do this with the DescriptionCommands(Those buttons in the tag's AM).

            #include "../../resource/res/description/Tpolygonselection.h"  
              
              BaseDocument *doc = GetActiveDocument();  
              BaseObject *obj = doc->GetActiveObject();   //Start out using BaseObject to grab the polygon object  
              if(!obj) return FALSE;                      //Error Handling  
              PolygonObject *pobj = ToPoly(obj);          //Cast the BaseObject type to a PolygonObject type and assign it to a variable "pobj"  
              if(!pobj) return FALSE;                     //Error Handling  
              
              for(BaseTag* polyTag = pobj->GetFirstTag(); polyTag; polyTag = polyTag->GetNext()) //Search for a PolygonSelection type tag  
                {  
                 if(!polyTag->IsInstanceOf(Tpolygonselection)) continue;  
                 polyTag->SetBit(BIT_ACTIVE);                  //optional... if you want the tag to be selected or not      
                 DescriptionCommand dc;                         //Create an empty DescriptionCommand variable to hold the command we'll use next  
                 dc.id = DescID(POLYGONSELECTIONTAG_COMMAND1);  //Assigns the POLYGONSELECTIONTAG_COMMAND1 to the dc variable  
                 polyTag->Message(MSG_DESCRIPTION_COMMAND,&dc); //Execute the command  
                }
            

            The Tpolygonselection.h file shows the other buttons you can execute with code the same way.

            -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 16/02/2012 at 14:45, xxxxxxxx wrote:

              I'm trying to achieve to create for each selected point a weight with the function SetWeight.
              So I figured the best way to do that would be a For loop. Where i check if the point is selected or not. If it is selected I set the weight else I do nothing.
              And it seems like this only work if the point are selected in the viewport. Of course i could be wrong.

               SelectionTag st = SelectionTag.Alloc(C4dApi.Tpointselection);
                                  BaseSelect bs = st.GetBaseSelect();
                                  
                                  PointObject pObj = PointObject.GetPointObject(op2);
               C4dApi.GePrint("test"+bs.Select(0));
                                  bs.Select(0);
                                  BaseSelect SelectedPoints = pObj.GetPointS();
               for (int i = 0; i < pObj.GetPointCount(); i++)
                                  {
                                      if (SelectedPoints.IsSelected(i))
                                      {
                                          this.wtagGlob.SetWeight(1,i,0.04);
                                          C4dApi.GePrint("Der Punkt mit dem Index " + i + " ist selektiert");
                                      }
                                  }
              

              thats my idea

              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 17/02/2012 at 01:41, xxxxxxxx wrote:

                I don't understand why you're allocating a new tag. The tag you need is already on the object, unless I've misunderstood you completely. What you need to do is get a pointer to the tag from the object and get that tag's BaseSelect.

                What you're actually doing is allocating a new tag and getting its BaseSelect which, not surprisingly, is empty.

                Also, the selection you get from GetPointS() is not the same as the selection in a selection tag. You can have a stored selection in the tag but quite different points currently selected in the model. That's why in your code nothing happens unless you have points selected in the viewport.

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