Hide Table of Contents
GetVisibleDrawingComponents Method (IView)

Gets all of the unobscured drawing components in this drawing view of an assembly drawing.

.NET Syntax

Visual Basic (Declaration) 
Function GetVisibleDrawingComponents() As System.Object
Visual Basic (Usage) 
Dim instance As IView
Dim value As System.Object
value = instance.GetVisibleDrawingComponents()
System.object GetVisibleDrawingComponents()
System.Object^ GetVisibleDrawingComponents(); 

Return Value

Visible IDrawingComponents in this drawing view



' Preconditions:
' 1. Open a drawing document of an assembly that contains Drawing View1
'     with one or more visible drawing components.
' 2. Open the Immediate window.
' Postconditions:
' 1. Gets the visible drawing components and their names.
' 2. Examine the Immediate window.
Option Explicit

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim swView As SldWorks.View
Dim swDrComp As SldWorks.DrawingComponent
Dim swComp As Component2
Dim vComps As Variant
Dim vBodies As Variant
Dim boolstatus As Boolean
Dim itr As Long

Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swModelDocExt = swModel.Extension
    Set swSelMgr = swModel.SelectionManager
    boolstatus = swModel.ActivateView("Drawing View1")
    boolstatus = swModelDocExt.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, 0)
    Set swView = swSelMgr.GetSelectedObject6(1, -1)
    swModel.ClearSelection2 True
    'Get all visible components in Drawing View1
    vComps = swView.GetVisibleDrawingComponents
    'Print the number of visible components
    Debug.Print "Number of components:"
    Debug.Print "  " & UBound(vComps) + 1
    'Iterate through the visible components and print each one's name
    Debug.Print "Names of drawing view components and the referenced assembly component names:"
    For itr = 0 To UBound(vComps)
        Debug.Print ""
        Set swDrComp = vComps(itr)
        Debug.Print "  " & swDrComp.Name
        Set swComp = swDrComp.Component
        'Print the referenced assembly component name
        If Not swComp Is Nothing Then
             Debug.Print "    " & swComp.Name2
             Call swComp.GetBodies3(swAllBodies, vBodies)
        End If
    Next itr
End Sub



Visible components are components not completely obscured by other components in the view.

After calling this method to retrieve the visible drawing components, use IDrawingComponent::Component to get a component object that fully supports all of the IComponent2 methods and properties.


See Also


SOLIDWORKS 2021 FCS, Revision Number 29

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

Subject:   Feedback on Help Topics
Page:   GetVisibleDrawingComponents Method (IView)
*   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:


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

Web Help Content Version: API Help (English only) 2021 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.