FIllet Two Members Through VBA

FIllet Two Members Through VBA

Anonymous
Not applicable
3,609 Views
4 Replies
Message 1 of 5

FIllet Two Members Through VBA

Anonymous
Not applicable

I need to fillet two lines with a specified radius using VBA. I have not been able to find anything on this subject using VBA. Any help is greatly appreciated.

0 Likes
Accepted solutions (1)
3,610 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Accepted solution

Here you go, just change fillet radius on whatever you want

Attribute VB_Name = "modFilletLines"
Option Explicit

Sub LineFillet()
Dim setName As String
Dim setObj As AcadSelectionSet


    setName = "$Lines$"
    On Error GoTo Err_Control

            Dim fType(0) As Integer, fData(0)
            Dim oSset As AcadSelectionSet

     fType(0) = 0: fData(0) = "LINE"
  
     Dim dxfcode As Variant
     Dim dxfdata As Variant
     dxfcode = fType: dxfdata = fData
     
     Dim setColl As AcadSelectionSets
     With ThisDrawing
          Set setColl = .SelectionSets
          For Each setObj In setColl
               If setObj.Name = setName Then
                    .SelectionSets.Item(setName).Delete
                    Exit For
               End If
          Next
          Set oSset = .SelectionSets.Add(setName)
     End With

            oSset.SelectOnScreen dxfcode, dxfdata
            
            If oSset.Count <> 2 Then
            MsgBox "Select 2 lines only"
            Exit Sub
            End If
            Dim lnf As AcadLine
                    Dim lns As AcadLine
              Set lnf = oSset.Item(0)
              Set lns = oSset.Item(1)
           Dim hdlf As String: hdlf = lnf.Handle
           Dim hdls As String: hdls = lns.Handle
           Dim filrad As Double
           filrad = ThisDrawing.GetVariable("filletrad")
           ThisDrawing.SetVariable "filletrad", 25#
           ThisDrawing.SetVariable "cmdecho", 1
           Dim cmd As String
           cmd = "(command " & Chr(34) & "_.fillet" & Chr(34) & " (handent " & Chr(34) & hdlf & Chr(34) & ")" & Chr(32) & "(handent " & Chr(34) & hdls & Chr(34) & ")" & Chr(32) & Chr(34) & Chr(34) & Chr(32) & Chr(34) & Chr(34) & ")" & vbCr
           ThisDrawing.SendCommand (cmd)
           
Err_Control:
           If Err.Number <> 0 Then
           MsgBox Err.Description
           End If
           
End Sub

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks. This is perfect.

0 Likes
Message 4 of 5

Anonymous
Not applicable
You're welcome 🙂
0 Likes
Message 5 of 5

jeremye86
Advocate
Advocate

should we put an API sleep routine after this line in case autocad gets hung up?

ThisDrawing.SendCommand (cmd)

 

0 Likes