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

    Delete polygon based on area?

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 313 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

      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 🙂

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          Hello utisz,

          was your question answered?

          Best wishes,
          Sebastian

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