Getting Started

Version: 16.2

Table of Contents

Introduction

MineSight® Grail is a flexible and powerful set of python modules packaged under one scripting library used to customize MineSight® for site implementation engineers and end users. In addition, MineSight® Grail is a replacement for MineSight® traditional MineSight® Compass Procedure language. It exploits the richness of Python as a scripting interface and provides a flexible Graphical User Interface (GUI) layout tool.

Scripts written using the MineSight® Grail library can be run inside of MineSight® Compass, use MineSight® Compass Multi-Run, run inside MineSight® 3-D, as well as executed in standalone mode from a desktop shortcut or from a command window.

There are many instances when working with a MineSight® project that a user is required to customize and automate a number of processes. The current customization method is to use MineSight® Compass Procedures that are based on a proprietary language developed by MineSight® over a number of years. While this has served our clients well, extending the traditional MineSight® Compass Procedure language is non-trivial. Since we already have developed Python scripting experience in providing user customizable reserve calculations in the MineSight® Interactive Planner, it was decided to extend the use of Python into a more general scripting interface into the system.

To accommodate this goal, we required the new scripting system to:

  • provide extensible, powerful scripts that can interact with outside processes
  • provide increased GUI composition capabilities
  • have improved ease of use and development
  • provide a new framework for scripting in MineSight® Compass and MineSight® 3-D
  • have backward compatibility with existing MineSight® Compass procedures, including multi-run capability
  • allow access to all important MineSight® data

Starting with MineSight® Grail v.1.10 the MineSight® Interactive Planner modules will be integrated with the MineSight® Grail scripting library to provide a single location for all your Python and MineSight® scripting needs.

It is important to note that MineSight® Grail is not just a replacement for MineSight® Compass procedures, but it is also an interface that lets us bind processes together in an easy way, and provide a rich interface toolkit that can be embedded in or run independent of MineSight® 3-D or MineSight® Compass.

You want to consider using MineSight® Grail whenever you need to allow different systems to interact in a seamless way.

Requirements

To work with the MineSight® Grail library, you will need the Python interpreter and some additional libraries. These libraries are installed as part of the MineSight® Grail installation process.

The requirements for MineSight® Grail can be divided into the following three categories,

  1. General

    When running a MineSight® Grail installation, the installation program will install all the pre-requisites for executing a Python script that uses the MineSight® Grail library. The pre-requisites are,

    1. Python 2.2.3
    2. Pmw widget library (Pmw.zip)
    3. Python Win32 library (win32all-152)
    4. Numeric library (Numeric-21.0.win32-py2.2.exe)

    You will not be able to effectively use MineSight® Grail if one of these components is missing.

    Fortunately these components are installed as part the MineSight® Grail installation process.

  2. MineSight® Grail Embedded

    As of MineSight® Grail v3.4 you will be able to manipulate MineSight®-3D. What your script can accomplish will be dependent on the version number. In general, the second version number tends to indicate a compatibility between the library and MineSight®-3D.

    For example, MineSight® Grail 3.4 works with MineSight®-3D 3.4; however, it is not guaranteed that MineSight® Grail 3.4 will work with MineSight®-3D 3.5.

    MineSight® Grail modules that work with MineSight®-3D are found in the grail.ms3d package.

  3. MineSight® Interactive Planner (MS-IP)

    Scripts that execute with MS-IP will only be workable within the context of an Interactive Plan. The version numbers will generally work along the same principle as MineSight® Grail Embedded (above).

    MineSight® Grail modules that work with the MS-IP are found in the grail.ip package.

A Tour of MineSight® Grail

MineSight® Grail aims to provide our users with a complete suite of tools that will open up MineSight® for custom tasks. Our aim to provide a complete set of tools useful for any mining operation using MineSight®.

Currently some of the major categories within the library are listed below.

Data Access

MineSight® Grail has modules that will provide access to the suite of MineSight® data files. These modules are organized within the MineSight® Grail library under the grail.data package. The current list of useful modules are,

grail.data.agdm
For accessing the contents of the MineSight® Attributed Geometry Data Model (AGDM) within a specified database.
grail.data.model
For read and write access to model files.
grail.data.geometry
For read and write access to Geometry MineSight® Resource (MSR) files.
grail.data.dh
For read and write access to drillhole and blasthole files.
grail.data.pcf
For read only access to the contents of a Project Control File (PCF).
grail.data.msr
For general purpose read and write access to MSR files.

MineSight® Grail Embedded (MSGe)

This section of the MineSight® Grail library provides script writers with the ability to manipulate MS-3D. The focus is allowing users to write custom scripts that will help the work flow within the MS-3D environment.

