Hide Table of Contents

Get Name of Drawing Zone Example (VBA)

This example shows how to get the name of a drawing zone for the specified x and y coordinates.

'-----------------------------------------------------------------------------
' Preconditions:
' 1. Verify that public_documents\tutorial\api\assem20.slddrw exists.
' 2. Open the Immediate Window.
'
' Postconditions.
' 1. Opens the specified drawing.
' 2. Creates a new sheet named Test with four zones.
' 3. Gets the name of the drawing zone for the specified
'    x and y coordinates.
' 4. Examine the Immediate window.
'
' NOTE: Because the drawing is used elsewhere, do not save changes.
'---------------------------------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim swModel As SldWorks.ModelDoc2
Dim fileName As String
Dim status As Boolean
Dim errors As Long
Dim warnings As Long
Dim x As Double
Dim y As Double
Sub main()
    Set swApp = Application.SldWorks
    fileName = "C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2017\tutorial\api\assem20.slddrw"
    Set swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocDRAWING, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)
    Set swDraw = swModel    
    Set swSheet = swDraw.GetCurrentSheet
    swDraw.ActivateSheet (swSheet.GetName)    
    ' Create sheet Test with four zones
    status = swDraw.NewSheet4("Test", swDwgPaperSizes_e.swDwgPaperAsize, swDwgTemplates_e.swDwgTemplateAsize, 1, 1, True, "", 0, 0, "", 0.5, 0.5, 0.5, 0.5, 2, 2)       
    swModel.ForceRebuild3 True    
    Set swSheet = swDraw.GetCurrentSheet
    swDraw.ActivateSheet (swSheet.GetName) 
    ' Set x and y coordinates on the sheet
    ' whose drawing zone name to get
    x = 0.201705822198041
    y = 2.42677238302502E-02    
    ' Get the name of the drawing zone for x and y
    Dim drawingZoneName As String
    drawingZoneName = swSheet.GetDrawingZone(x, y)
    Debug.Print "Drawing zone name for specified x and y coordinates: " & drawingZoneName    
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 Name of Drawing Zone 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) 2017 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.