1 Reply Latest reply on Aug 27, 2015 12:09 PM by Steve Mlynczak

    Macro to Change User Specified Name in BOM to description property

    Steve Mlynczak

      I want to traverse thru each configuration and pull the "description" property from the configuration specific tab and use it in the user specified name in the bill of materials. The code i have works for the active configuration but doesn't change as goes thru the configs.  It always keeps the same description property. This is what it looks like and the bottom pic is what i want. I have attached files for reference.


      It should look like this

        • Re: Macro to Change User Specified Name in BOM to description property
          Steve Mlynczak

          I was able to figure this out.


          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

          Dim cusPropMgr As SldWorks.CustomPropertyManager

          Dim config As SldWorks.Configuration

          Dim CP As String

          Dim valout As String

          Dim bool As Boolean

          Dim qw As String


          Sub main()

          Set swApp = Application.SldWorks

          Set swModel = swApp.ActiveDoc

          Set config = swModel.GetActiveConfiguration

          Set cusPropMgr = config.CustomPropertyManager


                'get custom property CP

                sConfigNameArr = swModel.GetConfigurationNames

                For Each sconfigname In sConfigNameArr


                Set swModelDocExt = swModel.Extension


                 Dim swConfig As SldWorks.Configuration

                 Set swConfig = swModel.GetActiveConfiguration

                 Set swCustProp = swModel.Extension.CustomPropertyManager(sconfigname)

                 Set sConfig = swModel.GetConfigurationByName(sconfigname)


                 If sconfigname = "Default" Then Set swCustProp = swModel.Extension.CustomPropertyManager("")

                 bool = swCustProp.Get4("Description", False, CP, valout)

                 sConfig.BOMPartNoSource = swBOMPartNumber_UserSpecified

                 sConfig.AlternateName = sconfigname

                 sConfig.UseAlternateNameInBOM = True

                 sConfig.AlternateName = CP





          End Sub