MACRO LIBRARY

Modify fillet size

Free public access. No account or subscription required.

Files

Modify fillet size

Code

'Search part for fillet features. If radius is 10mm, change to 20mm. If 20mm, change to 10mm.
    
'Preconditions: part with a fillet of radius 10mm is open
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swFilletFeatData As SldWorks.SimpleFilletFeatureData2
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swFeat = swModel.FirstFeature
    
    While Not swFeat Is Nothing
        If swFeat.GetTypeName = "Fillet" Then
            Set swFilletFeatData = swFeat.GetDefinition
            If swFilletFeatData.DefaultRadius = 0.01 Then
                swFilletFeatData.DefaultRadius = 0.02
            Else
                swFilletFeatData.DefaultRadius = 0.01
            End If
            swFilletFeatData.AccessSelections swModel, Nothing
            swFeat.ModifyDefinition swFilletFeatData, swModel, Nothing
        End If
        Set swFeat = swFeat.GetNextFeature
    Wend
End Sub
    
'From feature data API help pages:
'This method puts the model into a rollback state to allow access to the selections that _
    define this feature. You must use either of the following methods to restore the _
    rollback state:
    'IFeature::ModifyDefinition if you modified the feature
    'ISimpleFilletFeatureData2::ReleaseSelectionAccess if you did not
    
'AccessSelections is only necessary when you need to access the entity selections used to _
    create the feature. It is not needed to change simple feature properties.