2 Replies Latest reply on Aug 26, 2013 9:37 AM by Kyle Chamberlain

    Change in Bend Deduction property not committing.

    Kyle Chamberlain

      Here is my issue:

       

      I have a macro written that changes the bendDeduction property for a sheet metal feature to twice the thickness. The code seems to work fine and reads the new deduction value as what would be the correct result. The problem is that when i check the part after running the macro, no change has occurred.

       

      Here is the code:

       

       

      
      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
                          Debug.Print MToInch(swSheetMetal.BendAllowance)
                          swSheetMetal.BendAllowanceType = swBendAllowanceDeduction
                          swSheetMetal.BendAllowance = swSheetMetal.BendRadius * 2#
                          Debug.Print MToInch(swSheetMetal.BendAllowance)
                          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