Extending Multi-Runs with Python
®
and Standalone Engines
Page 1
Mining Software
24th
Annual
Mintec
Seminar
Extending Multi-Runs with Python®
and Standalone Engines
MineSight
®
is a state-of-the-art, integrated 3-D data modeling and visualization system
that provides great power and exibility for geological modeling and mine designs.
MineSight
®
, through the menu program MineSight
®
Compass™ allows access to the
complete package of MineSight
®
programs for manipulating the project databases of
drillhole, composite, and block models. As powerful as MineSight
®
is, however, it requires
human interaction to produce results.
One of the goals of Mintec, Inc., since the introduction of MineSight
®
, has been to allow
scripting of the graphical aspects of the program. By scripting the creation of 3-D objects
such as current mining surfaces, as-mined surfaces, extracting veried drillhole data, and
the selection of nalized results, such as the ultimate pit surface or pit phase surfaces,
many business processes can be replicated. For example, a model building process that
would incorporate new drilling information into the 3-D block model. Another process
could be created to allow the reporting of End-of-Month results.
An ideal situation would be to allow an audit trail of the model building process to
be completed totally automatically. In order to do this, the MineSight
®
graphical objects
need to be organized and named in a logical manner. This may require the use of the Data
Security System (DSS) to store nal business products such as Original Topo, Geologic
shapes, End-of-Month (EOM) surfaces, Final and Phase pit designs, and incremental or
monthly mining shapes.
A Multi-Run is simply a series of MineSight
®
Compass™ procedures that are executed
either in sequence or in loops. MineSight
®
Compass™ procedures can be standard
MineSight
®
procedures, Australasian MineSight
®
procedures, custom procedures, or
Python scripts. One of the standard MineSight
®
procedures, Runcmd.dat, allows the
execution of any command from MineSight
®
Compass™, Python
®
, Microsoft
®
Windows,
or any executable. This allows use to call outside programs during the execution of a
Multi-Run.
Python is the scripting language used within MineSight
®
. Python
®
can be used to reset
or update the model les in MineSight
®
. Python
®
can also be used to process individual or
multiple objects in a MineSight
®
directory.
The Standalone Engines are the MineSight
®
tools that have been “exposed” to
command line options. Once an engine is exposed, it can be run by passing commands to
it in a command window, a MineSight
®
Compass™ procedure, or a Python
®
script. The
portions of MineSight
®
that have been exposed and are available for your use are located
in the winexe\StandaloneEngines directory or for the Australasian clients, Medexe\
local. Plans are for the Standalone Engines to be moved to the winexe directory in a
future release.
Standalone Engines
There are currently eight programs in the Standalone Engine folder along with the
required DLL les to run them. These programs are:
Extending Multi-Runs with Python
®
and Standalone Engines
Page 2
Mining Software
24th
Annual
Mintec
Seminar
cdt.exe - Correcting Delaunay Triangulation corrects triangu-
lated contour strings.
clip.exe - The solid/string clipping utility.
dtb.exe - Delaunay Triangulation triangulates survey data.
lter.exe - Removes unwanted data from triangulation.
pclip.exe - Polygon/Polygon clipping utility.
sgr.exe - Surface Gridding and Volume Calculation utility.
union.exe - Solid/solid intersection engine.
voxel.exe - Calculates block partials from solids.
Within the Standalone Engine directory, there is a complied help le,
StandaloneEngines.chm. Each program also provides minimal documentation
internally, which is accessed by typing in the name of the program followed by a–h. For
example, typing in pclip–h results in :
POLYGON-POLYGON CLIPPING UTILITY
-vbm/srv Input VBM/Survey le with polygons.
There can be one or two input les
of the same format.
oper A pre-processing operation over input polygons
to be performed before other calculations.
It can be one of the following:
n No preprocessing.
s Separate polygons into independant sets.
c Option opposite to ‘s’. Combine all
polygons in one.
-prm le Input parameter le. Used when survey les used.
-int le Output intersection of input polygons.
-union le Output union of input polygons.
-diff le Output difference of input polygons.
-f<n> Validate polygons before intersection, where n can be
0 - make external and internal polygons
to have opposite direction (default);
1 - use original direction of polygons.
-R Reverse polygons (external oriented clockwise).
-dat dir Dene a directory with input les.
PCLIP ver 3.34 (MS3D 3.6) Copyright (C) 1996-2006 Mintec Inc.
Notice that the standalone engines are versioned and correspond to the major version of
MineSight
®
.
Procedures that use the Standalone Engines
Mintec has created procedure for many of the standalone engines. These procedures can
be received from the Technical Support group. The majority of these procedures have been
used by the Australasian MineSight
®
users.
The procedure names are:
Extending Multi-Runs with Python
®
and Standalone Engines
Page 3
Mining Software
24th
Annual
Mintec
Seminar
Pdtmcd.met Grid DXF/shell surface to GSF,
Permap.met Plots IP End of Period maps.
Pltpln.met Plots data on plan.
Pltsec.met Plots data on section.
Prmdup.met Removal of Duplicate triangles from a solid.
Psfslc.met Slice a Solid/Surface with a plane.
Psfvol.met Calculate Bench Volumes/Partials between two DTM
Surfaces.
Pspear.met Code Drill holes or Composites within 3-D Solids.
Ptrutl.met Solid/Surface Validation and Fix Utility.
Punion.met Runs Union on 2 Solids or Surfaces.
Pvbm2.met Create VBM strings of merged cut and survey data.
Pvalid.met Validate a surface, removes duplicates, self-intersections.
Pvbmmg.met Creates VBM strings of merged cut and survey data.
These procedures can be used with MineSight
®
Compass™ or as part of a Multi-Run.
Python® code samples
Python
®
can be used to select MineSight
®
objects for use with the Standalone Engines
or to directly modify MineSight
®
les. Mintec has documented the access methods in the
graildoc folder. From within MineSight
®
, click on Help | MineSight Help | MineSight
Grail Documentation. You can also access the graildoc using Microsoft
®
Explore. Click on
the ~\Winexe\graildoc\lib-grail-data-model.html to see terms and methods of
accessing the model data. Below is a sample of the documentation.
Terms and Denitions
During a discussion of Models there are several terms that need dening.
PCF
Project Control File. This le serves as the central storage location for all your
Model les. It knows what items are in what model, as well as the
dimensions of your model.
Model File Name
This is the name of the model, as it is known to the PCF.
3DBM
This is a 3-D block model.
GSM
This is a gridded seam model.
Slab
This is a sub-section of an Model. It is inefcient to load an entire model into
your computer’s memory. Instead, you will load a sub-section that you are
immediately interested in, and work on that.
In this way you will always have a slab within memory, but you will be able
to read/write from the disk via the Model denition.
Cell
A one-by-one-by-one location within the Model. This is the smallest
referenced item.
Extending Multi-Runs with Python
®
and Standalone Engines
Page 4
Mining Software
24th
Annual
Mintec
Seminar
In general the sequence of steps are:
1. Create a Model with your slab dimensions.
2. Request a handle to the slab
3. Read/Write data to/from the slab
4. Save the slab, if you were writing
5. Free memory
6. Force a garbage collection
Below is a snippet of code that resets three items in a 3DBM for a dened area, this might
be done in anticipation of coding the model in a later step.
m = model.Model(pcfpath, MODELNAME, minLevel, maxLevel, minRow,
maxRow, minColumn, maxColumn, itemlist)
s = m.slab()
for row in range(minRow, (maxRow + 1),1):
for col in range(minColumn, (maxColumn+1),1):
s.modset(‘WAREA’,benchnumber,row,col,model.UNDEFINED)
s.modset(‘INFLG’,benchnumber,row,col,model.UNDEFINED)
s.modset(‘BLPLY’,benchnumber,row,col,model.UNDEFINED)
m.storeslab()
m.free()
gc.collect()
Below is a snippet of code that sets several model items within a
dened area of the 3DBM.
m = model.Model(pcfpath, MODELNAME, minLevel, maxLevel, minRow,
maxRow, minColumn, maxColumn, itemlist)
s = m.slab()
for lev in range(minLevel,maxLevel+1):
dbug.write(‘Coding lev %s \n’ %lev)
for row in range(minRow, maxRow+1):
for col in range(minColumn, maxColumn+1):
veast = mypcf.xmin() + (col * dx) - (0.5*dx)
vnorth = mypcf.ymin() + (row * dy) - (0.5*dy)
test_inside = metech_utilities.mslocp(cut, mycut,
del, name, veast, vnorth, version)
if test_inside >= 0:
s.modset(“INFLG”,lev,row,col,1)
s.modset(“BLPLY”,lev,row,col,1)
m.storeslab()
m.free()
gc.collect()
In the above snippet, the blocks are being tested to see if they are within a boundary
polygon, using the metech_utilities library and if the block is within the boundary,
the items are set to the assigned value, in this case, 1.
Extending Multi-Runs with Python
®
and Standalone Engines
Page 5
Mining Software
24th
Annual
Mintec
Seminar
Standalone Engine samples
The Standalone Engines require that data in specic format be passed to the
program. Python
®
can be used to select a MineSight
®
object and export it in the
format required for the Standalone Engine.
In the code snippet below, a MineSight
®
solid is used to spear drillholes that are extracted
from a MineSight
®
drillhole data set.
# Dump Shell Files
# Ox
dbug.write(‘Creating Oxide Shell\n’)
msr_le_name = ‘%s\\_msresources\\OC-Geology\\ORE\\Hi.msr’ %CWD
shell_le_name = ‘hi.shl’
create_shl_les(dbug,msr_le_name,shell_le_name)
# Trans
dbug.write(‘Creating Transitional Shell\n’)
msr_le_name = ‘%s\\_msresources\\OC-Geology\\ORE\\Low.msr’ %CWD
shell_le_name = ‘low.shl’
create_shl_les(dbug,msr_le_name,shell_le_name)
.
.
.
 = open(‘voxelme.bat’,’w’)
