PDA

View Full Version : Polylines and Mathematics



Robert Platt
2007-03-18, 04:58 AM
Hi,
I think this is mainly a maths problem, but I'm posting it here because I need a VBA solution.
One property of a Polyline is .GetBulge, which is used to describe an arc segment. The online manual describes .GetBulge as being equal to: "...the tangent of 1/4 of the included angle for the arc between the selected vertex and the next vertex in the polyline's vertex list..."
I need to establish the radius and centerpoint of the arc segment from this information. I thought my trig. was reasonable, but I've tried everything I can think of and just can't see how to do it.
DXF codes are no help because they also only list the bulge factor.
It is obviously possible because if I "list" the polyline up comes all the information I need.
Any help in translating this will be very gratefully received.
Thanks.

Jeff_M
2007-03-18, 09:22 PM
Try this link (http://discussion.autodesk.com/thread.jspa?threadID=535876)
Jeff

Robert Platt
2007-03-19, 08:45 AM
Thanks Jeff - I'll have a look at that.
In the meantime I found a reference to the bulge in one a friend's AutoCAD VBA book. It helped clarify what the AutoCAD help page was saying. Between that and your link and my maths I can hopefully sort it out.
I'll post an update!
Robert

jakob_k
2007-04-04, 07:33 PM
hi,
i'll try my two cents worth; i hope i don't get change back.

As you step thru your polyline, the previous (or last) point is the start of the arc, when you get to an arc segment (check for assoc 42 as non-zero) the assoc 10 is the bulge point of the arc (a midpoint for geometric purposes) and assoc 42 is a bulge factor. The next assoc 10 is the next segment point (i.e. end of current arc). .

Now with your previous point and next point, the linear distance between them is the chord. Now get the distance from the chord’s midpoint to the bulge point; we’ll call this a sector bulge (i forget it's real name). the radius is equal to [(sector bulge)^2 + (half chord length)^2] / (2* sector bulge). The arc center is now given by a line from the bulge point in the direction of the chord midpoint a distance of your computed radius.

Autocad handles this info somewhat differently internally, but this approach will work for our purposes. That is why you may see a positive or negative bulge; autocad uses that for a right or left hand bulge rule.

If your first segment is an arc then you have no initial arc point but autocad assumes a zero degree tangent upon creation (or 270 deg perpendicular radiating from the center point). The geometric construction gets tricky, and I’d rather not type that much.

Also, this is for “lwpolylines”, not the old “polylines”.

maybe this attached image might help explain my words.

lastly, i know i used lisp references, but you get the picture.

Hope this helps,
karl

Robert Platt
2007-04-05, 12:12 PM
Hi Karl,
That's probably the most lucid description I've seen so far, and it avoids complex trig. functions (you wouldn't want to hear some of the solutions I've been offered!).
Got it working fine now.