Hide Table of Contents

Analyze Text and Geometry in GTol Symbol Example (VB.NET)

This example shows how to analyze the text and geometry in a GTol symbol.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Verify that the specified part document exists.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. Opens the specified part document.
' 2. Gets the number of lines, arcs, circles, text strings,
'    and triangles in <"GTOL-SPROF">.
' 3. Prints the number of lines in <"GTOL-SPROF">
'    to the Immediate window.
' 4. Gets and prints the number of point coordinates in the
'    lines in <"GTOL-SPROF"> to the Immediate window.
' 5. Gets and prints the x,y,z coordinates for the first and second points
'    of each line in <"GTOL-SPROF"> to the Immediate window.
' 6. Gets and prints the arc information for <"GTOL-SPROF"> to the
'    Immediate window.
' 7. Examine the Immediate window.
'---------------------------------------------------------------------------
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 swEnvironment As SolidWorks.Interop.sldworks.Environment
    Dim fileName As String
    Dim errors As Integer
    Dim warnings As Integer
    Dim nbrSymbols As Object
    Dim lineSymbols As Object
    Dim arcInfo As Object
    Dim nbrLineCoordinates As Integer
    Dim i As Integer
 
    Sub main()
 
 
        fileName = "C:\Program Files\SolidWorks Corp\SolidWorks\samples\tutorial\tolanalyst\minimum_clearance\top_plate.sldprt"
        swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocPART, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)
        swEnvironment = swApp.GetEnvironment
 
        Debug.Print("GTOL library - Surface Profile symbol name:")
 
        'Get the number of lines, arcs, circles, text strings,
        'and triangles in <"GTOL-SPROF">
        nbrSymbols = swEnvironment.GetSymEdgeCounts("<GTOL-SPROF>")
        Debug.Print(" Line count:     " & nbrSymbols(0))
        Debug.Print(" Arc count:      " & nbrSymbols(1))
        Debug.Print(" Circle count:   " & nbrSymbols(2))
        Debug.Print(" Text count:     " & nbrSymbols(3))
        Debug.Print(" Triangle count: " & nbrSymbols(4))
 
        'Print the number of lines in <"GTOL-SPROF">
        'to the Immediate window.
        Debug.Print("")
        Debug.Print("Number of lines: " & nbrSymbols(0))
 
        'Get and print x,y,z coordinates for the first
        'and second points of each line
        lineSymbols = swEnvironment.GetSymLines("<GTOL-SPROF>")
        nbrLineCoordinates = UBound(lineSymbols)
        Debug.Print("  Number of point coordinates: " & nbrLineCoordinates + 1)
        Debug.Print("     Point coordinates:")
        Debug.Print("       (Line 1's x,y,z coordinates for first and second points,")
        Debug.Print("        Line 2's x,y,z coordinates for first and second points,")
        Debug.Print("        ...)")
        For i = 0 To nbrLineCoordinates
            Debug.Print("        " & lineSymbols(i))
        Next i
 
        'Print the number of arcs in <"GTOL-SPROF">
        'to the Immediate window.
        Debug.Print("")
        Debug.Print("Number of arcs: " & nbrSymbols(1))
 
        'Get and print the x,y,z coordinates of the center, start, and end points of each arc,
        'whether the arc is filled, and whether a chord joining the start and end points of the arc is drawn
        Debug.Print("  x,y,z coordinates of the center, start, and end points of each arc,")
        Debug.Print("  whether the arc is filled (1 = true, 0 = false),")
        Debug.Print("  and whether a chord is displayed for each arc (1 = true, 0 = false):")
        arcInfo = swEnvironment.GetSymArcs2("<GTOL-SPROF>")
        For i = 0 To UBound(arcInfo)
            Debug.Print("        " & arcInfo(i))
        Next i
 
    End Sub
 
 
 
    ''' <summary>
    ''' The SldWorks swApp variable is pre-assigned for you.
    ''' </summary>
    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:   Analyze Text and Geometry in GTol Symbol 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) 2015 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.