Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Polylines with a bulge

50 views
Skip to first unread message

Minkwitz Design

unread,
Oct 10, 2001, 10:52:05 AM10/10/01
to
Hi Dave,
I'm not sure what your asking for when you say origin and startangle. Do
you mean the centerpoint of the arc and what would be the equivalent of
the startangle property for an acadarc? Or do you mean the first point
of the polyline and the angle between the two vertices in modelspace?
Here are a couple of functions. If you can't manipulate the code to give
you what you want, then please clarify what your asking for and I may
be able to come up with what you want.
-Josh

Option Explicit

Public Function IsArc(PolyLin As AcadLWPolyline, Optional Vertex As
Integer) As Boolean
Dim Bulg As Double
If Vertex = Empty Then Vertex = 0
Bulg = PolyLin.GetBulge(Vertex)
If bulge <> 0 Then IsArc = True
End Function

Public Function IsSemiCircle(PolyLin As AcadLWPolyline, Optional Vertex
As Integer) As Boolean
Dim Bulg As Double
If Vertex = Empty Then Vertex = 0
Bulg = PolyLin.GetBulge(Vertex)
If bulge = 1 Or Bulg = -1 Then IsArc = True
End Function

Public Function ClockWise(PolyLin As AcadLWPolyline, Optional Vertex As
Integer) As Boolean
Dim Bulg As Double
If Vertex = Empty Then Vertex = 0
Bulg = PolyLin.GetBulge(Vertex)
If bulge < 0 Then ClockWise = True
End Function

Public Function Radius(PolyLin As AcadLWPolyline, Optional Vertex As
Integer) As Double
Dim PolyPts As Variant
Dim PolySp(0 To 2) As Double
Dim PolyEp(0 To 2) As Double
Dim Lin1 As AcadLine
Dim Ang As Double
Dim IsoAng As Double
Dim Bulg As Double
If Vertex = Empty Then Vertex = 0
Bulg = PolyLin.GetBulge(Vertex)
Ang = Atn(Bulg) * 4
IsoAng = Ang / 3.141592654 * 180
If IsoAng < 0 Then
IsoAng = (IsoAng + 180) / 2
Else
IsoAng = (180 - IsoAng) / 2
End If
IsoAng = IsoAng / 180 * 3.141592654
PolyPts = PolyLin.Coordinates
PolySp(0) = PolyPts(0): PolySp(1) = PolyPts(1)
PolyEp(0) = PolyPts(2): PolyEp(1) = PolyPts(3)
Set Lin1 = ThisDrawing.ModelSpace.AddLine(PolySp, PolyEp)
Radius = (Lin1.Length / 2) / Cos(IsoAng)
Lin1.Delete
End Function

Public Function CenterPt(PolyLin As AcadLWPolyline, Optional Vertex As
Integer) As Variant
Dim PolyPts As Variant
Dim PolySp(0 To 2) As Double
Dim PolyEp(0 To 2) As Double
Dim Lin1 As AcadLine
Dim Ang As Double
Dim IsoAng As Double
Dim Radius As Double
Dim ClockWise As Boolean
Dim RadAng As Double
Dim Bulg As Double
If Vertex = Empty Then Vertex = 0
Bulg = PolyLin.GetBulge(Vertex)
PolyPts = PolyLin.Coordinates
PolySp(0) = PolyPts(0): PolySp(1) = PolyPts(1)
PolyEp(0) = PolyPts(2): PolyEp(1) = PolyPts(3)
Set Lin1 = ThisDrawing.ModelSpace.AddLine(PolySp, PolyEp)
Ang = Atn(Bulg) * 4
IsoAng = Ang / 3.141592654 * 180
If IsoAng < 0 Then
IsoAng = (IsoAng + 180) / 2
ClockWise = True
Else
IsoAng = (180 - IsoAng) / 2
End If
IsoAng = IsoAng / 180 * 3.141592654
If ClockWise Then
RadAng = Lin1.Angle + IsoAng + 3.141592654
Else
RadAng = Lin1.Angle - IsoAng + 3.141592654
End If
Radius = (Lin1.Length / 2) / Cos(IsoAng)
CenterPt = ThisDrawing.Utility.PolarPoint(PolyEp, RadAng, Radius)
Lin1.Delete
End Function


dgleason wrote:

> I am creating an arc / polyline (with bulge) slicer,
> how do I calculate the origin and start angle for a polyline with a
> bulge. I saw some AutoLISP code, but I cant read it.
>
> I found the following, but nothing for the start angle and obviously I
> can find the direction from the sign of the bulge factor..
>
> IncludedAngle = 4 * Atan(Abs(bulge factor))
> Angle = .5PI - .5IncludedAngle
> Chord = Distance(Point1, Point2)
> Radius = .5Chord / Cos(Angle)
>
> Thanks
>
> Dave
>

Minkwitz Design

unread,
Oct 12, 2001, 5:39:42 PM10/12/01
to
Hi Dave,
Sorry for the delayed response. First off, if you want access to the acad
functions from vb, from the pulldown, select project properties, then
references, then check the acad type library. Secondly, I do know the
math, but it's been a while since I wrote these :) I based the
centerpoint function on the theory that a line drawn perpendicular to a
chord at the chords midpoint (bisects the chord) will intersect with the
centerpoint. In addition, it bisects the angle of the arc. That in
combination with the following clip from the help files:

The bulge is 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. A negative bulge value indicates that the arc goes clockwise from
the selected vertex to the next vertex. A bulge of 0 indicates a
straight segment, and a bulge of 1 is a semicircle.

So the arctangent of the bulge multiplied by 4 gives the arc's angle.
This angle and the line bisecting the chord yields enough info to form 2
right triangles and calculate startangle, endangle, radius, centerpoint,
ect.

Using the value of the bulge and the location of the vertices, you can
calculate the direction of the arc and on which side of the polyline the
centerpoint falls. Hope this helps.

-Josh

dgleason wrote:

> Hi Josh, thanks for your help.. You were right
> I am looking for the "centerpoint and
> the equivalent to the startangle property for
> the arc".
>
> Unfortunately the project that I am writing is outside of AutoCad, so I
> really don't have access to AutoCad objects.
>
> Do you know the math behind:


> "CenterPt = ThisDrawing.Utility.PolarPoint(PolyEp, RadAng, Radius)"
>

> and
>
> "ThisDrawing.ModelSpace.AddLine(PolySp, PolyEp)"
>
> Basically I need to calculate the origin and startangle so
> that when I create a polyline "representation" of the
> polyline(with a bulge) that I read in, I know where to start, ie. in the
> which quadrant etc.
>

0 new messages