i found a macro on line to select and filet all sharp corners in a sheet metal part. but when i try to run it, i get a syntax error on 2 lines. anyone know what might be wrong. its the 2 lines in red.
Option Explicit
Sub AutoFilletCorners()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeatMgr As SldWorks.FeatureManager
Dim swEdge As SldWorks.Edge
Dim swFace As Sld akkor.Face2
Dim swFillet As SldWorks.Feature
Dim boolstatus As Boolean
Dim longstatus As Long, l jangka as long
Dim i As Long, j As Long, k As Long
Dim EdgeCount As Long
Dim Radius As Double
'Set Radius value here
Radius = 0.1 ' Example radius, adjust as needed
' Get SOLIDWORKS application object
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then
MsgBox "No document open."
Exit Sub
End If
Set swSelMgr = swModel.SelectionManager
Set swFeatMgr = swModel.FeatureManager
' Get all edges in the model
EdgeCount = swModel.GetEdgeCount
If EdgeCount = 0 Then
MsgBox "No edges found in the model."
Exit Sub
End If
' Iterate through each edge
For i = 1 To EdgeCount
Set swEdge = swModel.GetEdgeAt(i)
If Not swEdge Is Nothing Then
' Check if the edge is connected to three or more faces (a corner)
If swEdge.GetNumberOfFaces = 3 Then
' Select the edge and adjacent faces for filleting
boolstatus = swModel.Extension.SelectByID2(swEdge.Name, "EDGE", 0, 0, 0, False, 0, Nothing, 0)
For j = 1 To swEdge.GetNumberOfFaces
Set swFace = swEdge.GetFaceAt(j)
If Not swFace Is Nothing Then
boolstatus = swModel.Extension.SelectByID2(swFace.Name, "FACE", 0, 0, 0, True, 0, Nothing, 0)
End If
Next j
' Apply the fillet
Set swFillet = swFeatMgr.InsertFillet(swFeatMgr.GetFeatureCount + 1, Radius, 0, 0, 0, False, False, False, False)
swModel.ClearSelection2 True
If Not swFillet Is Nothing Then
' Fillet successfully applied
Else
' Fillet failed, handle the error (e.g., log the error)
Debug.Print "Failed to fillet edge: " & swEdge.Name
End If
End If
End If
Next i
' Clean up
Set swEdge = Nothing
Set swFace = Nothing
Set swFillet = Nothing
Set swSelMgr = Nothing
Set swFeatMgr = Nothing
Set swModel = Nothing
Set swApp = Nothing
MsgBox "Filleting complete."
End Sub