Solved n-gones with python

I found that the c ++ sdk had a routine for creating n-gones, but I did not find anything in python. By importing a wavefront that contains n-gones with my plugin, the import is not done properly. Is there a python solution or should I convert my plugin to c ++?

hi @passion3d,
There is no actual n-gon in the underlying layer of Cinema 4D.
Adjacent polygons use hidden edge to create n-gon-like shape(s).

Following code creates a 5-side polygon object:

import c4d, math
from c4d import utils
#Welcome to the world of Python

def main():
    pointCount = 5
    polygonCount = math.ceil(pointCount/4.0)                    # caculate minimum needed polygon number
    polyObj = c4d.BaseObject(c4d.Opolygon)                      # create an empty polygon object

    polyObj.ResizeObject(pcnt=pointCount, vcnt=polygonCount)    # resize object to have 5 points, 2 polygons

    # manually set all point position
    polyObj.SetPoint(id=0, pos=c4d.Vector(200,0,-200))
    polyObj.SetPoint(id=1, pos=c4d.Vector(-200,0,-200))
    polyObj.SetPoint(id=2, pos=c4d.Vector(-200,0,200))
    polyObj.SetPoint(id=3, pos=c4d.Vector(200,0,200))
    polyObj.SetPoint(id=4, pos=c4d.Vector(300,0,0))

    # associate points into polygons
    polygon0 = c4d.CPolygon(t_a=0, t_b=1, t_c=2, t_d=3)
    polygon1 = c4d.CPolygon(t_a=0, t_b=3, t_c=4)

    # set polygon in polygon object
    polyObj.SetPolygon(id=0, polygon=polygon0)
    polyObj.SetPolygon(id=1, polygon=polygon1)

    # set hidden edge
    nbr = utils.Neighbor()
    nbr.Init(op=polyObj, bs=None)                               # create Neighor counting all polygon in
    edge = c4d.BaseSelect()
    edge.Select(num=3)                                          # set selection, which is the id of the edge to be hidden
    polyObj.SetSelectedEdges(e=nbr, pSel=edge, ltype=c4d.EDGESELECTIONTYPE_HIDDEN)  # hide the edge




if __name__=='__main__':

Hi @eZioPan
thank you for this example very clear ;)