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

Need Help ..Arc or Fillet?

213 views
Skip to first unread message

David Nelms

unread,
Nov 8, 2001, 7:42:45 PM11/8/01
to
Need some help. If the example is readable below, I'd like to duplicate the
fillet command where the x is in the picture, with the only user interation
being entering the radius used. It is a cope in a plate and it needs a
radius. Is the fillet command exposed in VBA, or is my best bet drawing an
arc. The problem with that is I drew the plate setting points with
polarpoint and the variable as of Variant type. I thought I had the thing
figured out but keep getting a type mismatch when trying to set the point as
my centerpoint for an arc.
Before I do too much, I'd like to see what suggestions the group will give
as the best way top accomplish this.

________
| |
| |x_______
| |
| |


Thanks
David Nelms


Lanny Schiele

unread,
Nov 9, 2001, 11:04:06 AM11/9/01
to
ooops, you need PI.... one way:

Public Const PI As Double = 3.14159265358979

... but i'm sure you figured that one out... =)


Lanny Schiele

unread,
Nov 9, 2001, 11:01:19 AM11/9/01
to
I needed something to "round off" corners programmatically -- just give it a
lightweight polyline, the vertice number at which you want to have filleted,
and the size of the fillet's radius.
HTH - Lanny
Watch for word wrap...

'================================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


Minkwitz Design

unread,
Nov 9, 2001, 11:42:08 AM11/9/01
to
Dim centerPoint(0 To 2) As Double

Even with the method Lanny mentioned, you should use a variant array of
doubles, not variant type.

-Josh

Lanny Schiele

unread,
Nov 9, 2001, 11:30:18 AM11/9/01
to
Arctan! Arctan! ... i couldn't remember that one!

"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...

Joe Sutphin

unread,
Nov 9, 2001, 11:25:37 AM11/9/01
to
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...

David Nelms

unread,
Nov 10, 2001, 2:40:01 PM11/10/01
to
Appreciate the function. Being new to the VBA part of Autocad, need a little
help. IN your function it needs a LW polyline. When I draw my plate, I have
it using lines, not polylines. Do I need to change that? Is your function
looking for an existing polyline as a starting point?

Thanks for any help.


"Lanny Schiele" <lsch...@tmisystems.com> wrote in message

news:C78A5DF01780A78E...@in.WebX.maYIadrTaRb...

Lanny Schiele

unread,
Nov 12, 2001, 10:19:27 AM11/12/01
to

"David Nelms" <dne...@countrysoftware.com> wrote in message
news:61FB6D1F45B45927...@in.WebX.maYIadrTaRb...

> Appreciate the function. Being new to the VBA part of Autocad, need a
little
> help. IN your function it needs a LW polyline. When I draw my plate, I
have
> it using lines, not polylines. Do I need to change that? Is your function
> looking for an existing polyline as a starting point?

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 Craft

unread,
Nov 15, 2001, 12:44:55 AM11/15/01
to
If the angle is known you can calculate the tangent length of the curve. Using
the tangent you can calculate the beginning and ending point of the curve and
adjust the end of each line to match. One of the routines I use does just that,
but the central angle is sometimes over 180 degrees. This complicates finding
the point of intersection of the arc. The routine was not reliable in getting
the arc drawn in the correct direction so I calculate the coordinates of the
midpoint of the curve and sent the first, second(midpoint) and end points to
lisp using Vlax, then use the sendcommand to impliment the arc command.

Tom

0 new messages