Hide Table of Contents

Hide All Edges in Drawing View Example (VBA)

This example shows how to hide all of the edges in a drawing view.

 

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

'

' Preconditions: The file, foodprocessor.slddrw, exists.

'

' NOTE: The file, foodprocessor.slddrw, is usually

'       installed when you install SolidWorks and is intended to be

'       used with one of the SolidWorks tutorials. The path to this

'       file is installation-specific; however, the path shown in this

'       macro is the typical installation path.

'

'       Do NOT save the drawing document after running this macro

'       because its intended tutorial will not work!

'

' Postcondtions: All edges in Drawing View1 are hidden.

'

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

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swDraw As SldWorks.DrawingDoc

Dim swDocSpecification As SldWorks.DocumentSpecification

Dim swSheet As SldWorks.Sheet

Dim swView As SldWorks.View

Dim swDrawingComponent As SldWorks.DrawingComponent

Dim swComponent As SldWorks.Component2

Dim swEntity As SldWorks.Entity

Dim vEdges As Variant

Dim bRet As Boolean

Dim i As Long

 

Sub main()

 

Set swApp = Application.SldWorks

 

' Open the drawing document

Set swDocSpecification = swApp.GetOpenDocSpec("C:\Program Files\SolidWorks\SolidWorks\samples\tutorial\advdrawings\foodprocessor.slddrw")

Set swModel = swApp.ActiveDoc

If swModel Is Nothing Then

    Set swModel = swApp.OpenDoc7(swDocSpecification)

End If

 

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swDraw = swModel

 

' Get the current sheet

Set swSheet = swDraw.GetCurrentSheet

Debug.Print swSheet.GetName

    

' Select Drawing View1

bRet = swModel.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0#, 0#, 0#, True, 0, Nothing, swSelectOptionDefault): Debug.Assert bRet

Set swView = swModel.SelectionManager.GetSelectedObject6(1, -1)

 

' Print the drawing view name and get the component in the drawing view

Debug.Print swView.GetName2

Set swDrawingComponent = swView.RootDrawingComponent

Set swComponent = swDrawingComponent.Component

 

' Get the component's visible entities in the drawing view

vEdges = swView.GetVisibleEntities(swComponent, swViewEntityType_Edge)

 

' Hide all of the visible edges in the drawing view

For i = 0 To UBound(vEdges)

    Set swEntity = vEdges(i)

    swEntity.Select4 True, Nothing

    swDraw.HideEdge

    Next i

    

swModel.ClearSelection2 True

 

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:   Hide All Edges in Drawing View 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.