Files
Mark and select fillets under a certain radius
Code
'This macro demonstrates how the featuremanager tree _
can be traversed for fillets and then marked depending _
on whether the fillets are below a minimum radius. _
Finally, the number of marked features are displayed.
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swPart As SldWorks.PartDoc
Dim swFeat As SldWorks.Feature
Dim swFilletData As SldWorks.ISimpleFilletFeatureData 'or Object
Dim swSelMgr As SldWorks.SelectionMgr
Dim swModel As SldWorks.ModelDoc2
Const MinRadius = 0.002
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swPart = swModel
Set swSelMgr = swModel.SelectionManager
swPart.ClearSelection2 True
'traverse through features
Set swFeat = swPart.FirstFeature
While Not swFeat Is Nothing
If swFeat.GetTypeName2 = "Fillet" Then
Set swFilletData = swFeat.GetDefinition
If swFilletData.DefaultRadius <= MinRadius Then
'select and mark as 2
swFeat.Select2 True, 2
End If
End If
Set swFeat = swFeat.GetNextFeature
Wend
'list selections marked as 2
Debug.Print "Number of fillets with radius below " & MinRadius * 1000 & "mm:" & vbCrLf & _
swSelMgr.GetSelectedObjectCount2(2)
End Sub