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

StartPoint od polyline

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
flovo
1042 Views, 14 Replies

StartPoint od polyline

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;

14 REPLIES 14
Message 2 of 15
caddzone
in reply to: flovo

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



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 3 of 15
flovo
in reply to: flovo

Please, could you give me an example?

Message 4 of 15
caddzone
in reply to: flovo

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

the vertex and the new coordinate.



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 5 of 15
flovo
in reply to: flovo

I tried without success:

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

 

because the polyline change shape.

Message 6 of 15
caddzone
in reply to: flovo

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.



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 7 of 15
flovo
in reply to: flovo

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);
...

}

 

Message 8 of 15
caddzone
in reply to: flovo

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?



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 9 of 15
flovo
in reply to: flovo

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

Message 10 of 15
caddzone
in reply to: flovo

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.



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 11 of 15
flovo
in reply to: flovo

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?

Message 12 of 15
caddzone
in reply to: flovo

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.

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 13 of 15
flovo
in reply to: flovo

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

Please, could you explain it with code?

Message 14 of 15
caddzone
in reply to: flovo

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.

 

 



AcadXTabs for AutoCAD
Supporting AutoCAD 2000-2011


Message 15 of 15
flovo
in reply to: flovo

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

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost