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() |
C# | |
---|
System.object GetVisibleDrawingComponents() |
C++/CLI | |
---|
System.Object^ GetVisibleDrawingComponents(); |
Return Value
Visible
IDrawingComponents in this drawing view
Example
'VBA
'--------------------------------------------------------------------
' 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
Example
Remarks
See Also
Availability
SOLIDWORKS 2021 FCS, Revision Number 29