All modules that work with MS-3D are currently organized under the grail.ms3d section, and are only accessible during a MineSight®-3D session.

This feature is available starting in MineSight®-3D v3.4-00.

MineSight® Interactive Planner (MS-IP)

Modules that are used during an Interactive Planning (IP) session are available to help you run scripts based on your cuts, and run other scripts based on your IP session.

All modules organized under the grail.ip section are used for the access during a IP session, and are only accessible during the IP session.

MineSight® Compass and MineSight® Grail

The grail.compass section of the library is concerned with providing a useful alternative to the MineSight® Procedures. This allows you to create Python scripts that are interchangeable with the MineSight® Procedures. When working within the framework of a Compass Style script, you also gain the ability to run your Python scripts within a multi-run context.

How to Use MineSight® Grail

Using MineSight® Grail is a matter of starting up some particular script and playing around with it. It generally revolves around solving a particular task. Some examples would be,

  • Traversing a model.
  • Customizing an Interactive Planner script.
  • Processing large text files.

These tasks are easily accomplished with the MineSight® Grail library.

To learn how to create your own scripts using the MineSight® Grail library you will need to first learn how to use Python, then you can learn what you can with the MineSight® Grail library.

Learning Python

Since MineSight® Grail is a library that you can import into a Python script, it is highly recommended you gain a working familiarity with Python before you proceed in using the MineSight® Grail library.

The Python Tutorial [1] provides a very good starting point to working with Python. Once you are familiar with the basics of Python, you can start to import the MineSight® Grail library to write your scripts.

Executing MineSight® Grail Scripts

MineSight® Grail scripts can be divided into four broad categories of scripts outlined below,

  1. Command Line Scripts

    These are scripts that can be executed from the DOS prompt. They are generally scripts that are executed as batch jobs on a timed schedule.

    These scripts do not depend on either MineSight® Compass, MineSight® 3D or MineSight® Interactive Planner to execute. They do not require any of the MineSight® programs to be available when executing.

    An example would be a script that read a nightly log file and populated a geometry object appropriately.

  2. Compass Style Scripts

    These are scripts that are capable of executing within the MineSight® Compass environment. These scripts will acquire data from the user and run it against some other process. Compass style scripts have the ability to run within a multi-run.

    These scripts will typically import modules from the grail.compass sub-package.

  3. MineSight® Grail Embedded

    These are scripts that can execute within the context of a MineSight® 3D session.

    Grail Embedded scripts will import modules from the grail.ms3d subpackage.

    Because we late bind the state of MineSight® 3D to the grail.ms3d sub-package at the moment you execute the script, we require that the script be executed from a MineSight® 3D session.

    Prefixing scripts with file:em- is the convention for naming Grail Embedded scripts.

  4. IP Scripts

    These are scripts that are capable of running within MineSight® Interactive Planner (MS-IP). These scripts will import modules from the grail.ip sub-package.

    The grail.ip sub-package contents are only available during a MineSight® Interactive Planner session. Because we late bind the contents of a IP session to the grail.ip, you will not be able to use any grail.ip components outside the context of MS-IP.

    Prefixing scripts with ip- is the convention for naming MS-IP scripts.

    Note

    A MS-IP script is capable of using MineSight® Grail Embedded components since an IP session is conducted within a MineSight® 3D session.

Scripting with MineSight® Grail

The first step to using MineSight® Grail is to make sure it is installed on your machine. To use MineSight® Grail, it is recommended that you install the library using the Installation Program.

Using the MineSight® Grail library generally involves some specific mining related task. What that task is effects how you will be using the library. The best approach to learning what can be done with the library is to,

  1. Examine the HowTo section.

    The HowTo section documents specific tasks that one might do with the MineSight® Grail library (or sometimes just with Python by itself).

  1. Modify the sample scripts.

    The $(medexe)\script directory contains official scripts created by the MineSight® staff. These scripts are useful as a good starting point to learn what you can do with MineSight® Grail.

  2. Read the Library Reference documentation.

    The Library Reference documents all the modules found within the MineSight® Grail library. In general once you have examined one of the sample scripts, you can typically use the HowTo and the Library Reference to get more information on what a particular module, class or function can accomplish.

Summary

With the MineSight® Grail library we aim to provide you with the ability to solve your unique problems using MineSight®. The use of Python and the MineSight® Grail library provide a unique and powerful means for tying together unique and disparate processes.

Reference

[1]Python Tutorial. 30 May 2003. 1 June 2004. <http://www.python.org/doc/2.2.3/tut/tut.html>