Hide Table of Contents

Get Tangent Edges of Bendlines Example (VBA)

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 of a sheet metal part
'    that has a flat-pattern view with
'    bend lines with tangent edges.
' 2. Open the Immediate window.
'
' Preconditions: Examine the Immediate window.
'---------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDrawing As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim swView As SldWorks.View
Dim nbrBendlines As Long
Dim BendlinesArr As Variant
Dim nbrRelatedTangentEdges As Long
Dim RelatedTangentEdgesArr As Variant
Dim i As Long
Dim swSketchSegment As SldWorks.SketchSegment
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDrawing = swModel    
    ' Get drawing sheet
    Set 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
    Set swView = swDrawing.GetFirstView
    Debug.Print "    First drawing view is the current drawing sheet, so..."    
    ' Get first drawing view on drawing sheet
    Set 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)
                    Set 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
        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 Tangent Edges of Bendlines 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) 2021 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.