Hide Table of Contents

Get the Number of Lines in Flat-pattern Drawing View's Boundary-box Sketch (VB.NET)

This example shows how to get the number of lines in a flat-pattern drawing view's boundary-box sketch.

'---------------------------------------------
'
' Preconditions:
' 1. In SolidWorks:
'    a. Open <SolidWorks_install_dir>\samples\design portfolio\sheet_metal_bracket.sldprt.
'    b. Open a new drawing document.
'    c. Select sheet_metal_bracket.sldprt in the View Palette's dropdown list box.
' 2. In the IDE:
'    a. Open the Immediate window.
'    b. Run macro.
'
' Postconditions: The View Palette view's name, drawing view name, and
' number of lines in the boundary-box sketch of the
' drawing view of the flat pattern of the sheet
' metal part are printed to the Immediate window.
'
'---------------------------------------------
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 swView As View
        
Dim swSheet As Sheet
        
Dim swDisplayData As DisplayData
        
Dim sheetProperties As Object
        Dim sheetScale As Double
        Dim paperSize As swDwgPaperSizes_e
        
Dim width As Double
        Dim height As Double
        Dim numViews As Long
        Dim viewName As Object
        Dim viewNames As Object
        Dim viewPaletteName As String = ""
        Dim drawingViewName As String = ""
        Dim status As Boolean


        swModel = swApp.ActiveDoc
        swDrawing = swModel

        
' Get current sheet
        swSheet = swDrawing.GetCurrentSheet
        sheetProperties = swSheet.GetProperties
        sheetScale = sheetProperties(2) / sheetProperties(3)
        paperSize = swSheet.GetSize(width, height)

        
' Get number of views on View Palette
        numViews = 0
        viewNames = swDrawing.GetDrawingPaletteViewNames

        
' Iterate through views on View Palette
        ' When view name equals "Flat pattern", drop
        ' that view in drawing
        If Not (IsNothing(viewNames)) Then
            numViews = (UBound(viewNames) - LBound(viewNames))
            
For Each viewName In viewNames
                viewPaletteName = viewName
                
If (viewPaletteName = "Flat pattern") Then
                    Debug.Print("Dropping View Palette view named: " & viewPaletteName)
                    swView = swDrawing.DropDrawingViewFromPalette2(viewPaletteName, 0.0#, 0.0#, 0.0#)
                    drawingViewName = swView.GetName2
                    Debug.Print(
"Dropped View Palette view into drawing view named: " & drawingViewName)
                
End If
            Next viewName
        
End If

        ' Activate view and get number of lines in
        ' its boundary box sketch
        status = swDrawing.ActivateView(drawingViewName)
        swView = swDrawing.ActiveDrawingView
        swDisplayData = swView.GetSMBoundaryBoxDisplayData
        Debug.Print(
"Number of lines in boundary box of flat-pattern drawing view: " & swDisplayData.GetLineCount)

    
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:   Get the Number of Lines in Flat-pattern Drawing View's Boundary-box Sketch (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) 2012 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.