3 Replies Latest reply on Aug 19, 2016 7:38 PM by Piotr Tetlak

    Deafault K factor changing

    Piotr Tetlak

      Hello!

       

      I know that similar topic already have been discussed on that forum. Unfortunately I didn't find clear answer how to change default K-factor in SheetMetal part.

       

      Could somebody explain me why example below doesn't work properly:

      =====================================================================================

      Option Explicit

       

          Dim swApp                             As SldWorks.SldWorks

          Dim swModel                           As SldWorks.ModelDoc2

           Dim swFeat                            As SldWorks.Feature

          Dim swBaseFlange                 As SldWorks.BaseFlangeFeatureData

          Dim swSheetMetal                 As SldWorks.SheetMetalFeatureData

       

      Sub main()

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

          

          Set swFeat = swModel.FirstFeature

       

            Do While Not swFeat Is Nothing

              If swFeat.GetTypeName = "SheetMetal" Then

           

                        Set swSheetMetal = swFeat.GetDefinition

                        swSheetMetal.AccessSelections swModel, Nothing

                        swSheetMetal.BendAllowanceType = 2

                        swSheetMetal.Kfactor = 0.2

       

                        swFeat.ModifyDefinition swSheetMetal, swModel, Nothing

                         End If

       

       

          Set swFeat = swFeat.GetNextFeature

          Loop

       

          swModel.ForceRebuild3 False

          swModel.Save

      End Sub

      ===============================================

      The K-factor value is changed in model but I have to click "Override default value" in sheet menu. That is very unacceptable for me.

      I would really appreciate if smb could explain me how to change Default K-factor value.

       

       

      ==================================================

      After some time I've found out that I need to edit kfactor of SheetMetalTemplate, not particular SheetMetal.

      Using loop:

      @

      Do While Not swFeat Is Nothing

              If swFeat.GetTypeName = "SheetMetal" Then

      @

       

      I am not able to get SheetMetalTemplate object.

      Does anyone have any idea how to get it?

       

      Wiadomość była edytowana przez: Piotr Tetlak

        • Re: Deafault K factor changing
          Akshay Abitkar

          KFactor Property (ISheetMetalFeatureData) is obsolete one and Superseded by ISheetMetalFeatureData::GetCustomBendAllowance and ISheetMetalFeatureData::SetCustomBendAllowance.

           

          Try this one

           

          Option Explicit

           

              Dim swApp                             As SldWorks.SldWorks

              Dim swModel                           As SldWorks.ModelDoc2

              Dim swFeat                            As SldWorks.Feature

              Dim swBaseFlange                 As SldWorks.BaseFlangeFeatureData

              Dim swSheetMetal                 As SldWorks.SheetMetalFeatureData

              Dim swCustBendAllow         As SldWorks.CustomBendAllowance

              Dim swSketchBend            As SldWorks.SketchedBendFeatureData

           

           

           

          Sub main()

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

             

              Set swFeat = swModel.FirstFeature

           

                Do While Not swFeat Is Nothing

                  If swFeat.GetTypeName = "SheetMetal" Then

              

                            Set swSheetMetal = swFeat.GetDefinition

                            

                            Set swCustBendAllow = swSheetMetal.GetCustomBendAllowance

                           

                            swSheetMetal.AccessSelections swModel, Nothing

                            swCustBendAllow.Type = 2

                            swCustBendAllow.KFactor = 0.5

           

                            'swSheetMetal.BendAllowanceType = 2

                            'swCustBendAllow.BendAllowance

                            'swSheetMetal.KFactor = 0.5

           

                            swFeat.ModifyDefinition swSheetMetal, swModel, Nothing

                             End If

           

           

              Set swFeat = swFeat.GetNextFeature

              Loop

           

              swModel.ForceRebuild3 False

              swModel.Save

          End Sub

          • Re: Deafault K factor changing
            Deepak Gupta

            You also try using #TASK (a free awesome tool for SOLIDWORKS)