Delete polygon based on area?



  • On 21/07/2015 at 03:28, xxxxxxxx wrote:

    I'm trying to make a script that will delete polygons based on their surface area (polygons below a certain area treshold will be deleted). Is this possible?
    My first step was deleting a polygon from a polygonal object but I'm not able to delete the polygons --- Remove() does not work with CPolygon it seems.

    Pretty new to python programming in c4d so I need some hand :)



  • On 22/07/2015 at 01:59, xxxxxxxx wrote:

    Hello,

    for modeling operations you could use SendModelingCommand(). In this case you could use MCOMMAND_DELETE to delete the selected polygons of a polygon object. So in a first step you have to find out what polygons you want to delete. Then you would have to set that selection by accessing the BaseSelect object with GetPolygonS(). In this example "op" is the current object and must be a polygon object:

      
    selection = op.GetPolygonS()  
      
    # clear existing selection  
    selection.DeselectAll()  
      
    # define a new selection  
    selection.Select(0)      
      
    mode = c4d.MODELINGCOMMANDMODE_POLYGONSELECTION     
    c4d.utils.SendModelingCommand(c4d.MCOMMAND_DELETE, list = [op], doc = doc, mode = mode)  
      
    c4d.EventAdd()  
    

    Another way would be to handle the polygon data inside the polygon object itself. The Remove() function only exist for objects based on GeListNode and is used to remove an object from a linked list. The polygon data returned by GetAllPolygons() is just a python list with CPolygon objects. So if you want to handle the polygon object yourself would have to store the current polygons, then resize the polygon object with ResizeObject() and rebuild the polygon data by adding just the desired polygons.

    Best wishes,
    Sebastian



  • On 31/07/2015 at 10:32, xxxxxxxx wrote:

    Hello utisz,

    was your question answered?

    Best wishes,
    Sebastian


Log in to reply