I came up with a little bit of an improvement for the provinceDef file and workflow that should work for most mods. So I guess this is a mini tutorial of sorts. The idea is to bring in your entire provinces setup instead of breaking it up into smaller kingoms/duchys. The way I do this is by using different hue value for each duchy so this technique should work on any map with up to 360 duchies.
First thing I did is decide how many empires I'm going to have. In my mod I have 10 empires and I need an extra color for the oceans/rivers. So that's 11 groups. Then I divide 360 by 11 to get approximately 33 duchies per empire and assign the difference between the different hue ranges to different empires. Something like this:
Empire 1: hue 0-33 (reds to orange)
Empire 2: hue 34-65 (orange to yellow)
Empire 3: hue 66-98 (yellow to bright green)
Empire 4: hue 99-130 (greens)
Empire 5: hue 131-163 (grrens to turquoise blue)
Empire 6: hue 164-196 (turquise blue to light blue)
Oceans: hue 197-229 (light blue) you can technically get away with using just one hue value for all oceans and rivers instead you will never need a big range like this example.
Empire 7: hue 230-261 (blue to purple)
Empire 8: hue 262-294 (purple to pink)
Empire 9: hue 295-327 (pinks)
Empire 10: hue 328-360 (pink to red)
Then space the base colors our on the map as much as possible so similar colors aren't bordering each other. You can divide it further into specific kingdoms or however you want to group them. I did not divide them by kingdoms but started coloring them in based on duchys. So all counties within "duchy 1" of "empire 1" have a colour with hue "0" but different shade of the color. You keep moving forward duchy by duchy like that so all provinces in 2nd duchy have a hue of "1" and so on.
Then after you clear out your provinceDef file and paste in your list of colors using the color extractor batch file you should have something like this:
Then select all of the red fields:
Then right click on "sheet 1" in bottom of your excel window and click "View Code"
A blank VBA macro window should open up. Paste the following code into the box and run it.
Code:
Sub Hue()
For Each cell In Selection
R = cell.Value
G = cell.Offset(0, 1).Value
B = cell.Offset(0, 2).Value
Cells(cell.Row, 1).Resize(1, 5).Interior.Color = RGB(R, G, B)
R = R / 255
G = G / 255
B = B / 255
If (R >= G And R >= B) Then
Max = R
End If
If (G >= R And G >= B) Then
Max = G
End If
If (B >= R And B >= G) Then
Max = B
End If
If (R <= G And R <= B) Then
Min = R
End If
If (G <= R And G <= B) Then
Min = G
End If
If (B <= R And B <= G) Then
Min = B
End If
L = (Min + Max) / 2
If L < 0.5 Then
S = (Max - Min) / (Max + Min)
Else
S = (Max - Min) / (2 - Max - Min)
End If
If (Max = R) Then
H = (G - B) / (Max - Min)
End If
If (Max = G) Then
H = 2 + (B - R) / (Max - Min)
End If
If (Max = B) Then
H = 4 + (R - G) / (Max - Min)
End If
H = H * 60
If H < 0 Then
H = H + 360
Else
H = H
End If
cell.Offset(0, 20).Value = H
Next cell
End Sub
What the macro will do is colour in columns "A" to "E" in the RGB colour specified in the excel document. And then calculate the "Hue" value and put in the "W" column in the document.
The last step is to select everything and sort by the hue. (and then by any other colour you want in case hue value is identical)
What you should be left with is something like this. Each hue value represents a separate duchy, and its all nice and tidy.
If you add colours/provinces or make any changes you can always select the relevant "R" cells and run the macro again. You will likely have to delete the hue column when you're actually running map filler tool. Hope this is handy to someone.