For example, if a polyline has two vertices, and I have applied fillet to one of the vertices, then there is one vertex remaining.
I would like to find this remaining vertex through code.
In fact, there might be multiple filleted vertices and multiple remaining vertices, and I want to locate all the remaining vertices.
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Solved by zhengyunyang2019. Go to Solution.
Solved by _gile. Go to Solution.
Hi,
You can check if the bulges of two successive segments is equal to 0.0.
private static IEnumerable<int> GetNonFilletedVerticeIndices(Polyline pline)
{
int n;
if (pline.Closed)
{
n = pline.NumberOfVertices;
if (pline.GetBulgeAt(0) == 0.0
&& pline.GetBulgeAt(n - 1) == 0.0)
{
yield return 0;
}
}
else
{
n = pline.NumberOfVertices - 1;
}
for (int i = 1; i < n; i++)
{
if (pline.GetBulgeAt(i - 1) == 0.0
&& pline.GetBulgeAt(i) == 0.0)
yield return i;
}
}
for (int i = 1; i < polyline.NumberOfVertices - 1; i++)
{
SegmentType line1 = polyline.GetSegmentType(i - 1);
SegmentType line2 = polyline.GetSegmentType(i);
if (line1 == SegmentType.Line && line2 == SegmentType.Line)
{
Point3d p = polyline.GetPoint3dAt(i);
ed.WriteMessage("\nThe {0} is a need point", i);
}
}
Thank you very much for your help.
Earlier, I considered a solution myself, which involves determining whether each point is a bend point by checking if the adjacent line segments are straight.
Do you think my approach is feasible?
@zhengyunyang2019 wrote:Earlier, I considered a solution myself, which involves determining whether each point is a bend point by checking if the adjacent line segments are straight.
Do you think my approach is feasible?
Yes it is (simply try it), but your example does not handle closed polylines first vertex.
Can't find what you're looking for? Ask the community or share your knowledge.