You are on page 1of 9

e

h
t
in

Volume 24, Number 9, September 2008

Views into Software Development

Introducing the New Model Calculation


Script, cp-modelCalcTool.pyc
New to the suite of MineSight Compass
(MSCompass) procedures is a powerful new script,
cp-modelCalcTool.pyc. This script can be used to
process a Python user-calculation script for 3D block
model item values on a block-by-block basis and the
results can be stored back to the model.
cp-modelCalcTool.pyc is executed either from
MSCompass or from the command line in a dos/
cmd prompt window. In MSCompass, this script
is found on the menu in the 3D Modeling Group,
under Calculation Operation type. Or, on the Menu
tab dialog in MSCompass, enter the name of the
script (under Specify procedure) and then click the
Run button.

To run this script from the command line, use


the syntax shown below. Use the -h (help) option to
display the command line help for this script.
Command Line Arguments:
---------------------none

Window pops up asking for prj path,


then cp-ModelCalcTool panel is displayed

-p

absolute path to prj

-r

name of response set

-h

usage or help

Examples:
cp-modelCalcTool.pyc -p D:\modelCalc\geo.prj -r default
cp-modelCalcTool.pyc -p D:\modelCalc\geo.prj -r myresponses

Since cp-modelCalcTool.pyc is an MSCompass


script, it can also be used in a MultiRun. Choose this
script as the Procedure, then setup the MultiRun as
with any other procedure. Two examples showing
how to use this script in a Multirun are discussed later
in this article.
To run cp-modelCalcTool.pyc in a MultiRun
from the command line, use the following syntax:

(continued on page 2)

Inside This Issue:


Views into Software Development: Introducing the New
Model Calculation Script, cp-modelCalcTool.pyc........page 1
We Want Your Solutions!...................................................page 9
Shirley Deslauriers Retires.............................................page 10

Mintec Directory...........................................................................page 10
Changes Anticipated in MineSights Use of SQL.............page 10
2008 Training Schedule...............................................................page 11
Trade Shows and Seminars........................................................page 12
Web-based Training........................................................................page 12

MineSight in the Foreground

(Introducing the New Model Calculation Script, cp-modelCalcTool.pyc continued from page 1)
Command Line Compass Multirun:
----------------------------mscompass -multi package_name response_name [[drive:path_name]project_name] [-module module_name]
Example:
D:\modelCalc\Winexe\Metlib>mscompass -multi myPkg1 myResponses1 D:\modelcalc\geo.prj

Script Structure
The cp_modelCalcTool.pyc script consists of three sections: Selection, Calculations,
and Summary which are discussed below.

Selection
The Selection section is where the model file is selected as well as various limiting
filters. On the Model Selection And Limits panel, choose the 3D block model you want
this script to work with and then make any optional limiting choices. The limiting choices
made on the Model Selection And Limits panel control the availability of the panels
found in the Limit By and Limit To sections. Model blocks can be spatially limited by a
polygonal boundary, coordinates, and existing model items evaluated by an expression.
Model blocks to be used in the calculations can also be limited to levels, rows, and
columns, or can be bound by surfaces, solids, or level polygons.
Although this script will run on variable height benches and rotated models,
certain filtering options are not available if your model is rotated. If the model
is rotated using a true 3D rotation, then limiting by either boundary, surfaces,
and/or level polygons is not available since those options are applied by
elevation. However, those filters are available in horizontal rotation. Using model
coordinates (Easting, Northing, and/or elevation) to limit the selection is disabled
for all rotated models, but you may limit by the model block indices (column,
row, and/or bench). Coding between surfaces is done relative to the horizontal
orientation.
After the specified filtering, your Python script is run against each block in the
selected set. This allows maximum flexibility for further filtering, processing, and
optionally updating the item values in the block model.

Calculations
The Calculation Items panel is where the model items to be used in this script are
selected. Either enter the item name in the Add Item input field or use the Item Chooser
to display a list of model items from which to choose. The items shown on the list are from
the model you selected earlier on the Model Selection And Limits panel. Only those items
listed on the Calculation Items list can be used in this script.
(continued on page 3)

September 2008

MineSight in the Foreground


(Introducing the New Model Calculation Script, cp-modelCalcTool.pyc
continued from page 2)

Once an item has been added to the Calculation


Items list, a particular value can be specified to
substitute for undefined values. Specify whether or
not the items value is to be stored back to the model
after this scripts calculations are complete. The list
can be reorganized using the arrow buttons along the
right side of this panel.
The Calculation Coding panel is to input the
Python user-calculation script (shown below).
Optionally, an existing script can be imported and/
or savee to a file. Numerous commonly used tokens
are listed along the right side of the panel. The model
items previously selected on the Calculation Items
dialog are also listed. Click on those to insert them
into the script.

The Options panel is where the various partials


options, options for an output audit report, progress
window display, and various validation options
are selected. Validation options check for possible
problems with selected polygons, surfaces, and solids
using this script.

Summary

The Responses panel displays a summary of the


responses that will be used by this script based on
input choices.

(continued on page 4)

September 2008

MineSight in the Foreground


(Introducing the New Model Calculation Script, cp-modelCalcTool.pyc
continued from page 3)

Use the Test One Block panel


to select the particular block
you want to use for testing your calculations. This
specified block will then be used when the Test One
Block button is selected on the Calculation Coding
panel or on this panel.

Examples using cp-modelCalcTool.pyc


The following examples illustrate the use of this
script to code a model item based on calculations or
based on a blocks location between surfaces or within
solids. The two final examples show how the script is
run via MultiRun.

Example 1
This example illustrates the use of a simple set
of calculations. A code for model item ZONE is
calculated based on the blocks existing ROCK code
value and CUPLY grade values.
First, the model to use is selected on the Model
Selection And Limits panel. Since we want to
calculate the value of model item ZONE for every
block in the model, no limiting is used.

Example 1 Calculation Items panel Shows the selected model items


to be used in this script. Only item ZONE will be stored back to the
model file.

Next, go to the Calculation Coding panel and


enter the script calculations in Python syntax. The
model items you had selected on the Calculation
Items panel are available for use in calculations on
this panel. Along the right-hand column are all of the
available tokens that can be used in your calculations.
You can also import an existing script (.pyc),
or you can export your new calculations to a script
(.pyc).
When you are satisfied with your coding, be
sure to test it using the Test One Block button.
(Remember, you can change which block is used for
testing on the Test One Block panel located in the
Summary section.)

Example 1 Model Selection And Limits panel Notice that when


there is no limiting specified, the Limit By and Limit To panel choices
are unavailable.

Next, under the Calculations section on the


Calculations Items panel, select the model items to
use in the script calculations. In this example, item
ZONE will be calculated (and stored) based on model
items CUPLY and ROCK.
Example 1 Calculation Coding panel Shows how the item ZONE
is calculated based on ROCK type and range of CUPLY grade values in
this user-script.
(continued on page 5)

September 2008

MineSight in the Foreground


(Introducing the New Model Calculation Script, cp-modelCalcTool.pyc continued from page 4)

Example 2
This example shows how to code model blocks that occur between two surfaces. In this case, a code will be
assigned to those blocks that occur between a topography surface and a pit surface.
Under the Limit To Surfaces heading, go to the Control By Surfaces panel. Use the file chooser or type
in the absolute path to the.msr geometry object files that contain the MineSight surfaces. Next, specify the
model item to be used on the Calculation Items panel, followed by the item and what its value should be
equal to over on the Calculation Coding panel.
Example 2 Control By Surfaces and Calculation Coding
panels - Coding model item INPIT with a value of 1 based on the
blocks location between the two surfaces specified on the Control
By Surfaces panel. On the Control By Surfaces panel, the full
path to the surfaces must be entered.

Example 2 Shown is a 3D view of the two MineSight surfaces:


topography (brown) and a pit (blue).

Example 2 Shown is a 3D view of those model blocks that occur below


the topography surface and inside the pit surface.
(continued on page 6)

September 2008

MineSight in the Foreground


(Introducing the New Model Calculation Script, cp-modelCalcTool.pyc continued from page 5)

Example 3
This example uses cp-modelCalcTool.pyc in a MultiRun to set codes for blocks based on multiple solids.
While model blocks can be coded from solids directly in MS3D or by using the standalone engine mscode.
exe, this example shows how to accomplish the task using this script.
On the Model Selection And Limits panel, choose to limit by Solids. The Control By Solids panel will
then become available where the absolute path to the solids objects is entered. In this example, the surfaces are
all located in the same directory and each surface is defined using multi-run variable, ?01. Once setup has been
completed, run the script via File | Run Procedure. Note: in a MultiRun setup, the Test One Block option is
not available.
Example 3 Control By Solids and Calculation Coding
panels Solids are defined as MultiRun variable ?01, and
values to be assigned are defined by MultiRun variable ?02.

