Vous êtes sur la page 1sur 7

Extending Multi-Runs with Python® and Standalone Engines

Extending Multi-Runs with Python®


Mining Software
and Standalone Engines
MineSight® is a state-of-the-art, integrated 3-D data modeling and visualization system
that provides great power and flexibility 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 verified drillhole data, and
the selection of finalized 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 final 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 files 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 files to run them. These programs are:

24th
Annual
Mintec
Seminar

Page 
Extending Multi-Runs with Python® and Standalone Engines

cdt.exe - Correcting Delaunay Triangulation corrects triangu-


lated contour strings.
clip.exe - The solid/string clipping utility.
dtb.exe - Delaunay Triangulation triangulates survey data. Mining Software
filter.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 file,
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 file with polygons.


There can be one or two input files
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 file Input parameter file. Used when survey files used.
-int file Output intersection of input polygons.
-union file Output union of input polygons.
-diff file 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 Define a directory with input files.

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 24th
be received from the Technical Support group. The majority of these procedures have been
Annual
used by the Australasian MineSight® users.
Mintec
The procedure names are:
Seminar

Page 
Extending Multi-Runs with Python® and Standalone Engines

Pdtmcd.met – Grid DXF/shell surface to GSF,


Permap.met – Plots IP End of Period maps.
Pltpln.met – Plots data on plan.
Mining Software 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® files. 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 Definitions


During a discussion of Models there are several terms that need defining.
PCF
Project Control File. This file serves as the central storage location for all your
Model files. 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 inefficient 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 definition.

24th Cell
Annual A one-by-one-by-one location within the Model. This is the smallest
Mintec referenced item.
Seminar

Page 
Extending Multi-Runs with Python® and Standalone Engines

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 Mining Software
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 defined 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
defined 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):
fldbug.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,
fldel, flname, 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 24th
polygon, using the metech_utilities library and if the block is within the boundary, Annual
the items are set to the assigned value, in this case, 1. Mintec
Seminar

Page 
Extending Multi-Runs with Python® and Standalone Engines

Standalone Engine samples


The Standalone Engines require that data in specific format be passed to the
Mining Software 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
fldbug.write(‘Creating Oxide Shell\n’)
msr_file_name = ‘%s\\_msresources\\OC-Geology\\ORE\\Hi.msr’ %CWD
shell_file_name = ‘hi.shl’
create_shl_files(fldbug,msr_file_name,shell_file_name)
# Trans
fldbug.write(‘Creating Transitional Shell\n’)
msr_file_name = ‘%s\\_msresources\\OC-Geology\\ORE\\Low.msr’ %CWD
shell_file_name = ‘low.shl’
create_shl_files(fldbug,msr_file_name,shell_file_name)
.
.
.
fl = open(‘voxelme.bat’,’w’)
# Code DH
fl.write(“@echo off\n”)
fl.write(“echo Coding Drillholes...\n”)
fl.write(‘m208RP /frun208.PRI %s\n’ %nullout)
fl.write(‘m219v1 /frun219.hi %s\n’ %nullout)
fl.write(‘if exist dat205.cd del dat205.cd %s\n’ %nullout)
fl.write(‘clip -drh dat219.tmp -attr spear.0 -drill dat205.cd %s\n’ %nullout)
fl.write(‘if exist dat205.cd m205v1 /frun205.low %s\n’ %nullout)
fl.write(‘if exist dat205.cd del dat205.cd %s\n’ %nullout)
fl.write(‘clip -drh dat219.tmp -attr spear.1 -drill dat205.cd %s\n’ %nullout)
fl.write(‘if exist dat205.cd m205v1 /frun205.hi %s\n’ %nullout)

The above snippet exports the solid.msr as a shell format file and runs Clip.exe.
The -drh option specifies that the data to clip is a drillhole file and the –attr specifies that
the attribute of the solid should be set to the intervals within the solid, while the –drill
specifies the output should be in M205V1 format. In the above example, two attributed
solids with that define the high and low grade ore zones exported as shell files along with
the drillhole intervals exported using M219V1 are used with the Clip program to define
the assay intervals within each solid. Each solid is processed, then the output of the program
is loaded back into the drillhole file using M205V1.
The same shell files can be used to calculate the 3DBM partials using another Standalone
Engine, Voxel. The code snippet below shows how this can be done:
fl.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(),
24th mypcf.nx(),mypcf.ny(),mypcf.nz(),mypcf.dx(),mypcf.dy(),mypcf.dz(),nullout))
Annual fl.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.
Mintec ymin(),mypcf.zmin(), mypcf.nx(),mypcf.ny(),mypcf.nz(),mypcf.dx(),mypcf.dy(),mypcf.
Seminar dz(),nullout))

Page 
Extending Multi-Runs with Python® and Standalone Engines

Using DTB to create a surface


Dtb can use a runfile 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 runfile would look
Mining Software
like this:
com ********** Start of run file *******************
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 Rectification (default


option);
// 1 - perform boundary Rectification

com Output file format


IOP3 = 3 // 0 - Plot file (default option);
// 1 - list of Edges
// 2 - list of Triangles
// 3 - Shell format
// 4 - Old Shell format

IOP4 = 0 // 0 - output file is in ASCII format (default option);


// 1 - output file is in BINARY format

END // Logical End of the run file

The output is a shell file that can be imported into MineSight® or converted to a .msr
using the shl2msr.exe program.
Using voxel to create partial files
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 file, 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 filtering 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.

24th
Annual
Mintec
Seminar

Page 
Extending Multi-Runs with Python® and Standalone Engines

Mining Software

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 filtered by plane. The output is a .csv file that can be
opened in Microsoft® Excel.

24th
Annual
Mintec
Seminar

Page 

Vous aimerez peut-être aussi