helpp

Discussion in 'AutoCAD' started by cmedinag, Mar 14, 2005.

  1. cmedinag

    cmedinag Guest

    im very inexpert in this, i copy paste a code from here of a fillet... now im trying to use it with user interaction, u know, the user select the point or line and the programdo the fillet in it.. and simply dont know how... can anyone correct me? this is the code..
    thanks!

    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

    Public Sub filletprueba()

    Dim objEnt As AcadLWPolyline
    Dim returnObj As AcadObject
    Dim radio As Double
    Dim vertexnum As Integer
    Dim basePnt As Variant
    Dim copyObj As AcadLWPolyine

    On Error Resume Next

    ' pide seleccion de usuario

    ThisDrawing.Utility.GetEntity returnObj, basePnt, "Select a line"

    If Err <> 0 Then
    Err.Clear
    Exit Sub
    Else

    On Error GoTo 0

    If TypeOf returnObj Is AcadLWPolyline Then
    Set lineObj = returnObj

    Set copyObj = ThisDrawing.FilletVertex(lineObj, 1, 50)

    End Sub
     
    cmedinag, Mar 14, 2005
    #1
  2. cmedinag

    Jackrabbit Guest

    Can you use SENDCOMMAND?

    Code:
    Public Sub FilletPolyline()
    Dim entity As AcadEntity
    Dim filletRadius As Double
    Dim pickedPoint As Variant
    Dim polyline As AcadLWPolyline
    
    ThisDrawing.Utility.GetEntity entity, pickedPoint, "Select a polyline..."
    filletRadius = ThisDrawing.Utility.GetReal("Enter the fillet radius...")
    
    If TypeOf entity Is AcadLWPolyline Then
    Set polyline = entity
    ThisDrawing.SendCommand "FILLET Radius" & _
    Str(filletRadius) & " Polyline Last "
    End If
    End Sub
    
     
    Jackrabbit, Mar 15, 2005
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
There are no similar threads yet.
Loading...