Hide Table of Contents

Show Components and Component Configurations Names and Descriptions Example (VBA)

This example shows how to show and hide component and configuration names and descriptions in the FeatureManager design tree.

'-------------------------------------------------------
' Preconditions:
' 1. Open public_documents\samples\tutorial\smartcomponents\pillow_block.sldasm.
' 2. Collapse the bearing<1> component.
' 3. Widen the FeatureManager design tree.
' 4. Open the Immediate window.
'
' Postconditions:
' 1. At each Stop statement, read the comments and press F5
'    to continue.
' 2. Examine the Immediate window.
'-------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim SelMgr As SldWorks.SelectionMgr
Dim swFeatMgr As SldWorks.FeatureManager
Sub main()
    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
    Set SelMgr = Part.SelectionManager
    Set swFeatMgr = Part.FeatureManager
    
    Debug.Print "Tree Display settings upon opening document"
    Debug.Print vbTab & "Show Component Names                      : " & swFeatMgr.ShowComponentNames
    Debug.Print vbTab & "Show Component Descriptions               : " & swFeatMgr.ShowComponentDescriptions
    Debug.Print vbTab & "Show Component Configuration Names        : " & swFeatMgr.ShowComponentConfigurationNames
    Debug.Print vbTab & "Show Component Configuration Descriptions : " & swFeatMgr.ShowComponentConfigurationDescriptions & vbCrLf
    Stop
    ' To verify the settings, right-click pillow_block at the
    ' the top of the FeatureManager design tree and point at Tree Display
    ' Compare the settings with the output in the Immediate window
    ' Then click anywhere in the graphics area to close the short-cut menu
    ' Examine the FeatureManager design tree to
    ' verify that the names of the components are not shown
    If (swFeatMgr.ShowComponentDescriptions) Then
        swFeatMgr.ShowComponentDescriptions = False
    Else
        swFeatMgr.ShowComponentDescriptions = True
    End If
    Stop
    ' Show Component Descriptions is set to true    
    ' Examine the FeatureManager design tree, and
    ' verify that the descriptions of the components
    ' are shown
    If (swFeatMgr.ShowComponentConfigurationNames) Then
        swFeatMgr.ShowComponentConfigurationNames = False
    Else
        swFeatMgr.ShowComponentConfigurationNames = True
    End If    
    Stop
    ' Show Component Configuration Names is set to false    
    ' Examine the FeatureManager design tree, and
    ' verify that the names of the configurations are
    ' not shown
    If (swFeatMgr.ShowComponentConfigurationDescriptions) Then
        swFeatMgr.ShowComponentConfigurationDescriptions = False
    Else
        swFeatMgr.ShowComponentConfigurationDescriptions = True
    End If    
    Stop
    ' Show Component Configuration Descriptions is set to true    
    ' Examine the FeatureManager design tree, and
    ' verify that the descriptions of the configurations
    ' are shown
    Debug.Print "Display modified settings"
    Debug.Print vbTab & "Show Component Names                      : " & swFeatMgr.ShowComponentNames
    Debug.Print vbTab & "Show Component Descriptions               : " & swFeatMgr.ShowComponentDescriptions
    Debug.Print vbTab & "Show Component Configuration Names        : " & swFeatMgr.ShowComponentConfigurationNames
    Debug.Print vbTab & "Show Component Configuration Descriptions : " & swFeatMgr.ShowComponentConfigurationDescriptions & vbCrLf
    ' FeatureManager::ShowComponentNames and FeatureManager::ShowComponentDescriptions
    ' cannot both be set to false
    swFeatMgr.ShowComponentDescriptions = True
    If (swFeatMgr.ShowComponentNames) Then
        swFeatMgr.ShowComponentNames = False
    End If
    
    Debug.Print "Try to set FeatureManager::ShowComponentDescriptions to false while FetureManager::ShowComponentNames is false"
    Debug.Print vbTab & "Before call to Show Component Descriptions : " & swFeatMgr.ShowComponentDescriptions
    swFeatMgr.ShowComponentDescriptions = False  ' This call does not work because FeatureManager::ShowComponentNames display is set to false
    Debug.Print vbTab & "After call to Show Component Descriptions  : " & swFeatMgr.ShowComponentDescriptions & vbCrLf
    ' Restore original settings
    If (swFeatMgr.ShowComponentDescriptions) Then
        swFeatMgr.ShowComponentNames = True
        swFeatMgr.ShowComponentDescriptions = False
    Else
        swFeatMgr.ShowComponentNames = True
    End If
    
    If (swFeatMgr.ShowComponentConfigurationNames) Then
        swFeatMgr.ShowComponentConfigurationNames = False
    Else
        swFeatMgr.ShowComponentConfigurationNames = True
    End If
    If (swFeatMgr.ShowComponentConfigurationDescriptions) Then
        swFeatMgr.ShowComponentConfigurationDescriptions = False
    Else
        swFeatMgr.ShowComponentConfigurationDescriptions = True
    End If
    Debug.Print "Original settings restored"
    Debug.Print vbTab & "Show Component Names                      : " & swFeatMgr.ShowComponentNames
    Debug.Print vbTab & "Show Component Descriptions               : " & swFeatMgr.ShowComponentDescriptions
    Debug.Print vbTab & "Show Component Configuration Names        : " & swFeatMgr.ShowComponentConfigurationNames
    Debug.Print vbTab & "Show Component Configuration Descriptions : " & swFeatMgr.ShowComponentConfigurationDescriptions & vbCrLf
    
    Debug.Print "Macro done executing!"
End Sub


Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Show Components and Component Configurations Names and Descriptions Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2022 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.