I'm trying to change the thickness and the radius of the sheet metal folder (not the sheet metal features inside the sheet metal folder). Consequently, the changes in the folder data will propagate to the sheet metal features hence why I'm doing it. I tried the following code:
' Preconditions: ' (1) Part document containing sheet metal part is open. ' (2) Sheet-Metal feature is selected. ' ' Postconditions: Default bend radius value is doubled. ' '----------------------------------------------- Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swSelMgr As SldWorks.SelectionMgr Dim swFeat As SldWorks.Feature Dim swSheetMetal As SldWorks.SheetMetalFeatureData Dim bRet As Boolean Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swSelMgr = swModel.SelectionManager Set swFeat = swSelMgr.GetSelectedObject5(1) Set swSheetMetal = swFeat.GetDefinition Debug.Print "Feature = " & swFeat.Name Debug.Print " Thickness (Before) = " & swSheetMetal.Thickness * 1000# & " mm" ' Rollback to change default bend radius bRet = swSheetMetal.AccessSelections(swModel, Nothing): Debug.Assert bRet ' Double the default bend radius value swSheetMetal.Thickness = 50.8 / 1000# Debug.Print " Thickness (After) = " & swSheetMetal.Thickness * 1000# & " mm" ' Apply changes bRet = swFeat.ModifyDefinition(swSheetMetal, swModel, Nothing): Debug.Assert bRet Debug.Print bRet End Sub
But for some reasons it doesn't work although Bret is true at the end. When I edit the sheet metal folder, the thickness value is not changed. Any help would be appreciated
I found a workaround using a method by Viktor Bovzdarenko. I've written an extension class of SheetMetalFolder2 found at Github:
GitHub - jliliamen/SheetMetalFolder2: Extension of the ISheetMetalFolder interface to change thickness and radius value …