Automating tasks in Surpac: How macros can make you more efficient

The Surpac environment allows the use of macros to automate tasks.

The Surpac environment allows the use of macros to automate tasks.

Using macros, included in mining planning software, can save you a lot of time and make you more efficient in your work. Macros are commonly used to automate repetitive tasks in software to save time. Surpac macros can make your work easy and free you up to do more “engineering” work. My goal, in this post, is to (i) share my thoughts on how macros can save you time; and (ii) show how the “record macro” feature in Surpac can be used to quickly and easily make useful macros.

Several mine planning tasks can be automated. These include printing mine plans, importing data into databases, block model reports, and volume calculations. Most mine planning software provide a means to build macros. Scripting (programming) languages extend the usefulness of these macros (much like VBA extends the usefulness of MS Excel macros). When well conceived and implemented, macros save time and reduce error.

Macros are simple computer programs. The program itself is written in a text file and interpreted by a scripting engine. In Surpac, the scripting engine is TCL (Python in MineSight and Lava and Perl in Vulcan). The most advanced user can write a macro completely from a text editor, save, and run it. The least advanced user can record a macro with the “record macro” command and replay the macro. An efficient alternative for someone who is not a programming guru, but is interested in building useful macros, is to record a macro and modify it with simple scripting (TCL) commands.

This approach is illustrated in the video below to build a macro to automate importing survey data from a csv file into a mine survey database. In this example, I:

  1. Record a macro while importing data into the database.
  2. Choose the points within the macro that I want to interact with the macro. In this case, before applying the “select format file…” form and before applying the “load database tables…” form.
  3. Use the _action switch to pause the macro for user input at these points.
  4. Save the macro for later use.

If you want a copy of the macro in the video, go to Sphinx Mining Systems’ website and click on “Technology Transfer” then on “Free downloads” (Note: you will have to register to get access).

This simple process can allow you to build some useful macros quickly and efficiently, which will free you up to do some real “engineering” work. Are there any macro tips of your own that you want to share? Let me hear from you.