2 Replies Latest reply on May 5, 2017 7:33 AM by Jacob Kuznicki

    (SW 2017 SP2.0)  When I try to use IExtrudeFeatureData2.LinkToThickness = True Solidworks crashes.

    Jacob Kuznicki

      (SW 2017 SP2.0)

      I am trying use the API to create a cut extrude in a sheetmetal part.  I want the cut extrude to "link to thickness".  When I try to use IExtrudeFeatureData2.LinkToThickness = True Solidworks crashes.  Is there a method that is more appropriate?

       

                     Dim swSheetMetal As SldWorks.SheetMetalFeatureData

                     'There is code that sets the swSheetMetal variable to the Sheetmetal feature definition

       

                      'Sets the thickness value of the sheet metal to a variable.

                      dblThk = swSheetMetal.Thickness

                      'Creates a Cut Extrusion (blind - link to thickness)

                      swModel.FeatureManager.FeatureCut True, False, False, 0, 0, dblThk, dblThk, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 1, 1, 1

                     

                      'Captures the CutExtrusion feature that was just created and links the depth dimension to the thickness of the sheet metal.

                      Set swFeature = swSelMgr.GetSelectedObject5(1)

                     

                      Dim extFeatData As ExtrudeFeatureData2

                      Set extFeatData = swFeature.GetDefinition

                    

                     extFeatData.LinkToThickness = True  '<<<CRASH>>>

        • Re: (SW 2017 SP2.0)  When I try to use IExtrudeFeatureData2.LinkToThickness = True Solidworks crashes.
          Peter Brinkhuis

          Could you post a more complete example of what you have? Something that works preferably (up until the crash)? I'm trying to recreate something that works now, but the error might just be in that part of the code.

            • Re: (SW 2017 SP2.0)  When I try to use IExtrudeFeatureData2.LinkToThickness = True Solidworks crashes.
              Jacob Kuznicki

              Start with a sheetmetal part (we use gage tables for thickness and bend radius).  Create a circular sketch on the face of the sheetmetal part.  Run the macro below with the sketch selected.

               

              Dim swApp As SldWorks.SldWorks

              Dim swModel As SldWorks.ModelDoc2

              Dim swFeature As SldWorks.Feature

              Dim swSheetMetal As SldWorks.SheetMetalFeatureData

              Dim swSelMgr As SldWorks.SelectionMgr

              Dim swFeatName As String

              Dim swFeatType As String

              Dim dblThk As Double

               

              Set swApp = Application.SldWorks

               

              If Not swApp Is Nothing Then

                    Set swModel = swApp.ActiveDoc

                    If Not swModel Is Nothing Then

                        Set swFeature = swModel.FirstFeature

                          While Not swFeature Is Nothing

                              swFeatName = swFeature.Name

                              swFeatType = swFeature.GetTypeName

                              If swFeatType = "SheetMetal" Then

                                Set swSheetMetal = swFeature.GetDefinition

                                Set swSelMgr = swModel.SelectionManager

                             

                                'Sets the thickness value of the sheet metal to a variable.

                                dblThk = swSheetMetal.Thickness

                                'Creates a Cut Extrusion (blind)

                                swModel.FeatureManager.FeatureCut True, False, False, 0, 0, dblThk, dblThk, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 1, 1, 1

                             

                                'Captures the CutExtrusion feature that was just created

                                'and links the depth dimension to the thickness of the

                                'sheet metal.

                                Set swFeature = swSelMgr.GetSelectedObject5(1)

               

                                Dim extFeatData As ExtrudeFeatureData2

                                Set extFeatData = swFeature.GetDefinition

                                extFeatData.LinkToThickness = True

                             End If

                             Set swFeature = swFeature.GetNextFeature

                          Wend

                    End If

                    Set swModel = Nothing

              End If

              Set swApp = Nothing

               

              This is where my Solidworks will crash, although the Help documentation states that LinkToThickness is a set\get property.