This code will fillet all polyline objects on the active autoCAD document from an excel module. This is useful when you have CNC object that will be cut on a plasma cutter and cant have sharp edges for safety reasons.
Each fillet will have a radius of 0.25 . The radius can be changed by using acadDoc.SetVariable
acadDoc.SetVariable "filletrad", 0.25


Note: the objects are drawn with PLINETYPE system variable set to 0. This will create LWPOLYLINE or 2D polylines. Also note the polyline objects must be closed.
They can also be drawn with the VBA via AddLightWeightPolyline Method
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-ActiveX/files/GUID-2003E0A1-5FB5-48A7-8CDA-2804F7C61C1C-htm.html
Start by opening Notepad and pasting the following code. Then save as ‘filletall.lsp’ Put the lsp file in a folder called Support. The folder should be located in the same folder as your worksheet.
(defun c:aeoutline () (if (setq i 0 ss (ssget '((0 . "POLYLINE,LWPOLYLINE")(-4 . "&")(70 . 1)))) (progn (while (< i (sslength ss)) (setq x (ssname ss i)) (command "._fillet" "_P" x) (setq i (1+ i)) ) ) ) )
Open vba module in excel and paste the following code.
Sub fillet_all_objects() Dim acadApp As Object Dim acadDoc As Object Dim LispPath As String On Error Resume Next 'Check if AutoCAD application is open. If it is not opened create a new instance and make it visible. Set acadApp = GetObject(, "AutoCAD.Application") If acadApp Is Nothing Then Set acadApp = CreateObject("AutoCAD.Application") acadApp.Visible = True End If If acadApp Is Nothing Then 'Check (again) if there is an AutoCAD object. MsgBox "Sorry, it was impossible to start AutoCAD!", vbCritical, "AutoCAD Error" Exit Sub End If On Error GoTo 0 On Error Resume Next Set acadDoc = acadApp.ActiveDocument If acadDoc Is Nothing Then Set acadDoc = acadApp.Documents.Add End If If acadDoc.ActiveSpace = 0 Then acadDoc.ActiveSpace = 1 End If LispPath = ThisWorkbook.Path & "\Support\filletall.lsp" LispPath = Replace(LispPath, "\", "/") 'load the lisp proc to fillet all vertex of polyline acadDoc.SetVariable "filletrad", 0.25 acadDoc.SendCommand "(load " + Chr(34) + LispPath _ + Chr(34) + ")" + vbCr & "aeoutline" & vbCr & "all " & vbCr End Sub
Note: I try to avoid using the SendCommand method as much as possible for reasons listed in this article. I also found that Sendcommand will not return any run-time errors, So if something went wrong, the user will never know.
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-ActiveX/files/GUID-E13A580D-04CA-46C1-B807-95BB461A0A57-htm.html
In this case, I had no other alternative because it was the most efficient/ only way to fillet all objects and all corners.
All finished! Now just run the macro ‘fillet_all_objects’ and see the computer bend to your will.