# Code DH
.write(“@echo off\n”)
.write(“echo Coding Drillholes...\n”)
.write(‘m208RP /frun208.PRI %s\n’ %nullout)
.write(‘m219v1 /frun219.hi %s\n’ %nullout)
.write(‘if exist dat205.cd del dat205.cd %s\n’ %nullout)
.write(‘clip -drh dat219.tmp -attr spear.0 -drill dat205.cd %s\n’ %nullout)
.write(‘if exist dat205.cd m205v1 /frun205.low %s\n’ %nullout)
.write(‘if exist dat205.cd del dat205.cd %s\n’ %nullout)
.write(‘clip -drh dat219.tmp -attr spear.1 -drill dat205.cd %s\n’ %nullout)
.write(‘if exist dat205.cd m205v1 /frun205.hi %s\n’ %nullout)
The above snippet exports the solid.msr as a shell format le and runs Clip.exe.
The -drh option species that the data to clip is a drillhole le and the –attr species that
the attribute of the solid should be set to the intervals within the solid, while the –drill
species the output should be in M205V1 format. In the above example, two attributed
solids with that dene the high and low grade ore zones exported as shell les along with
the drillhole intervals exported using M219V1 are used with the Clip program to dene
the assay intervals within each solid. Each solid is processed, then the output of the program
is loaded back into the drillhole le using M205V1.
The same shell les can be used to calculate the 3DBM partials using another Standalone
Engine, Voxel. The code snippet below shows how this can be done:
.write(‘voxel -shl hi.shl -prt hi.prt -xmin %s -ymin %s -zmin %s -nx %s -ny %s
-nz %s -dx %s -dy %s -dz %s -sb 10 %s\n’ %(mypcf.xmin(),mypcf.ymin(),mypcf.zmin(),
mypcf.nx(),mypcf.ny(),mypcf.nz(),mypcf.dx(),mypcf.dy(),mypcf.dz(),nullout))
.write(‘voxel -shl low.shl -prt low.prt -xmin %s -ymin %s -zmin
%s -nx %s -ny %s -nz %s -dx %s -dy %s -dz %s -sb 10 %s\n’ %(mypcf.xmin(),mypcf.
ymin(),mypcf.zmin(), mypcf.nx(),mypcf.ny(),mypcf.nz(),mypcf.dx(),mypcf.dy(),mypcf.
dz(),nullout))
Extending Multi-Runs with Python
®
and Standalone Engines
Page 6
Mining Software
24th
Annual
Mintec
Seminar
Using DTB to create a surface
Dtb can use a runle to create a surface from survey data. An example might
be the end-of-month survey pickups. For example, the surveyors may provide
toe, crest, spot elevations, and a boundary limit. The dtb runle would look
like this:
com ********** Start of run le *******************
dtb parameter=param.cod survey=jan.srv
dtb output=jan.shl
com Option assigning
IOP1 = 0 // 0 - use breaklines (default option);
// 1 - ignore Breaklines
IOP2 = 1 // 0 - not perform boundary Rectication (default
option);
// 1 - perform boundary Rectication
com Output le format
IOP3 = 3 // 0 - Plot le (default option);
// 1 - list of Edges
// 2 - list of Triangles
// 3 - Shell format
// 4 - Old Shell format
IOP4 = 0 // 0 - output le is in ASCII format (default option);
// 1 - output le is in BINARY format
END // Logical End of the run le
The output is a shell le that can be imported into MineSight
®
or converted to a .msr
using the shl2msr.exe program.
Using voxel to create partial les
Mintec has created a script named ShlRpt.pyc that uses the Standalone Engine program
voxel.exe. The script can be run from within MineSight
®
or from a batch le, procedure,
or from the command line. The script can process multiple objects in a MineSight
®
folder
or multiple elements in a MineSight
®
object. The script has many options for ltering the
data to be used: by element name, element material, resource material, solids only, and by
Volume. Multiple items can be reported including volume, tonnages, and area. The tonnage
factor is applied to the entire set of solids.
Extending Multi-Runs with Python
®
and Standalone Engines
Page 7
Mining Software
24th
Annual
Mintec
Seminar
Other Python® Scripts
Mintec is creating Python
®
scripts to simplify the reporting
of objects, for example, the polygonal reports.
This script will report out various items of interest on all
objects in a folder that contain polylines or polygons. Data
can be ltered by plane. The output is a .csv le that can be
opened in Microsoft
®
Excel.