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:  Drawing document is open in standard 3D view.

'

' Postconditions: Projection switches to third angle

'                 from first angle or vice versa.

'

'-------------------------------------------

Option Explicit

'  Drawing Paper Sizes

Public Enum swDwgPaperSizes_e

    swDwgPaperAsize = 0

    swDwgPaperAsizeVertical = 1

    swDwgPaperBsize = 2

    swDwgPaperCsize = 3

    swDwgPaperDsize = 4

    swDwgPaperEsize = 5

    swDwgPaperA4size = 6

    swDwgPaperA4sizeVertical = 7

    swDwgPaperA3size = 8

    swDwgPaperA2size = 9

    swDwgPaperA1size = 10

    swDwgPaperA0size = 11

    swDwgPapersUserDefined = 12

End Enum

'  Drawing Templates

Public Enum swDwgTemplates_e

    swDwgTemplateAsize = 0

    swDwgTemplateAsizeVertical = 1

    swDwgTemplateBsize = 2

    swDwgTemplateCsize = 3

    swDwgTemplateDsize = 4

    swDwgTemplateEsize = 5

    swDwgTemplateA4size = 6

    swDwgTemplateA4sizeVertical = 7

    swDwgTemplateA3size = 8

    swDwgTemplateA2size = 9

    swDwgTemplateA1size = 10

    swDwgTemplateA0size = 11

    swDwgTemplateCustom = 12

    swDwgTemplateNone = 13

End Enum

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)

    

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) 2013 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.