9 Replies Latest reply on Dec 3, 2016 11:05 PM by Nilesh Patel

    Table of configuration specific custom properties.

    pradeep nirer


      I have a part/assembly which has number of configurations and in each configurations for same configuration specific custom properties different values are assigned.

      I want to create a table in this part/assembly drawing which lists

      1) All the configurations of the part/assembly in the first column

      2) Related configuration specific custom properties in second and rest of the columns.


      Is this possible in Solidworks? If yes, please help understand how to achieve it.


      Note: I am not fan of design table insertion as it is prohibited in my company...




        • Re: Table of configuration specific custom properties.
          Peter Brinkhuis

          Should be doable without the design tables. What's wrong with those, they can be great


          You can add a new table to a drawing. At the top of each column you can set the property that it should contain, at least that's how it works with adding extra columns to BOMs. You should be able to select the configuration name and the content of a custom property as the columns.

          • Re: Table of configuration specific custom properties.
            Amen Allah Jlili

            Yes. It's possible.


            0. Add a TableAnnotation to the drawing.

            1. Get the referenced model's ModelDoc2 object from the first view.
            2. Use the ConfigurationManager to get the names of all the configurations.

            3. Per configuration, use the CustomPropertyManager of the ModelDoc2 object you get in step one to get all the custom properties names and their resolved values using the method CustomPropertyManager::GetAll2. This method will take two variants one is for the names of the custom props and the other for the resolved values and fill them in for you.

            4. Fill the table one configuration at a time.


            Hopefully, all of your configurations have the same custom properties, otherwise, your table will not look nice.


            Send me a message if you need more help!

            • Re: Table of configuration specific custom properties.
              pradeep nirer


              Some how I worked out... just check below code.


              Option Explicit

              Dim swApp As Object

              Dim Part As Object
              Dim boolstatus As Boolean
              Dim longstatus As Long, longwarnings As Long
              Dim myTable1 As TableAnnotation

              Function InsertTable1(rowCount As Integer, columnCount As Integer) As TableAnnotation

                  If columnCount < 3 Then
                      MsgBox "Invalid table column"
                      Exit Function
                  End If

                  Dim myTable As TableAnnotation
                  Set myTable = Part.InsertTableAnnotation(3.50025261755506E-02, 0.807825915596727, 1, rowCount, columnCount)
                  If Not myTable Is Nothing Then
                     myTable.BorderLineWeight = 0
                     myTable.GridLineWeight = 0
                  End If
                  boolstatus = myTable.MergeCells(0, 0, 0, 2)
                  myTable.Text(0, 0) = "ASSEMBY CONFIGURATION TABLE"
                  myTable.Text(1, 0) = "CONFIG"
                  myTable.Text(1, 1) = "CPN/RPN/GPN"
                  myTable.Text(1, 2) = "DESCRIPTION"
                  Set InsertTable1 = myTable

              End Function

              Function GetPartDescription(asmDoc As ModelDoc2, configName As String, propertyName As String) As String

                  Dim cfg As Configuration
                  Set cfg = asmDoc.GetConfigurationByName(configName)
                  Dim custPropertyManager As CustomPropertyManager
                  Set custPropertyManager = cfg.CustomPropertyManager
                  Dim ValOut As String
                  Dim ResolvedValOut As String
                  Dim wasResolved As Boolean
                  custPropertyManager.Get5 propertyName, False, ValOut, ResolvedValOut, wasResolved
                  GetPartDescription = ValOut
              End Function
              Sub main()

              Set swApp = Application.SldWorks

              Set Part = swApp.ActiveDoc
              Dim myModelView As Object
              Set myModelView = Part.activeView

              Dim dDoc As DrawingDoc
              Set dDoc = Part

              Dim activeView As View
              Set activeView = dDoc.ActiveDrawingView

              If activeView Is Nothing Then
                  Exit Sub
              End If

              Dim dComponent As DrawingComponent
              Set dComponent = activeView.RootDrawingComponent

              Dim component As Component2
              Set component = dComponent.component

              Dim asmDoc As AssemblyDoc
              Set asmDoc = component.GetModelDoc2

              Dim asmModDoc As ModelDoc2
              Set asmModDoc = asmDoc

              Dim configNames()  As String
              Dim configCount As Integer

              configCount = asmModDoc.GetConfigurationCount

              'insert table now
              Set myTable1 = InsertTable1(configCount + 2, 3)

              'Get names of all configurations and add into table
              Dim i As Long
              configNames = asmModDoc.GetConfigurationNames
              For i = 0 To UBound(configNames)
                      Dim configName As String
                      configName = configNames(i)
                      myTable1.Text(i + 2, 0) = i + 1
                      myTable1.Text(i + 2, 1) = configName
                      ' this is name of custom property we will search for description
                      Dim partDescCustomProperty As String
                      partDescCustomProperty = "DESCRIPTION"
                      Dim partDesc As String
                      partDesc = GetPartDescription(asmModDoc, configName, partDescCustomProperty)
                      myTable1.Text(i + 2, 2) = partDesc
              Next i

              End Sub