Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

design table description 1

Status
Not open for further replies.

SS22

Mechanical
Dec 9, 2004
7
When working with design tables and configurations there appear to be two different descriptions. One is the Component Description which can be edited in the design table, right click properties, click custom properties, and select description from pull down menu. The second I believe is called the Component Configuration Description, right click to select properties.
I like managing the description in the design table, that way I can link its name to dimension values or whatever. The problem is when I am in an assembly drawing the properties tab gives me config name, but not the design table description. I have been using the same meaningless 5 digit part numbers for config name, BOM part number, and drawing number. I can not tell the differences in configs from the name. How can I link the two descriptions or get Solidworks to display the design table description in the assembly drawing environment?

Thanks.
 
Replies continue below

Recommended for you

Gildashard,

I finally came up with a macro to update a configuration description from a design table. Unfortunately, the code is long, required the SolidWorks object variables to be declared using early binding, it would not close gracefully depending on the way the user closed the design table and would not function if the design table was opened inside SolidWorks. It also did not work in SolidWorks 2004. So I threw it out.

My other idea of writing a separate macro and using a custom property set by the design table to populate the configuration description worked too but portability was sacrificed; You always had to make sure you had access to the macro.

In the end, I decided my other idea of opening the design table, adding a configuration, closing the design table then re-opening and re-closing it is the way to go. The code is much simpler, always stays with the design table, does not require the SolidWorks object variables to be declared using early binding (for those of us {like me} who forget to set the correct references), does not care how the user closes the design table and, works if the design table is opened inside SolidWorks or in a separate window. I also have tested it and found it works in SolidWorks 2004 SP4.1 and SP5.0, SolidWorks 2005 SP5.0, and SolidWorks 2006 SP0.0.

I have attached my code below in case you are still interested in it. However, let me make one disclaimer. I have come to believe that no two installations of SolidWorks are the same; even on supposedly identical computers. After reading posts in this forum for the past few years and from the experiences of the 50 some users we have at work, there is no guarantee that the code will work for you or anyone else without some “tweaks”.

Enjoy,

Regg


Code:
'******************************************************************************
'Macro description:
'Creates/changes a Configuration's description from a design table.
'For first time run or new configuration requires design table to
'be opened and closed a second time for update to take place.
'Macro works when design table is opened inside SolidWorks or in a new window.
'
'Install instructions:
'From a SolidWorks model, open a design table in a new window.
'From the Excel menu, select Tools, Macro, Visual Basic Editor.
'In the Visual Basic Editor, double click on ThisWorkbook in the Project Explorer window.
'(If the Project Explorer is not visible, select View, Project Explorer from the menu.)
'(If the ThisWorkbook icon is not visible, expand the Microsoft Excel Objects folder.)
'Paste this code into the code window.
'
'Use instructions:
'This macro assumes row two is the header row which contains the design table parameters
'and row three is start of the configuration data.
'Parameter name for configuration description is $DESCRIPTION (not case sensitive) in hopes
'SolidWorks will sometime honor my enhancement request(s) and add this functionality.  Because
'$DESCRIPTION is not a recognized parameter, leave a blank column between the $DESCRIPTION
'colum and the end of the last column in the design table so SolidWorks will ignore it.
'Type in a description for each configuration in the $DESCRIPTION column.
'Close the design table.  If this is the first time the macro is run, a message will be
'displayed asking you to open and close the design table (A similar message will be displayed
'when a new configuration is added to the table).  Open and close the design table to update
'the configuration descriptions.
'
'******************************************************************************
Option Explicit


Dim swApp As Object
Dim swModel As Object
Dim swConfig As Object

Private Sub Workbook_Open()

    'get SolidWorks object
    Set swApp = GetObject(, "SldWorks.Application")
    
    'get model that design table belongs to in case users changes active document
    '(on open is only time can guarantee calling model will be active)
    Set swModel = swApp.ActiveDoc

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Dim yRow As Long, xCol As Long, FoundNew As Boolean
    Dim ConfigName As String
    
    'find $Description column
    For xCol = 2 To 256
    
        If StrComp(Cells(2, xCol).Value, "$Description", vbTextCompare) = 0 Then Exit For
        
    Next 'xCol
    
    'check if $Description column exists; exit sub if not
    If xCol > 256 Then Exit Sub
    
    'check for SolidWorks object
    '(this code should only run when macro is first pasted into workbook)
    If swApp Is Nothing Then
    
        'display message for first time use of macro
        MsgBox "This design table contains configuration description data" & vbLf & _
               "that may need to be updated in the model.  To preform     " & vbLf & _
               "update, re-open this design table and then close it again.     ", vbOKOnly + vbExclamation, ThisWorkbook.Name
        
        Exit Sub
        
    End If
    
    'update existing configuration descriptions
    For yRow = 3 To 65536  'hopefully table never gets this long
    
        'get configuration name from design table
        ConfigName = Cells(yRow, 1).Value
        
        'check for end of table
        If Trim$(ConfigName) = "" Then
        
            Exit For
            
        Else
        
            'get configuration object
            Set swConfig = swModel.GetConfigurationByName(ConfigName)
            
            'check for new configuration
            If swConfig Is Nothing Then
            
                'set flag
                FoundNew = True
                
            Else
            
                'just update description in model
                swConfig.Description = Cells(yRow, xCol).Value
                
            End If
            
        End If
        
    Next 'yRow
    
    'display re-open message if new configurations found
    If FoundNew Then
        
        MsgBox swModel.GetTitle & ":     " & vbLf & _
               "     This model's design table will create new configurations that     " & vbLf & _
               "     will need to have the configuration description added to them.     " & vbLf & _
               "     To add, re-open design table and then close again.     ", vbOKOnly + vbExclamation, ThisWorkbook.Name
        
    End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor