Forum Replies Created

  • ton vogels

    June 27, 2022 at 7:46 pm in reply to: How to remove empty polygons

    Following Script from a guy at Cgsociety did the work for me.

    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.objStack.append(self.currObj.GetNext())
    self.currObj = self.currObj.GetDown()
    else:
    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():
    obj.Remove()
    c4d.EventAdd()

    if __name__ == ‘__main__’:
    main()

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy