________
| |
| |x_______
| |
| |
Thanks
David Nelms
Public Const PI As Double = 3.14159265358979
... but i'm sure you figured that one out... =)
'================================BEGIN CODE
'This function will add a vertex infront of the vertice _
to be "filleted", adjust the previous point, and _
add a bulge factor to the new segment
Public Function FilletVertex(ByVal LWPline As AcadLWPolyline, _
ByVal VertexNumber As Integer, ByVal Radius As Double)
On Error Resume Next
Dim AngleToVertex As Double
Dim AngleFromVertex As Double
Dim AngleIncluded As Double
Dim PtList As Variant
Dim LastVertex As Integer
Dim PrevVertex As Integer
Dim NextVertex As Integer
Dim pt1 As Variant
Dim pt2 As Variant
Dim pt2a As Variant
Dim pt2b As Variant
Dim pt3 As Variant
Dim VertexA(1) As Double
Dim VertexB(1) As Double
Dim AngleC As Double
Dim AngleA As Double
Dim Chamfer As Double
Dim Util As AcadUtility
Set Util = ThisDrawing.Utility
If Not Radius > 0 Then Exit Function
With LWPline
PtList = .Coordinates
LastVertex = (UBound(PtList) - 1) / 2
If VertexNumber > LastVertex Then VertexNumber = 0
NextVertex = VertexNumber + 1
PrevVertex = VertexNumber - 1
If NextVertex > LastVertex Then NextVertex = 0
If PrevVertex < 0 Then PrevVertex = LastVertex
If NextVertex = PrevVertex Then Exit Function
pt1 = .Coordinate(PrevVertex)
pt2 = .Coordinate(VertexNumber)
pt3 = .Coordinate(NextVertex)
ReDim Preserve pt1(2): pt1(2) = 0
ReDim Preserve pt2(2): pt2(2) = 0
ReDim Preserve pt3(2): pt3(2) = 0
AngleToVertex = Util.AngleFromXAxis(pt2, pt1)
AngleFromVertex = Util.AngleFromXAxis(pt2, pt3)
AngleIncluded = (AngleToVertex - AngleFromVertex)
If AngleIncluded > PI Then
AngleIncluded = AngleIncluded - (2 * PI)
ElseIf AngleIncluded < -PI Then
AngleIncluded = AngleIncluded + (2 * PI)
End If
Chamfer = Radius * _
Tan((PI - (Abs(AngleIncluded))) / 2)
pt2b = Util.PolarPoint(pt2, _
AngleFromVertex, Chamfer)
VertexB(0) = pt2b(0): VertexB(1) = pt2b(1)
.Coordinate(VertexNumber) = VertexB
pt2a = Util.PolarPoint(pt2, _
AngleToVertex, Chamfer)
VertexA(0) = pt2a(0): VertexA(1) = pt2a(1)
.AddVertex VertexNumber, VertexA
.SetBulge VertexNumber, _
Tan((IIf(AngleIncluded > 0, PI, -PI) _
- AngleIncluded) / 4#)
End With
End Function
'================================END CODE
Even with the method Lanny mentioned, you should use a variant array of
doubles, not variant type.
-Josh
"Joe Sutphin" <jo...@worldnet.att.net> wrote in message
news:03C17005A73D621A...@in.WebX.maYIadrTaRb...
> Pi = Atn(1)*4
> --
> Joe Sutphin
> See special offer on my new book at
> http://eomnisource.hypermart.net
>
>
> "Lanny Schiele" <lsch...@tmisystems.com> wrote in message
> news:1B13167ED6C4754E...@in.WebX.maYIadrTaRb...
"Lanny Schiele" <lsch...@tmisystems.com> wrote in message
news:1B13167ED6C4754E...@in.WebX.maYIadrTaRb...
Thanks for any help.
"Lanny Schiele" <lsch...@tmisystems.com> wrote in message
news:C78A5DF01780A78E...@in.WebX.maYIadrTaRb...
Sorry, but no -- it must use a lightweight polyline. I wrote it because in
our industry, you start with a rectangular board (the pline) and do notching
and radiusing around the edges... its a bit different in that it involves
calculating the bulge needed from the desired radius. It should give you
some idea as to what is needed to be done to fillet lines... there, i would
find the intersection of the 2 lines, get the center point of your arc,
create the arc, and then change the length of the 2 lines accordingly. Good
luck - Lanny
Tom