Hide Table of Contents

Get Tangent Edges of Bendlines (VB.NET)

This example shows how to get each bendline's visible tangent edges in a flat-pattern view in a drawing of a sheet metal part.


' Preconditions:

' 1. Open a SOLIDWORKS drawing that has a flat-pattern

'    view of a sheet metal part that has bend lines

'    with tangent edges.

' 2. Run the macro and examine the Immediate window

'    and the drawing document to verify the results.


' Postconditions: None


Imports SolidWorks.Interop.sldworks

Imports SolidWorks.Interop.swconst

Imports System

Imports System.Diagnostics


Partial Class SolidWorksMacro


    Public Sub main()


        Dim swModel As ModelDoc2

        Dim swDrawing As DrawingDoc

        Dim swSheet As Sheet

        Dim swView As View

        Dim nbrBendlines As Long

        Dim BendlinesArr As Object

        Dim nbrRelatedTangentEdges As Long

        Dim RelatedTangentEdgesArr As Object

        Dim i As Long

        Dim swSketchSegment as SketchSegment


        swModel = swApp.ActiveDoc

        swDrawing = swModel


        ' Get drawing sheet

        swSheet = swDrawing.GetCurrentSheet

        ' Get name of drawing sheet

        Debug.Print("Name of drawing sheet: " & swSheet.GetName)

        ' Get number of views on drawing sheet

        Debug.Print("  Number of drawing views on drawing sheet: " & swDrawing.GetViewCount)

        ' First view is the current drawing sheet

        swView = swDrawing.GetFirstView

        Debug.Print("    First drawing view is the current drawing sheet, so...")

        ' Get first drawing view on drawing sheet

        swView = swView.GetNextView

        While Not swView Is Nothing

            Debug.Print("        Get next drawing view on drawing sheet...")

            ' Get first true drawing view on current drawing sheet

            Debug.Print("           Is this drawing view a flat-pattern view? " & swView.IsFlatPatternView)

            ' If this drawing view is a flat pattern view, then

            ' get its bendlines and their related tangent edges

            If swView.IsFlatPatternView Then

                ' Get number of bendlines in the drawing view

                nbrBendlines = swView.GetBendLineCount

                Debug.Print("            Number of bendlines in this drawing view: " & nbrBendlines)

                If (nbrBendlines > 0) Then

                    BendlinesArr = swView.GetBendLines                        

                    For i = 0 To UBound(BendlinesArr)

                    swSketchSegment = BendlinesArr(i)

                    Debug.Print("             Is bend line " & i & " really a bend line? " & swSketchSegment.IsBendLine)

                        ' Get the number of tangent lines related to

                        ' the bendline

                        nbrRelatedTangentEdges = swView.GetRelatedTangentEdgeCount(BendlinesArr(i))

                        Debug.Print("              Number of tangent edges for Bendline " & i & ": " & nbrRelatedTangentEdges)

                        ' Get the tangent lines related to the bendline

                        If (nbrRelatedTangentEdges > 0) Then

                            RelatedTangentEdgesArr = swView.GetRelatedTangentEdges(BendlinesArr(i))

                            nbrRelatedTangentEdges = nbrRelatedTangentEdges - 1

                        End If

                    Next i

                End If

            End If

            ' Get next drawing view

            swView = swView.GetNextView

        End While


    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

Subject:   Feedback on Help Topics
Page:   Get Tangent Edges of Bendlines (VB.NET)
*   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:


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

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.