MACRO LIBRARY

Change sheet metal feature k-factor

Free public access. No account or subscription required.

Files

Change sheet metal feature k-factor

Code

'Demonstrates how to change the k-factor on a sheet metal feature
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
'Preconditions: part is open with sheet metal feature
'Results: sheet metal feature's k-factor is changed to 0.6
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swSheetMetalFeatData As SldWorks.ISheetMetalFeatureData
Dim swCustBendAllow As SldWorks.CustomBendAllowance
    
Sub Main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swFeat = swModel.FirstFeature
    Do While Not swFeat Is Nothing
        If swFeat.GetTypeName = "SheetMetal" Then
            Set swSheetMetalFeatData = swFeat.GetDefinition
            swSheetMetalFeatData.AccessSelections swModel, Nothing
            Set swCustBendAllow = swSheetMetalFeatData.GetCustomBendAllowance
            swCustBendAllow.kfactor = 0.6
            swSheetMetalFeatData.SetCustomBendAllowance swCustBendAllow
            swFeat.ModifyDefinition swSheetMetalFeatData, swModel, Nothing
            Exit Do
        End If
        Set swFeat = swFeat.GetNextFeature
    Loop
End Sub
    
'Notes:
'   This macro proves that sometimes AccessSelections is necessary even when the selections _
    themselves are not being modified.