Hey @datamilch,
Thank you for reaching out to us. Your question is a bit ambiguous, as you talk about wanting to 'delete vertices of quad-polys and want them to turn into tri-polys' but show us an image series which just deletes two quads. You do not need any commands (CallCommand
, SendModelingCOmmand
) for that, as the core of the operation is quite simple. When you have a quad Q {a, b, c, d}
, then removing the point n
in it just means leaving it out and repeating the last point.
So, to construct a tri with b
being removed would be a, c, d, d
, and constructing a tri for d
being removed would be a, b, c, c
. It is important to keep the order of vertices, as the winding direction of a polygon determines its normal. So, a, c, d, d
and d, c, a, a
occupy the same space but have reversed normals. Only a, c, d, d
has the same winding order and normal as its origin quad a, b, c, d
. So, it would be something like this:
quad: c4d.CPolygon # A polygon
i: int # A vertex index
# Construct a triangle with the point with the index #i being removed from #quad.
if not quad.IsTriangle() and quad.b == i:
tri: c4d.CPolygon = c4d.CPolygon(quad.a, quad.c, quad.d, quad.d)
This all might sound a bit complicated but is not that hard to do. What is a bit trickier is to detect the point to remove. Here your question is also a bit ambiguous as you do not specify if the points which should be removed are provided by the user or should be detected. If not, you would to test:
- For each polygon
P
in a mesh M
:
- Test if it is triangle, and if so continue.
- For each point
q
in the polygon P
:
- Test if both edges
e1
and e2
connected to q
have only one polygon (i.e., Q
) attached to them.
- If so, you found a point of a quad that is at the border of the mesh. There are of course literal corner cases where this little test might not produce an output humans consider sensible: Imagine a singular perfect right-angled quad as the input mesh. This algorithm would turn it into a triangle. Intended? Catching these special cases can get much more involved.
For 1.2.1
you can use Neighbor.GetEdgePolys. You should start with writing the script yourself, we will help you then along the way when you struggle, but we cannot write things from start to finish for you.
Cheers,
Ferdinand