Selecting an Ngon

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

On 17/11/2006 at 13:21, xxxxxxxx wrote:

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

---------
Hi,
Just a simple question, how do I select an ngon?
I imagined it would be this

    
    
    
    
    LONG ngon_index=0; // the first ngon
    
    
    
    
    LONG polycount = op->GetPolygonCount();
    
    
    
    
    BaseSelect *select = op->GetPolygonS();
    
    
    
    
    select->Select(ngon_index+polycount);
    
    
    
    
    [CODE]
    
    
    
    
    but this doesnt seem to select anything in C4D
    
    
    
    
     
    
    
    
    
    Thanks

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

On 21/11/2006 at 18:52, xxxxxxxx wrote:

To see the code's effect in workspace ...
I use

EventAdd(EVENT_FORCEREDRAW);

Best regards ...
Zaw Min Tun

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

On 22/11/2006 at 06:30, xxxxxxxx wrote:

Here is a code sample for a command plugin that selects all ngons:

  
Bool MenuTest::Execute(BaseDocument *doc)  
{  
     BaseObject *op = doc->GetActiveObject();  
     if(!op) return TRUE;  
     if (op->GetType()==Opolygon)  
     {  
          PolygonObject *polyobj = ToPoly(op);  
          BaseSelect *sel = polyobj->GetPolygonS();  
  
          LONG ngoncount, *polymap = NULL;  
          LONG **ngons = NULL;  
          if(!polyobj->GetPolygonTranslationMap(ngoncount, polymap))  
          {  
               GeFree(polymap);  
               return FALSE;  
          }  
  
          if(!polyobj->GetNGonTranslationMap(ngoncount, polymap, ngons))  
          {  
               GeFree(polymap);  
               GeFree(ngons);  
               return FALSE;  
          }  
  
          LONG ngoncnt = polyobj->GetNgonCount();  
          LONG x;  
          for(x=0; x<ngoncnt; i++)  
          {  
               LONG y;  
               for(y=1; j<=ngons[x][0]; j++)  
               {  
                    GePrint(LongToString(ngons[x][y]));  
                    sel->Select(ngons[x][y]);  
               }  
          }  
          EventAdd();  
  
          GeFree(ngons);  
          GeFree(polymap);  
  
     }  
  
     return TRUE;  
}  
[CODE]  
  
Basically you select the polygons within the ngons. You can get the polygon indices through GetPolygonTranslationMap and GetNgonTranslationMap.  
  
hope this helps  
  
cheers,  
Matthias  

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

On 22/11/2006 at 11:58, xxxxxxxx wrote:

Thank you Matthias,
A couple of typos 😉 but it works great