Hide Table of Contents

Get Weld Bead Symbol Data Example (VBA)

This example shows how to get weld bead symbol data in a drawing.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Open a drawing that contains at least one view with a weld bead
'    annotation.
' 2. Open an Immediate window.
'
' Postconditions: Inspect the Immediate window.
'----------------------------------------------------------------------------

Option Explicit

Sub main()

    Dim swApp                   As SldWorks.SldWorks
    Dim swModel                 As SldWorks.ModelDoc2
    Dim swDraw                  As SldWorks.DrawingDoc
    Dim swSheet                 As SldWorks.Sheet
    Dim swView                  As SldWorks.View
    Dim swWBead                 As SldWorks.WeldBead
    Dim swDispData              As SldWorks.DisplayData
    Dim strFilled As String
    Dim lineCount As Long
    Dim vLine As Variant
    Dim lineColor As Long, lineLineType As Long, lineStyle As Long, lineWeight As Long
    Dim lineX As Double, lineY As Double, lineZ As Double
    Dim polygonCount As Long
    Dim vPolygon As Variant
    Dim polyColor As Long, polyLineType As Long, polyNumPts As Long
    Dim polyX As Double, polyY As Double, polyZ As Double
    Dim index As Long, index2 As Long, arrayIndex As Long

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    Set swSheet = swDraw.GetCurrentSheet
    Set swView = swDraw.GetFirstView

    While Not swView Is Nothing

        Debug.Print swView.Name
        Set swWBead = swView.GetFirstWeldBead()

        While Not swWBead Is Nothing

            Debug.Print "  Weld Bead..."
            If (swWBead.SolidFill = False) Then
                strFilled = "open"
            Else
                strFilled = "solid filled"
            End If

            Set swDispData = swWBead.GetAnnotation().GetDisplayData()
            lineCount = swDispData.GetLineCount
            Debug.Print "    Line count = " & lineCount

            For index = 0 To lineCount - 1
                vLine = swDispData.GetLineAtIndex3(index)
                If Not IsEmpty(vLine) Then
                    lineColor = vLine(0)
                    lineLineType = vLine(1)
                    lineStyle = vLine(2)
                    lineWeight = vLine(3)
                    Debug.Print "      Color = " & lineColor & ", line type = " & lineLineType & ", line style = " & lineStyle & ", line weight = " & lineWeight
                    arrayIndex = 4
                    For index2 = 0 To 1
                        lineX = vLine(arrayIndex)
                        lineY = vLine(arrayIndex + 1)
                        lineZ = vLine(arrayIndex + 2)
                        Debug.Print "       " & index2 & " (" & lineX & ", " & lineY & ", " & lineZ & ")"
                        arrayIndex = arrayIndex + 3
                    Next index2
                End If
            Next index

            Debug.Print "    Polyline count = " & swDispData.GetPolyLineCount
            Debug.Print "    Arc count = " & swDispData.GetArcCount
            polygonCount = swDispData.GetPolygonCount
            Debug.Print "    Polygon count = " & polygonCount

            For index = 0 To polygonCount - 1
                vPolygon = swDispData.GetPolygonAtIndex(index)
                If Not IsEmpty(vPolygon) Then
                    polyColor = vPolygon(0)
                    polyLineType = vPolygon(1)
                    polyNumPts = vPolygon(4)
                    Debug.Print "      Color = " & polyColor & ", line type = " & polyLineType & ", point count = " & polyNumPts & ", " & strFilled
                    arrayIndex = 5

                    For index2 = 0 To polyNumPts - 1
                        polyX = vPolygon(arrayIndex)
                        polyY = vPolygon(arrayIndex + 1)
                        polyZ = vPolygon(arrayIndex + 2)
                        Debug.Print "       " & index2 & " (" & polyX & ", " & polyY & ", " & polyZ & ")"
                        arrayIndex = arrayIndex + 3
                    Next index2
                End If
            Next index
            Set swWBead = swWBead.GetNext()
        Wend
        Set swView = swView.GetNextView
    Wend

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:   Get Weld Bead Symbol Data 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) 2016 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.