Hide Table of Contents

Get Virtual Sharp Witness Line Data Example (VB.NET)

This example shows how to get the geometry data of all of the virtual sharp witness lines in a drawing.

'----------------------------------------------------------------------------
' Preconditions: Open the drawing of a part that contains one or more
' virtual sharps with witness lines.
'
' Postconditions: Inspect the Immediate Window for virtual sharp witness line
' geometry data.
' ---------------------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics

Partial Class SolidWorksMacro

    
Dim swModel As ModelDoc2
    
Dim pDrawing As DrawingDoc
    
Dim swView As View
    
Dim Count As Long
    Dim size As Long
    Dim entitiesData As Object
    Dim index As Long
    Dim entityCounts As Long
    Dim entType As Long
    Dim linesCount As Long
    Dim arcsCount As Long
    Dim VirtualSharpNum As Long
    Dim j As Long

    Sub main()

        swModel = swApp.ActiveDoc
        pDrawing = swModel

        swView = pDrawing.GetFirstView
        
While Not swView Is Nothing

            Debug.Print("Drawing view: " & swView.Name)

            Count = swView.GetWitnessEntitiesCount(size)

            Debug.Print(
"  Number of virtual sharp witness lines: " & Count)
            Debug.Print(
"  Size of virtual sharp witness line geometry data array: " & size)

            
If (Count > 0) Then
                entitiesData = swView.GetWitnessGeomInfo

                
If Not IsNothing(entitiesData) Then
                    VirtualSharpNum = 0
                    index = 0
                    entityCounts = 0
                    
While entityCounts < Count - 1
                        Debug.Print(
"    Virtual sharp " & VirtualSharpNum)
                        Debug.Print(
"      Color: " & entitiesData(index))
                        index = index + 1
                        Debug.Print(
"      Line style (swLineStyles_e): " & entitiesData(index))
                        index = index + 1
                        Debug.Print(
"      Line weight: (swLineWeights_e): " & entitiesData(index))
                        index = index + 1
                        Debug.Print(
"      Layer ID: " & entitiesData(index))
                        index = index + 1
                        Debug.Print(
"      Layer override (swLayerOverride_e):" & entitiesData(index))
                        index = index + 1

                        entType = entitiesData(index)
                        Debug.Print(
"      Entity type: " & entType)
                        
If (entType = 0) Then
                            index = index + 1
                            linesCount = entitiesData(index)
                            Debug.Print(
"      Line count: " & linesCount)
                            index = index + 1

                            
For j = 0 To linesCount - 1
                                Debug.Print(
"        Start: x =" & entitiesData(index) & " y =" & entitiesData(index + 1) & " z =" & entitiesData(index + 2))
                                index = index + 3
                                Debug.Print(
"        End:   x =" & entitiesData(index) & " y =" & entitiesData(index + 1) & " z =" & entitiesData(index + 2))
                                index = index + 3
                            
Next j
                            entityCounts = entityCounts + linesCount
                        
End If

                        entType = entitiesData(index)
                        Debug.Print(
"      Entity type: " & entType)
                        
If (entType = 1) Then
                            index = index + 1
                            arcsCount = entitiesData(index)
                            Debug.Print(
"      Arc count: " & arcsCount)
                            index = index + 1

                            
For j = 0 To arcsCount - 1
                                Debug.Print(
"        Start:  x =" & entitiesData(index) & " y =" & entitiesData(index + 1) & " z =" & entitiesData(index + 2))
                                index = index + 3
                                Debug.Print(
"        End:    x =" & entitiesData(index) & " y =" & entitiesData(index + 1) & " z =" & entitiesData(index + 2))
                                index = index + 3
                                Debug.Print(
"        Center: x =" & entitiesData(index) & " y =" & entitiesData(index + 1) & " z =" & entitiesData(index + 2))
                                index = index + 3
                                Debug.Print(
"        Normal: x =" & entitiesData(index) & " y =" & entitiesData(index + 1) & " z =" & entitiesData(index + 2))
                                index = index + 3
                            
Next j

                            entityCounts = entityCounts + arcsCount

                        
End If

                        VirtualSharpNum = VirtualSharpNum + 1

                    
End While

                End If
            End If

            swView = swView.GetNextView

        
End While

    End Sub

  
    
Public swApp As SldWorks


End Class

 

 



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:   Get Virtual Sharp Witness Line Data Example (VB.NET)
*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) 2020 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.