StartPoint od polyline

StartPoint od polyline

Anonymous
Not applicable
2,593 Views
14 Replies
Message 1 of 15

StartPoint od polyline

Anonymous
Not applicable

Is possible to change the startpoint of a polyline?

eg:

Polyline lwp = obj as Polyline;

int vn = lwp.NumberOfVertices;
for (int i = 0; i < vn; i++)
{
    SegmentType sg = lwp.GetSegmentType(i);

 }

...

lwp.StartPoint = lwp.GetArcSegmentAt(1).StartPoint;

0 Likes
Accepted solutions (1)
2,594 Views
14 Replies
Replies (14)
Message 2 of 15

Anonymous
Not applicable

You can modify the first vertex just as you would any vertex.

0 Likes
Message 3 of 15

Anonymous
Not applicable

Please, could you give me an example?

0 Likes
Message 4 of 15

Anonymous
Not applicable

You call the PolyLine's SetPointAt() method and pass it the index of

the vertex and the new coordinate.

0 Likes
Message 5 of 15

Anonymous
Not applicable

I tried without success:

Point3d nextpoint = lwp.GetArcSegmentAt(1).StartPoint;
lwp.SetPointAt(0, new Point2d(nextpoint.X, nextpoint.Y));

 

because the polyline change shape.

0 Likes
Message 6 of 15

Anonymous
Not applicable

You're trying to set the start point to the second vertex.

 

You'll have to explain in more detail what you're trying to do.

0 Likes
Message 7 of 15

Anonymous
Not applicable

I've a closed polyline composed by some Arc and Line as in 1.dwg

This polyline has a startpoint at 41.4033981995461,46.6236763815663 (startpoint of the first segment) that I need to change in 43.8777100135197,46.8401506153171 (startpoint of the second segment) before cicllyng with:

int vn = lwp.NumberOfVertices;
for (int i = 0; i < vn; i++)
{
SegmentType sg = lwp.GetSegmentType(i);
...

}

 

0 Likes
Message 8 of 15

Anonymous
Not applicable

Isn't it obvious that if you want to change the start point of the first

segment to be the start point of the second segment, what you

actually are doing is deleting the first segment/vertex?

0 Likes
Message 9 of 15

Anonymous
Not applicable

I only want to change the first segment of the polyline.

0 Likes
Message 10 of 15

Anonymous
Not applicable

Sorry, I really can't figure out what it is you're trying to do.

 

Perhaps posting a file with the 'before' and 'after' might help.

0 Likes
Message 11 of 15

Anonymous
Not applicable

As attached files before.dwg and after.dwg the first segment of the polyline is different.

My question is: how can I do this programmatically in autocad .net?

0 Likes
Message 12 of 15

Anonymous
Not applicable
Accepted solution

The only difference I see is that the first vertex is offset by one

vertex in one of the two polylines.

 

To do this via the API, you either delete the last vertex and

insert it at the start, or delete the first vertex and insert it

at the end.

 

0 Likes
Message 13 of 15

Anonymous
Not applicable

I don't understand, because I think the last vertex is also the first.

Please, could you explain it with code?

0 Likes
Message 14 of 15

Anonymous
Not applicable

No, the last vertex is not the first vertex. If a polylline is closed, it

merely means that there is a segment connecting the first and last

vertices. Perhaps you are confusing vertices with the segments

that connect them.

 

Sorry, I don't have time to write the code for you.

 

 

0 Likes
Message 15 of 15

Anonymous
Not applicable

Ok, now I understand:

 

int vn = lwp.NumberOfVertices;

lwp.RemoveVertexAt(0);
lwp.AddVertexAt(vn - 1, new Point2d(X, Y), 0, 0, 0);

 

where Point2d(X, Y) is the StartPoint of the Segment at index = 1

 

Many thanks

0 Likes