1 Reply Latest reply on Jul 1, 2014 8:30 AM by John Pate

    swSheetMetal.BendRadius returning incorrect values

    John Pate

      I need help debugging a section of  sheet metal flat pattern macro since our VAR is useless and refuses to look at it. 


      Below is a small section of code for a large macro that we have been using successfully with SW2012 for quite a long time that I am trying to upgrade to SW2014 compatability.  When we begin a drawing of a sheet metal part, we insert an isometric view then we run the macro.  It's purpose is to validate that the material thickness, bend radius, and K-factor are consistent against a standard that we know works in our pressbrakes.  If all of the checks are validated, the macro will insert the flat pattern along with a note stating that all the parameters are correct.  If they do not pass validation, the flat pattern gets inserted but it generates a note stating whick parameters are incorrect.


      If I make a part in my typical fashion using our standard gauge tables, go to the drawing, insert the view, and run the macro, everything works as it should.  The problem occurs when I go back to the part I just created and change the gauge from one thickness to another.  In SW2012, this was not a problem:  I would go back to the drawing, run the macro again and it would revalidate and update as necessary.  In SW2014, what is happening is that the thickness and K-factor update properly, but the bend radius is locked to the original material gauge I selected.


      For example, in SW2014, I chose 16GA stainless for the original part.  We use thickness of 0.062"/1.5748mm, K-factor of 0.4170, and bend radius of 0.062"/1.5748mm. The macro works properly.  Then I go back to the part and change the material to 11GA stainless.  This should be a thickness of 0.125"/3.1496mm, K-Factor of 0.4158, and bend radius of 0.125"/3.1496mm.  However, when I re-run the macro my bend radius is always 0.062"/1.5748mm on the drawing even though it is 0.125" in the part.  I thought it was something in the re-running of the macro but the bend radius parameter stays incorrect even if I delete the existing drawing and start a new one.  This same situation happens with all of the materials that we use.


      I am stumped. Dues anyone have any idea why this returns incorrect values if I modify the part sheet metal gauge or ideas for fixes?






      Sub ProcessFlatView(ByVal ParamSMconfig As String, ByRef ParamSWflatViewNote As Variant)


      Dim swFeat As SldWorks.Feature

      Dim swSheetMetal As SldWorks.SheetMetalFeatureData

      Dim Kfactor, BendRad, Thickness As Single

      Dim bBendParamValidate As Boolean

      Dim xlApp As Excel.Application

      Dim xlSheetMetalWb As Excel.Workbook

      Dim xlRowIterator, xlSheetIterator As Long

      Dim tempThick, tempKfactor, tempBendRad, EvalTol As Single

      Dim bThickValidate As Boolean

      Dim bKfactorValidate As Boolean

      Dim bBendRadValidate As Boolean

      Dim swMatl, swMatlDB As String

      Dim bRet As Boolean

      Dim lRet As Long


      Dim swFlatView          As SldWorks.View

      Dim SWnote As SldWorks.Note

      Dim swAnnotation        As SldWorks.Annotation


      Dim FlatViewText, GrainDirectionText As String

      Dim FlagStart, FlagEnd As String

      Dim sThickness As String

      Dim sKfactor As String

      Dim sBendRad As String

      Dim sFirstSMFeatName As String


      bRet = swCurrentDoc.ShowConfiguration2(ParamSMconfig) 'activates the current SM configuration


          Set swFeat = swCurrentDoc.FirstFeature


          While Not swFeat Is Nothing 'hunt for sheet metal data

              If bFoundMultiBodies = False Then 'for single body sheet metal:

                  If (swFeat.GetTypeName2 = "SheetMetal") And (swFeat.IsSuppressed = False) Then

                      Set swSheetMetal = swFeat.GetDefinition

                      Thickness = Val(Format(swSheetMetal.Thickness * 1000, "#.####")) 'value in mm

                      BendRad = Val(Format(swSheetMetal.BendRadius * 1000, "#.####")) 'value in mm                '<---------- SOMETHING WRONG HERE I THINK

                      Call MsgBox("Thickness = " & Thickness)

                      Call MsgBox("Bend Radius = " & BendRad)




      Message was edited by: John Pate Removed attached drawing.