AnsweredAssumed Answered

Changes to Sheet Metal Properties Not Being Applied

Question asked by Eric Schneider on Jun 21, 2016
Latest reply on Jun 27, 2016 by Eric Schneider

The following was basically copy/pasted from here. When I run the following script, I get no errors, debug printout shows changes, second run of script shows changes were applied but no changes appear in the tree. What am I doing wrong?

 

Dim swApp                       As SldWorks.SldWorks
Dim swModel                     As SldWorks.ModelDoc2
Dim swSelMgr                    As SldWorks.SelectionMgr
Dim swFeat                      As SldWorks.Feature
Dim swFeatMgr                   As SldWorks.FeatureManager
Dim swFeatStat                  As SldWorks.FeatureStatistics
Dim swSubFeat                   As SldWorks.Feature
Dim swSheetMetal                As SldWorks.SheetMetalFeatureData
Dim featCount                   As Long
Dim counter                     As Long
Dim bRet                        As Boolean

Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swFeat = swModel.FirstFeature
    Set swFeatMgr = swModel.FeatureManager
    Set swFeatStat = swFeatMgr.FeatureStatistics
    Do While Not swFeat Is Nothing
        ' Process top-level sheet metal features
        ' Debug.Print swFeat.GetTypeName
    Select Case swFeat.GetTypeName
        Case "SheetMetal"
            Set swSheetMetal = swFeat.GetDefinition
            ' Rollback to change default bend radius
            bRet = swSheetMetal.AccessSelections(swModel, Nothing): Debug.Assert bRet
            Debug.Print MToInch(swSheetMetal.BendAllowance)
            Debug.Print swSheetMetal.BendAllowanceType
            swSheetMetal.BendAllowanceType = -1
            swSheetMetal.BendAllowance = swSheetMetal.BendRadius * 2#
            Debug.Print MToInch(swSheetMetal.BendAllowance)
            Debug.Print swSheetMetal.BendAllowanceType
            ' Apply changes
            bRet = swFeat.ModifyDefinition(swSheetMetal, swModel, Nothing): Debug.Assert bRet
            Debug.Print MToInch(swSheetMetal.BendAllowance)
            Debug.Print swSheetMetal.BendAllowanceType
            'Rebuild sheet
            swModel.ForceRebuild3 (False)
            Exit Sub
        Case Else
        'not a sheetmetal feature
    End Select
    Set swFeat = swFeat.GetNextFeature
    Loop
End Sub

Function MToInch(inputVal As Double) As Double
    MToInch = (inputVal * 1000#) / 25.4
End Function

Outcomes