
Can a Python script running in Windows open Micromine and display data?
The answer, below, might be of interest to others.
A Python script can start-up a new instance of Micromine (or run any executable) using code like this:
import subprocess
My_Windows_Command = "\"C:\\Program Files (x86)\\Micromine 2013\\mmwin.exe\""
if subprocess.call(My_Windows_Command, shell=True) == 0:
print('Successful')
else:
print('FAILED')
(That assumes you've got Python installed, and it should be version 3.3.1 so that you can use it when running Python within Micromine.)
If
you want to automatically perform an action when Micromine opens then
you can get it to run a macro upon start-up, as described below. You can't run
a script when starting Micromine yet but I expect that will be added. However, you could make a macro that runs a Python script within Micromine (using the macro command RUNSCRIPT_FROMFILE).
Run a macro from the command line
To run a macro from the command line, enter the name of the project and the name of the macro as command line parameters:
For example:
mmwin -project "Examples" -macro "name_of_macro"
I've attached an example script that does that:
Open_Micromine_from_Windows+Run_Batch.py
Customer support service by UserEcho
In MM2013 SP3 (when that is released in future) you will be able to run a script directly when opening Micromine, by using a command line like:
mmwin -script "name_of_script.py"
or
mmwin -project "Examples" -script "name_of_script.py"