Remove points from a polygon
-
I have created a function that adds points to a polygon.
But how to remove a point from a polygon, as well as remove the faces that contain it ? -
Hey @kantronin,
Thank you for reaching out to us. I would recommend having a look at the Modeling Python Examples. They are a bit hidden, but in the Geometry section I went over the general classic API geometry model of Cinema 4D.
Regarding your core questions:
- Removing points from a polygon: Without wanting to be overly pedantic, I must point out that polygons only index vertices, they do not hold them;
CPolygonreferences with its fieldsa,b,c, anddthe vertices of thePolygonObjectit is attached to. In this sense removing points from a polygon is not possible, you can just de-index them. Cinema 4D expresses both triangles and quadrangles with the typeCPolygon, i.e., as quadrangles. A triangle simply repeats itscindex in itsdindex. I explained this in the modelling examples in more detail. - Removing vertices or polygons from a
PolygonObject: There is neither aPolygonObject.RemovePolygonnor aPointObject.RemovePointif that is what you are looking for. When you want to change the vertex or polygon count of aPolygonObject, you must callPolygonObject.ResizeObjectand then callPointObject.SetAllPoints()and for each (new) polygonPolygonObject.SetPolygon. The operation_extrude_polygons_s26 example covers this subject, although I go there into the opposite direction, I increase the point and polygon count rather than decreasing it.
PS: Useful might also be geometry_polygonobject_s26 because I explained there the type from scratch.
Cheers,
Ferdinand - Removing points from a polygon: Without wanting to be overly pedantic, I must point out that polygons only index vertices, they do not hold them;