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.
Thank you for your suggestion. As you said it is working for BOM, but this method is not working to collect the configurations list and corresponding configuration specific custom properties of the part/assembly.
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!
Thank you very much for your suggestion, long back I had used Solidworks not that familiar much with present versions. Can you please help me to understand by adding some images please. Sorry, I am expecting too much from you guys... as I am poor in Solidworks .
I'm not really sure if people will help you if you don't show some effort. You can try SolidWorks's macro examples to give you a head start. Copy and paste code and try to work it out yourself first. Hopefully when you're stuck at certain step, you can post a question
Best of luck !
Some how I worked out... just check below code.
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"
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
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
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
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
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
Your code works OK.
You can remove following lines:
If columnCount < 3 Then
MsgBox "Invalid table column"
You are passing the value '3' in 'Set myTable1 = InsertTable1(configCount + 2, 3)', the value of columnCount will always be '3' and therefore 'If columnCount < 3' will always be false.
Other thing I noticed that your code works for Assembly Document only (Referenced model from the drawing view), as per your initial post, I believe you want the codes to work for both Part and Assembly documents.
There are few other things that can be tidy up. Let me know if you are interested.
Thank you very much for your feedback. I am struggling to make it work for Parts also but I am not getting it as I am not good in coding, if possible, please help me on this.
Try attached revised macro. I have modified the macro to work for both part and assembly document. You need to select the drawing view before running the macro.
Just put a break point in the code and execute the macro line by line to see how it works. If something doesn't make sense, just let me know.