4 Replies Latest reply on Aug 24, 2014 1:15 AM by Deepak Gupta

    How to access part parameters from assembly ?

    Sanya Shmidt

      Hello guys!

      Can someone give me a simple example please.

       

      Assembly document

           - FRONT_BEAM

           - REAR_BEAM

           etc....

       

      Need to know how to change FRONT_BEAM parameter ("DF_X_Offset@Sketch1") from an assembly level?

       

      For single part its easy,

       

      ' single part

      swApp = Application.SldWorks

      swModel = swApp.ActiveDoc

      swModel.Parameter("DF_X_Offset@Sketch1").SystemValue = DF_X_Offset * 0.0254

       

      but how I tell via code get FRONT_BEAM and change DF_X_Offset@Sketch1@FRONT_BEAM???

      Any help is appreciated.

      Thank you.

        • Re: How to access part parameters from assembly ?
          Deepak Gupta

          Add model type in the DF_X_Offset@Sketch1@FRONT_BEAM.PART

            • Re: How to access part parameters from assembly ?
              Sanya Shmidt

              Thank you. I was almost there :-)

              • Re: How to access part parameters from assembly ?
                Sanya Shmidt

                Deepak,

                Do you know how to access/change Custom properties of the component in the assembly?

                What is the syntax?

                 

                swModel.CustomInfo("Description@SideBeam.sldprt") = "TEST" ???? WHat is the correct way?

                 

                Thank you,

                Alex.

                  • Re: How to access part parameters from assembly ?
                    Deepak Gupta

                    Try/Use these codes as required:

                     

                    Option Explicit

                    Sub main()

                     

                        Dim swApp                        As SldWorks.SldWorks

                        Dim swModel                     As SldWorks.ModelDoc2

                        Dim swCompModel            As SldWorks.ModelDoc2

                        Dim swSelMgr                   As SldWorks.SelectionMgr

                        Dim swComp                     As SldWorks.Component2

                        Dim value                          As String

                       

                        Set swApp = Application.SldWorks

                        Set swModel = swApp.ActiveDoc

                        Set swSelMgr = swModel.SelectionManager

                        Set swComp = swSelMgr.GetSelectedObjectsComponent2(1)

                     

                        Set swCompModel = swComp.GetModelDoc

                       

                        swCompModel.AddCustomInfo3 swCompModel.GetActiveConfiguration.Name, FieldName, FieldType, FieldValue 'To add configuration specific property

                        value = swCompModel.CustomInfo2(swCompModel.GetActiveConfiguration.Name, "Property Name Here") 'To get configuration specific property

                        Debug.Print value

                        swCompModel.CustomInfo2(swCompModel.GetActiveConfiguration.Name, "Property Name Here") = "Value Here" 'To change configuration specific property

                       

                        'swCompModel.AddCustomInfo2 FieldName, FieldType, FieldValue 'To add custom property

                        value = swCompModel.CustomInfo("Property Name Here") 'To get custom property

                        Debug.Print value

                        swCompModel.CustomInfo("Property Name Here") = "Value Here" 'To change custom property

                          

                        swModel.ClearSelection2 True

                     

                    End Sub