Hide Table of Contents

Analyze Text and Geometry in GTol Symbol Example (VBA)

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 whether <"GTOL-SPROF"> is bound.
' 3. Gets the number of lines, arcs, circles, text strings,
'    and triangles in <"GTOL-SPROF">.
' 4. Gets the number of point coordinates in the
'    lines in <"GTOL-SPROF">.
' 5. Gets the x,y,z coordinates for the first and second points
'    of each line in <"GTOL-SPROF">.
' 6. Gets the arc information for <"GTOL-SPROF">.
' 7. Examine the Immediate window.
'---------------------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swEnvironment As SldWorks.Environment
Dim fileName As String
Dim errors As Long
Dim warnings As Long
Dim nbrSymbols As Variant
Dim lineSymbols As Variant
Dim arcInfo As Variant
Dim nbrLineCoordinates As Long
Dim i As Long

Sub main()
    Set swApp = Application.SldWorks

    fileName = "C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2018\samples\tutorial\tolanalyst\minimum_clearance\top_plate.sldprt"
    Set swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocPART, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)
    Set swEnvironment = swApp.GetEnvironment
   

    Debug.Print "GTOL library - Surface Profile symbol name:"

    'Get whether <"GTOL-SPROF"> is bound
    Dim bound As Boolean
    swEnvironment.GetIsBound "<GTOL-SPROF>", bound
    Debug.Print (" Bound? " & bound) 
    Debug.Print ("")   

    '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))
    Debug.Print ""
    Debug.Print ("Number of lines: " & nbrSymbols(0))
   

    'Get the 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
    Debug.Print ""
    Debug.Print ("Number of arcs: " & nbrSymbols(1))
   

    'Get 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



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 (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) 2018 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.