Hide Table of Contents

Get Number of Polylines in Shaded Mode Drawing View Example (VBA)

This example shows how to get the number of polylines in a drawing view displayed in Shaded and Wireframe modes.

' Preconditions:
' 1. Open public_documents\introsw\bolt-assembly.slddrw.
' 2. Change Drawing View4 to Shaded mode (click
'    Drawing View4 in the drawing, click Shaded
'    in Display Style in the PropertyManager page, and
'    click OK.
' 3. Open the Immediate window.
' Postconditions:
' 1. Gets the number of polylines in Shaded mode.
' 2. Switches mode to Wireframe and gets number of polylines
'    in Wireframe mode.
' 3. Switches mode back to Shaded.
' 4. Examine the Immediate window.
' NOTE: Because the drawing is used elsewhere, do not save
' changes
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swDrawDoc As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim retval As Long
Dim boolstatus As Boolean
Dim nCountShaded As Long
Dim nCount_WireFrame As Long
Dim retval2 As Boolean
Sub main()
    Set swApp = Application.SldWorks
    Set swDrawDoc = swApp.ActiveDoc
    swDrawDoc.ClearSelection2 True
   ' Select Drawing View4
    boolstatus = swDrawDoc.Extension.SelectByID2("Drawing View4", "DRAWINGVIEW", 0, 0, 0, False, 0, Nothing, swSelectOptionDefault)
    Set swView = swDrawDoc.SelectionManager.GetSelectedObject6(1, -1)
    ' Get display mode for Drawing View4
    Set swView = swDrawDoc.ActiveDrawingView
    retval = swView.GetDisplayMode2
    Debug.Print "Drawing view in what display mode"
    Debug.Print "  swDisplayMode_e: swWIREFRAME = 0, swHIDDEN_GREYED = 1, swHIDDEN = 2, swSHADED = 3: " & retval
    ' Get number of polylines in drawing view in Shaded mode
    swView.GetPolyLineCount5 swCrossHatchFilter_e.swCrossHatchExclude, nCountShaded
    Debug.Print "Number of polylines in drawing view in Shaded mode = " & nCountShaded
    ' Switch to Wireframe mode because you can get number of polylines in Wireframe mode
    retval2 = swView.SetDisplayMode3(False, swDisplayMode_e.swWIREFRAME, False, False)
    Debug.Print "Display mode changed to Wireframe: " & retval2
    ' Get number of polylines in Wireframe mode
    swView.GetPolyLineCount5 swCrossHatchFilter_e.swCrossHatchExclude, nCount_WireFrame
    Debug.Print "Number of polylines in WireFrame = " & nCount_WireFrame
    ' Switch back to Shaded mode
    retval2 = swView.SetDisplayMode3(False, swDisplayMode_e.swSHADED, False, False)
    Debug.Print "Display mode changed back to Shaded: " & retval2
    swDrawDoc.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

Subject:   Feedback on Help Topics
Page:   Get Number of Polylines in Shaded Mode Drawing View Example (VBA)
*   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) 2017 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.