13 Replies Latest reply on Dec 16, 2014 11:44 AM by Sanya Shmidt

    Changing sheet metal Gauge via API

    Sanya Shmidt

      Good evening,

       

      Can someone help me how to change sheet metal parameters steel gauge via API. Part I have is using predefined gauge table with 15 different materials.

       

      I assume I`ll have to use the following code with some other code to change the gauge? Right?

       

      boolstatus = Part.Extension.SelectByID2("Sheet-Metal", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)

       

      Any information or link to a similar topic will be great.

       

      Thanks,

      SW gauge.PNG

        • Re: Changing sheet metal Gauge via API
          Artem Taturevych

          Hi,

           

          You need to get the pointer to sheet metal feature. You can do this via selection or just directly by name: PartDoc::FeatureByName. This will give you a pointer to IFeature object where you can call the Feature::GetDefinition method. Now just call the following method to set the gauge table parameters: SheetMetalFeatureData::SetUseGaugeTable.

           

          Take a look at this example demonstrating the usage of gauge table: http://help.solidworks.com/2013/English/api/sldworksapi/create_base-flange_feature_using_gauge_table_example_vb.htm

          ______________________________________________

          Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

           

          IC3DSteel – New Steel Solution for SolidWorks

          translationXpert – SolidWorks files language translator

          LinkedIn - SolidWorks API Group

            • Re: Changing sheet metal Gauge via API
              Sanya Shmidt

              Sorry Artem, I`ve got myself confused.. Don`t really have a lot of experience with API and its structure.

               

              So I have a sheet metal part with "Sheet-Metal" feature and Gauge table attached.

               

                  Dim swApp As SldWorks.SldWorks

                  Dim swModel As SldWorks.ModelDoc2

                  swModel = swApp.ActiveDoc

               

                  Dim ShMetalFeat As SldWorks.SheetMetalFeatureData

                  ShMetalFeat.SetUseGaugeTable(True, "c:\Program Files\SolidWorks Corp\SolidWorks\lang\english\Sheet Metal Gauge Tables\Steel Gauge Table.xls")

               

                 What should I do next to change thickness from 7gauge to 10 gauge? Typically it has to be done manually by choosing Gauge from the drop down menu in Sheet metal Parameters (see 1st post picture).

               

              Thank you.

                • Re: Changing sheet metal Gauge via API
                  Artem Taturevych

                  Hi Sanya,

                   

                  Here is the sample which changes the gauge thickness to the last value in the drop-down. You need to select the base flange which is uses gauge table and run the macro:

                   

                  Dim swApp As SldWorks.SldWorks

                  Dim swModel As SldWorks.ModelDoc2

                  Dim swSelMgr As SldWorks.SelectionMgr

                   

                  Sub main()

                   

                      Set swApp = Application.SldWorks

                   

                      Set swModel = swApp.ActiveDoc

                     

                      Set swSelMgr = swModel.SelectionManager

                     

                      Dim swFeat As SldWorks.Feature

                     

                      Set swFeat = swSelMgr.GetSelectedObject6(1, -1)

                     

                      Dim swBaseFlangeFeatData As SldWorks.BaseFlangeFeatureData

                     

                      Set swBaseFlangeFeatData = swFeat.GetDefinition

                     

                      Debug.Print swBaseFlangeFeatData.UseGaugeTable

                      Debug.Print swBaseFlangeFeatData.GaugeTablePath

                      Debug.Print swBaseFlangeFeatData.ThicknessTableName

                     

                      Dim vThicknesses As Variant

                      vThicknesses = swBaseFlangeFeatData.GetTableThicknesses()

                      swBaseFlangeFeatData.ThicknessTableName = vThicknesses(UBound(vThicknesses))

                   

                   

                      swFeat.ModifyDefinition swBaseFlangeFeatData, swModel, Nothing

                     

                  End Sub

                  ______________________________________________

                  Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

                   

                  IC3DSteel – New Steel Solution for SolidWorks

                  translationXpert – SolidWorks files language translator

                  LinkedIn - SolidWorks API Group