.NET
cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

How to find the remaining vertices on a polyline?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
zhengyunyang2019
283 Views, 3 Replies

How to find the remaining vertices on a polyline?

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.

zhengyunyang2019_0-1698905880387.png

 

3 REPLIES 3
Message 2 of 4
_gile
in reply to: zhengyunyang2019

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;
            }
        }


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 4
zhengyunyang2019
in reply to: _gile

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?

Message 4 of 4
_gile
in reply to: zhengyunyang2019


@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.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report