Hide Table of Contents

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

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

 

Option Explicit

'-------------------------------------------------------

'

' Preconditions:

'       (1) Open <SolidWorks_install_dir>\samples\tutorial\smartcomponents\pillow_block.sldasm.

'       (2) Interactively collapse all expanded components to more easily see what this macro does.

'       (3) Step through this macro.

'

' Postconditions: None

'

'-------------------------------------------------------

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 & "ShowComponentNames                     : " & swFeatMgr.ShowComponentNames

    Debug.Print vbTab & "ShowComponentDescriptions              : " & swFeatMgr.ShowComponentDescriptions

    Debug.Print vbTab & "ShowComponentConfigurationNames        : " & swFeatMgr.ShowComponentConfigurationNames

    Debug.Print vbTab & "ShowComponentConfigurationDescriptions : " & swFeatMgr.ShowComponentConfigurationDescriptions & vbCrLf

    ' To verify the settings, interactively right-click "pillow_block (NPD-24)" at the

    ' the top of the FeatureManager design tree and point at Tree Display.

    ' Then click anywhere in the graphics area to close the short-cut menu.

    

    ' Interactively examine the FeatureManager design tree to

    ' verify that the names of the components are not shown.

    

    If (swFeatMgr.ShowComponentNames) Then

        swFeatMgr.ShowComponentNames = False

    Else

        swFeatMgr.ShowComponentNames = True

    End If

    ' Show Component Names is now set to TRUE.

    ' Examine the FeatureManager design tree, and

    ' verify that the names of the components are

    ' shown in the FeatureManager design tree.

    

    If (swFeatMgr.ShowComponentDescriptions) Then

        swFeatMgr.ShowComponentDescriptions = False

    Else

        swFeatMgr.ShowComponentDescriptions = True

    End If

    ' Show Component Descriptions is now set to FALSE.

    ' Examine the FeatureManager design tree, and

    ' verify that the descriptions of the components are

    ' not shown.

    

    If (swFeatMgr.ShowComponentConfigurationNames) Then

        swFeatMgr.ShowComponentConfigurationNames = False

    Else

        swFeatMgr.ShowComponentConfigurationNames = True

    End If

    ' Show Component Configuration Names is now 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

    ' Show Component Configuration Descriptions is now 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 & "ShowComponentNames                     : " & swFeatMgr.ShowComponentNames

    Debug.Print vbTab & "ShowComponentDescriptions              : " & swFeatMgr.ShowComponentDescriptions

    Debug.Print vbTab & "ShowComponentConfigurationNames        : " & swFeatMgr.ShowComponentConfigurationNames

    Debug.Print vbTab & "ShowComponentConfigurationDescriptions : " & 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 ShowComponentDescriptions : " & swFeatMgr.ShowComponentDescriptions

    swFeatMgr.ShowComponentDescriptions = False  ' This call does not work because FeatureManager::ShowComponentNames display is set to FALSE

    Debug.Print vbTab & "After call to ShowComponentDescriptions  : " & swFeatMgr.ShowComponentDescriptions & vbCrLf

    

    'Restore original settings

    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 "Restored original settings"

    Debug.Print vbTab & "ShowComponentNames                     : " & swFeatMgr.ShowComponentNames

    Debug.Print vbTab & "ShowComponentDescriptions              : " & swFeatMgr.ShowComponentDescriptions

    Debug.Print vbTab & "ShowComponentConfigurationNames        : " & swFeatMgr.ShowComponentConfigurationNames

    Debug.Print vbTab & "ShowComponentConfigurationDescriptions : " & swFeatMgr.ShowComponentConfigurationDescriptions & vbCrLf

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) 2013 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.