Example 3 MultiRun Variables tab dialog


Variables ?01 and ?02 are assigned values for
the eight runs (for each of the eight solids used in
this MultiRun).
(continued on page 7)

September 2008

MineSight in the Foreground


(Introducing the New Model Calculation Script, cp-modelCalcTool.pyc continued from page 6)

Example 3 Model view showing item AREA after coding using the
cp-modelCalcTool.pyc script. One model block located in area 8
Example 3 This picture shows the eight different solids (each
is shown in the yellow block query highlight.
colored differently) before coding. The smallest solid (area 8) is
outlined by a query box.

Example 4
This last example is a bit more complex as it shows the use of cp-modelCalcTool.pyc in multiple
instances in the same multirun package and response set.

Example 4 MultiRun setup.

In the first setup, cp-modelCalcTool.pyc is used to set code values for blocks between multiple surfaces.
The result from this run will then be used for calculations in the second setup.
Upper and lower surfaces are defined as variables ?01 and ?02 on the Control By Surfaces panel. The
surface defined by variable ?01 is always above the surface defined by variable ?02. Since there are four pairs
of surfaces, the script will be run four times to code all the blocks in the model below the uppermost surface
(or below topography).
(continued on page 8)

September 2008

MineSight in the Foreground


(Introducing the New Model Calculation Script, cp-modelCalcTool.pyc
continued from page 7)

Example 4 MultiRun Variables used in the first setup.

Example 4 Control By Surfaces How multiple surfaces are used as


variables. Note the complete path is given. Coding will be between ?01
and ?02; the surface defined by variable ?01 is always above the surface
defined by variable ?02.

The script input on the Calculation Coding panel


is very simple; the blocks between the upper and
lower surface will be assigned a code and stored to
model item SURFS.
Multiple surfaces. The objective is to code model blocks between these
surfaces.

Results after running the cp-ModelCalTool.pyc script. Coded


model blocks are displayed along with the original five surfaces.

Example 4 Model item SURFS will be assigned a particular code


depending on its location between surfaces.

Finally, in the second MultiRun setup, a Python


script is used to calculate model block values using the
SURFS code (calculated in the first setup above) and
using the ZONE code calculated in Example 1. The
result from this run is stored in model item XTRA1.
(continued on page 9)

September 2008

MineSight in the Foreground


(Introducing the New Model Calculation Script, cp-modelCalcTool.pyc continued from page 8)

Example 4 This shows the Python script used to calculate model item
XTRA1 in the second setup.

Example 4 Variable values used in Example 4. This MultiRun package


is comprised of two cp-modelCalcTool.pyc setups.

We Want Your Solutions!


26th Annual Mintec Seminar
Why wait until the last minute?
Do it now while its fresh!
How did you use MineSight
to solve a problem?
Example 4 Final results: 3D display of model item XTRA1 and the five
surfaces that were used in this MultiRun.

cp-modelCalcTool.pyc is a flexible and


powerful new MSCompass script. It performs
calculations on model blocks using a Python script
and optionally utilizes MS3D surfaces and solids. In
the future this script will be capable of running from
inside MS3D via the File | Run Scripts menu option
and to run this script using GSM and GSF models.
Look for this script on the 2008 Update CD, if not
sooner at www.mintec.com. If you would like further
information about this new script, please contact
Mintec Technical Support at support@mintec.com or
by telephone at 520.326.1860.

September 2008

Share your experience using MineSight


on a project or operation
Consider any application of MineSight to a mining problem
which would be of general interest to the attendees.
Presentations should be approximately 20 minutes in length.
Submit your abstracts, in Microsoft Word format, approximately
100-250 words, with the following information:
Title, subject, and keyword
Names, titles, addresses, and telephone numbers
of all authors
Address questions/abstracts to:
Fred Fest, Mintec, Inc.
Telephone 520.795.3891
Fax 520.325.2568
E-mail Fred.Fest@mintec.com
(Abstracts for presentations will be reviewed and you will be
notified of acceptance.)

You might also like