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

SclGetActiveLayer

Overview

The 3D Graphics environment that Scl integrates with has viewports that string and triangle data are drawn in. There is always at least one viewport but there may be more than one viewport, depending on the users actions.

There is always one viewport that is known as the active viewport. This viewport is indicated by the title bar of the viewport being highlighted in a different colour to other viewports.

Each viewport has one layer (SWA) that is known as the active layer. This layer is treated as the top layer in a set of overlay plans and it is the only layer that conventional graphics editing commands may operate upon to modify data. Note that this restriction does not exist for Scl scripts as the script author may modify data in any layer that seems appropriate.

It may be necessary for the script author to be able to query and set the active layer depending upon the needs of the problem being solved. Note that different viewports can have different active layers.

The SclGetActiveLayer command returns a handle to the active swa for a specified viewport for use with other Scl commands.

Synopsis

$ViewportHandle SclGetActiveLayer SwaHandle

Description

Return the handle of the active viewport into the ViewportHandle variable.

Arguments

  • ViewportHandle
  • The handle to the viewport for which the active layer is required must be stored in this variable.

  • SwaHandle
  • Passed by reference. The handle of the active layer is assigned to this variable.

Examples

# 
# This example shows how the active layer for the active viewport
# is obtained. A string file is then loaded into this layer and drawn
# 
# get the active layer for the active viewport
SclGetActiveViewport ViewportHandle
$ViewportHandle SclGetActiveLayer SwaHandle
# load the file with error detection and the append option
if {[catch {$SwaHandle SclSwaOpenFile "pit1.str" append}] != 0} {
  puts "Error loading pit1.str"
} else {
  # draw the data 
  $SwaHandle SclGetStrings StringsHandle
  $StringsHandle SclDraw
  # do a zoom all to ensure we can see everything
  SclFunction "ZOOM ALL" {}
}