0

Automating creation and plotting of sections

Steve 6 years ago in Scripting updated by Thierno Maiga 5 years ago 6

I've just started using Micromine 2016 and I would like to automate the creation and plotting of sections using a script or macro.

I know it's possible to set up a macro to do this by specifying individual forms to load and execute but I would like to have a generic script or macro which reads through a section control file and creates plot files from the sections defined in the section control file.

If a new section is created in the section control file, running the macro/script would process the new section without having to change the script/macro (I don't want to have to change the macro every time I create a new section in the SCF).

So I’m guessing the (very basic!) pseudo-code might look something like this:

#############

Open section control file as SCF

For i= 0 to SCF.records_count

#read SCF field names and their values

#assign values to variables and use them to set Vizex display and create plot files

Set Vizex display according to the parameters in SCF record (SCF.X_CENTRE, SCF.Y_CENTRE, SCF.AWAY etc)

PlotFileName = SCF.Name

Create plotfile as PlotFileName

#############

I can get a Python script to read the contents of the section control file, but I have no idea how to use the SCF parameters to set the Vizex display or create the plotfile – can anyone give any pointers for that?


Answer

Answer

Hi Steve,


A process that works well, is defined in the Introduction to Micromine Training Manual. Plotting Using Macro.pdf is an extract of the relevant Lessons.  


That approach is fine for me.  Although each NAME in the Section Control File (SCF) has to be defined as a record in the macro, i don't see that as a problem.  If a new section is defined, then I simply add a couple of lines to the macro.


The advantage of macro is that it requires no programming knowledge.  Anyone who knows how to save a form in Micromine, can write a macro.


The macro disadvantage is that it can't (easily) handle conditions and looping.  


Personally i like to combine the strengths of scripts and macros by using a script to control the looping and then calling a macro from inside the loop to do the Micromine stuff.  


Plotting all the sections, in a SCF, is a good example of this process.  The script reads each section name, from the SCF, and then calls a macro to create the PEL file and then output a PEX file to the printer.  The Substitution Table provides the "link" between the script and the macro.  In this case the section name is read by the script and posted to a saved  Substitution Table form.  Then the macro is called.  The first line of the macro loads the saved  Substitution Table form - so it now knows the SCF name.


I have zipped up the Training project Training(2016 Introduction with Plot Script).zip so that you can see how this works.  Run the script called Plot_Sections_With_Macro.py to see how this works in practice.


I could describe everything in more detail, but probably best to get back to me if you have any questions.


Paul

Hi Steve,


Yes, you are right and your pseudo-code looks fine, but it is not completed. Please use this plot_sections.py.

This is an example with some comments that will help you to undestand the code. Probably there is an easier way how to work with plotting but I am not aware of it. The steps are following:

1. Read the section data
2. Focus your data. This is where DisplayLimits is used
3. Create PEL file


To create a PEL you need to create a PEX file first. Micromine does not support now creating PEL files using scripts that is why we need to implement the following workaround:

1. Create a temporary macro

2. Create Plot file

3. Create PEL using the macro specifing just created plot file

4. Remove the macro


The attached script will create PEL files in your project directory. These files for demo:

SECTIONS_TEST.DAT - section file. Save it to ProjectDirectory\SECTIONS

SECTIONS_DEMO.STR - load it in Vizex before running the script.


If anyone can suggest a better approach, that would be good.


Regards,

Pavel

Hi Pavel,


That is fantastic - it works perfectly and does exactly what I was trying to do.


Thanks also for the comprehensive explanation - very useful for learning more about scripting.


Many thanks, it is much appreciated

Steve

Hi Pavel Hope you are fine , so i would like to produce some kind of solid around drill hole intersection using intersection file to be able report the grade and tonnage inside this solid using BM . I ‘ve tried the option Wireframe | Create from Strings | Centre Line to Solid to generate the single solid. To be clear what I would like is to create a single solid for each hole using the intersection file and estimate the grade and tonnage inside those single solids  .

Answer

Hi Steve,


A process that works well, is defined in the Introduction to Micromine Training Manual. Plotting Using Macro.pdf is an extract of the relevant Lessons.  


That approach is fine for me.  Although each NAME in the Section Control File (SCF) has to be defined as a record in the macro, i don't see that as a problem.  If a new section is defined, then I simply add a couple of lines to the macro.


The advantage of macro is that it requires no programming knowledge.  Anyone who knows how to save a form in Micromine, can write a macro.


The macro disadvantage is that it can't (easily) handle conditions and looping.  


Personally i like to combine the strengths of scripts and macros by using a script to control the looping and then calling a macro from inside the loop to do the Micromine stuff.  


Plotting all the sections, in a SCF, is a good example of this process.  The script reads each section name, from the SCF, and then calls a macro to create the PEL file and then output a PEX file to the printer.  The Substitution Table provides the "link" between the script and the macro.  In this case the section name is read by the script and posted to a saved  Substitution Table form.  Then the macro is called.  The first line of the macro loads the saved  Substitution Table form - so it now knows the SCF name.


I have zipped up the Training project Training(2016 Introduction with Plot Script).zip so that you can see how this works.  Run the script called Plot_Sections_With_Macro.py to see how this works in practice.


I could describe everything in more detail, but probably best to get back to me if you have any questions.


Paul

Thanks Paul - that's another great suggestion which also works well. Very interesting to see an alternative approach, it's really useful for learning about how the scripts and macros can work together. Thanks for your help and for the extract from the training manual - that helps a lot.