Hatch Colors

keith fowlow 8 years ago in General updated by Erik Scheel 6 years ago 5
Hi Group,
I am wondering if there is a way to upload colors from say a spreadsheet. I have some polyline geology that I can import with the attributes. There are a lot of geology units so if I can just upload a legend with the units and colors into MM that would be much better than making a legend from scratch.

Any help is appreciated.
Hi Keith,

The easiest way to do this is by running the attached Python script. RGB-2-Hatch-Set.py

The script requires two files:

1. An input text file containing the following information in separate fields. (Tab delimited is best becase geological descriptions often contain commas, which throw off the column order if you use a comma delimited file.)

This defines your source data:

Redred brightness (numeric; 0 to 255)
Greengreen brightness (numeric; 0 to 255)
Blueblue brightness (numeric; 0 to 255)
CodeGeo code (text up to 255 characters)
DescriptionDescriptive text (up to 255 characters)

2. A Micromine data (.DAT) file with the following file structure.

Other fields may be present (and will be ignored) but you must include the listed fieldnames. This is the file that will be converted to a hatch set:

N (Numeric)4
GNN (Numeric)4
BLN (Numeric)4
GEOC (Character)25 (set the width to suit the longest geological code)
DESCRIPTC (Character)255

Here is how you use it. These instructions are also included at the top of the script, which may be viewed in the Micromine script editor or any text editor:

1. Save the script to your Micromine project (or somewhere convenient).

2. In Micromine, create a DATA file in your working project using the file structure described above.

3. Use File | Import | Text to import the tab-delimited version of the colours, codes, and descriptions into the new Micromine file.

4. Select Scripting | Open Script Editor from the main menu (or press F11), and then click the Load Existing Script button on the Script Editor toolbar to load the script into the script editor.

5. Change the filename on line 56 (the part between the quotes) to match the file you created in Step 3:
input_file_name = "Imported-Geological-Colours.DAT"

6. Change the form set name on line 57 (between the quotes) to suit your project data:
created_form_set_name = "Geological codes and colours"

7. Click the Run Script toolbar button, or press F5, to run the script.

8. The new form set is now available via Tools | Hatch Sets | Text or the relevant Vizex display.

I've also included a file containing some sample codes and colours so you can see the script working. Imported-Geological-Colours.DAT



Something just occurred to me: If your codes and colours are already in a spreadsheet, you can just copy and paste them into the Micromine DATA file instead of going through the whole import text process. (I started with an existing text file when I wrote my initial post.)

There is another way to get a lot of colours into a colour set (which you can easily convert to a hatch set) if you're not comfortable with using Python: Copy and paste the values, colours and labels from the spreadsheet directly into the colour set editor.

There are really only two tricks to this process:

  1. You must click on each column heading to select it before pasting the contents into it. The process won't work if you select an individual cell.
  2. You must convert the red, green and blue colours into a long integer value. This is easily done in Excel using the following formula:

For example:

242 + (195 * 256) + ( 20 * 65526) = 1360882

You will, of course, have to use actual cell addresses for the [RED], [GREEN] and [BLUE] values. To make this easier I've set up the calculation on the RGB to Micromine tab of this Excel workbook: RGB-Hex-to-Micromine-Colours.xlsx

Once you've calculated the values for all of your colours, just select that entire column in Excel and copy the numbers. Then, in Micromine, click the colour heading row (the one with no label) and then press Ctrl+V to paste the colours, as shown here:

You can then do the same with the codes (Value) and their descriptions (Label).

To convert the colour set to a hatch set, just select Tools | Colour Sets | Convert to Hatch Set. You can then display the new hatch set in the hatch set editor and right-click a hatch to adjust its borders etc.

If you're importing colours from a Google Earth KML file into Excel you'll see the colours listed in hexadecimal character string format, along with an opacity value, in A-B-G-R order, where A = Alpha (opacity) and B, G, and R are the colours:


In this format, "ff" is the opacity, "14" is blue, "c3" is green, and "f2" is red.

(Be aware, other applications such as drawing software may list the colours in the opposite order. The opacity value is usually a pretty good indicator of which end is which because "ff" is pure white, which is not normally used for geological colours.)

You can easily use Excel to convert Google Earth hexadecimal ABGR colours to decimal, which you can then convert to a Micromine long integer using the preceding calculation. You'll need to use a few different Excel functions:

  • DECIMAL(Number, Radix): Converts a hex Number to a decimal value. Radix = 16 for hexadecimal numbers.
  • RIGHT(Text, Num_chars): Extracts the right-most characters from a text string. Num_chars = 2 will extract the last two characters.
  • MID(Text, Start_num, Num_chars): Extracts characters from the middle of a text string. Start_num = 3 and Num_chars = 2 will extract the third and fourth characters.
  • LEFT(Text, Num_chars): Extracts the left-most characters from a text string.

The calculations will look like this (remembering to use actual cell addresses). You'll find them on the HEX ABGR to Micromine tab of the attached workbook:

[BLUE] =DECIMAL(MID([HEX] 3,2),16)



I can't get a wildcard to work in the hatch set, is there something I'm missing?

Hi Geoff,

I suggest that you change your values for DIOR, LAMP, DYKE, and SY to all read *DIOR* and skip the "|" separators.