Hide Table of Contents

Display Vertices Example (VBA)

This example shows how to display vertices.

 

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

'

' Preconditions:

'          (1) Part document is open and has one or more solid bodies.

'          (2) Each solid body does not contain any circular edges.

'

' Postconditions: All vertices are highlighted.

'

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

Option Explicit

 

Sub main()

 

Dim swApp As SldWorks.SldWorks

Dim Part As SldWorks.PartDoc

Dim Body As SldWorks.Body2

Dim Edge As SldWorks.Edge

Dim Vertex As SldWorks.Vertex

Dim Bodyarr As Variant

Dim vbody As Variant

Dim Edgearr As Variant

Dim idx As Long

Dim vobj As Variant

Dim crgb As Long

 

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

 

Bodyarr = Part.GetBodies2(swSolidBody, True)

For Each vbody In Bodyarr

    Set Body = vbody

    Edgearr = Body.GetEdges

    idx = 0

    For Each vobj In Edgearr

        Set Edge = vobj

        Set Vertex = Edge.GetStartVertex

        Select Case CInt(idx Mod 8)

        Case 0

           crgb = RGB(0, 0, 0)

        Case 1

           crgb = RGB(0, 0, 255)

        Case 2

           crgb = RGB(0, 255, 0)

        Case 3

           crgb = RGB(0, 255, 255)

        Case 4

           crgb = RGB(255, 0, 0)

        Case 5

           crgb = RGB(255, 0, 255)

        Case 6

           crgb = RGB(255, 255, 0)

        Case 7

           crgb = RGB(255, 255, 255)

    End Select

    idx = idx + 1

    Vertex.Display Part, crgb, 1, True

   Next   

Next

 

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:   Display Vertices 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) 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.