You are here: Surpac Concepts > Macros > SCL > Viewport and Layers > SclViewport > SclViewport getById
GEOVIA Surpac

SclViewport getById

Overview

You use this function to determine the reference handle for a viewport using its viewport Id.

Synopsis

SclViewport getById <id>

Description

Get the reference handle to a viewport by specifying the viewport Id, for example, 00001. This function provides an alternative to iterating over all viewports to locate the one of interest.

A reference handle to the viewport is returned. This handle is used to access the available set of viewport functions and the SclSetValueByName and SclGetValueByName attribute commands. If the specified viewport Id is not found, you will see an error message.

Arguments

  • getById
  • A literal string to identify the function.

  • <id>
  • The Id of the viewport to find.

Returns

If successful, this command returns a reference handle to the viewport. If the viewport Id cannot be found, an error message is returned.

Examples

# Get a viewport handle by its Id
set vp1 [SclViewport getActive]
set vp2 [SclViewport split vertical 30 $vp1 ]
set vp3 [SclViewport split horizontal 50 $vp2 ]
if {[catch {SclViewport getById "00003"} myVP]} then {
  puts "No such viewport"
} else {
  puts "Found [$myVP SclGetValueByName title]"
}