Remove empty polygons


I imported a 3D file with a lot of empty polygons.
How can I possibly delete them all at ones?


this should do it (does not delete object, if children present, though):

import c4d
from c4d import documents as docs

class ObjIter:

    def __init__(self, obj):
        self.obj = obj
        self.currObj = obj
        self.objStack = []

    def __iter__(self):
        return self

    def __next__(self):

        if not self.currObj:
            raise StopIteration

        obj = self.currObj

        if self.currObj.GetDown():
            self.currObj = self.currObj.GetDown()
            self.currObj = self.currObj.GetNext()
            while not self.currObj and len(self.objStack) > 0:
                self.currObj = self.objStack.pop()

        return obj

def main():
    doc = docs.GetActiveDocument()
    obj = doc.GetFirstObject()
    scene = ObjIter(obj)

    for obj in scene:
        if isinstance(obj, c4d.PolygonObject) and obj.GetPointCount() == 0 and not obj.GetDown():

if __name__ == '__main__':


Thanks for your help.
But unfortunately it doesn’t work.


i am assuming you’re on a c4d-release >= 23 then (i believe the python-version change came with r23)?
i 've edited the code above, try again, see if it works.


Exact I am on R26.
Used the script and deleted 400+ empty polygons.
This made my day.

Thanks a lot Mesutcakin.