Hide Table of Contents

Get and Set Sheet Properties Example (VBA)

This example shows how to get the sheet properties and how to switch projection.

'----------------------------------------------------------------------
' Preconditions:
' 1. Open public_documents\samples\tutorial\api\block1.sldprt and make
'    a drawing with front, side, and top views.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. Switches projection to third angle from first angle or vice versa.
' 2. Examine the graphics area and Immediate window.
'
' NOTE: Because the part is used elsewhere, do not save changes.
'----------------------------------------------------------------------
Option Explicit
Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swDraw As SldWorks.DrawingDoc
    Dim swSheet As SldWorks.Sheet
    Dim vSheetProps As Variant
    Dim bFirstAng As Boolean
    Dim bRet As Boolean
    Set swApp = Application.SldWorks
    Set swDraw = swApp.ActiveDoc
    Set swSheet = swDraw.GetCurrentSheet
    ' Get current sheet properties
    vSheetProps = swSheet.GetProperties
    ' Current sheet properties
    Debug.Print "Name = " + swSheet.GetName
    Debug.Print "  TemplateName              = " & swSheet.GetTemplateName
    Debug.Print "  PaperSize                 = " & vSheetProps(0)
    Debug.Print "  TemplateIn                = " & vSheetProps(1)
    Debug.Print "  Scale1                    = " & vSheetProps(2)
    Debug.Print "  scale2                    = " & vSheetProps(3)
    Debug.Print "  FirstAngle                = " & vSheetProps(4)
    Debug.Print "  Width                     = " & vSheetProps(5)
    Debug.Print "  Height                    = " & vSheetProps(6)
    ' Switch projection property
    bFirstAng = vSheetProps(4)
    vSheetProps(4) = Not bFirstAng
    ' Apply updated sheet properties
    swSheet.SetProperties vSheetProps(0), vSheetProps(1), vSheetProps(2), vSheetProps(3), vSheetProps(4), vSheetProps(5), vSheetProps(6)
    ' Current projection property
    Debug.Print " "
    Debug.Print "  New FirstAngle setting    = " & vSheetProps(4)
    
    swDraw.EditRebuild
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 and Set Sheet Properties 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.