I am writing a script using python that takes unique values from a table and goes through selecting lines and assigning your chosen color to each value. I do realize that this is essentially what themes are for but I am trying to avoid those for this. I was wondering if someone could help me with the part I am struggling with, assigning a color or pen style to a selection at the end of my pasted code where I have "make it this color"?
Thanks!
import os
from osgeo import ogr
from mi_common_util import CommonUtil
from System.Collections.Generic import List
from System import *
from MapInfo.Types.Data import *
from MapInfo.Types import MapInfoDictionary
from MapInfo.Types import *
colorList = [16711680, 16776960, 65280, 65535, 255, 16711935, 8388608, 8388736, 8421504]
tableCount = (pro.Catalog.Tables.Count)
print ("Pick a number from the opions below")
for x in range(tableCount):
print ("Table " + str(x) + ": " + pro.Catalog.Tables[x].Alias)
i = input("type the number for the desired table")
uniqueRows = []
rowTotal = (pro.Catalog.Tables[int(i)].RowCount())
for y in range(rowTotal):
CommonUtil.do("Fetch Rec " + str(y) + " From UNIQUE_values")
sValue=eval("UNIQUE_values.Level")
uniqueRows.append(sValue)
print (uniqueRows)
variables = List[MapInfoDictionary[String, Object]]()
newVariables = []
c=0
for g in range(rowTotal):
c += 1
if g < 9:
vColor = MapInfoDictionary[String, Object]()
vColor['Name'] = ("Color" + str(c))
vColor['Type'] = ("Color" + str(c))
vColor['Prompt'] = ("_Color" + str(c) + ":")
vColor['Value'] = colorList[g]
variables.Add(vColor)
else:
vColor = MapInfoDictionary[String, Object]()
vColor['Name'] = ("Color" + str(c))
vColor['Type'] = ("Color" + str(c))
vColor['Prompt'] = ("_Color" + str(c) + ":")
vColor['Value'] = 255 # blue
variables.Add(vColor)
if pro.Input('Input Style', variables, None):
for v in variables:
new_List = ('{}'.format(v['Value']))
newVariables.append (new_List)
print (newVariables)
my_dict = dict(zip(uniqueRows, newVariables))
print(my_dict)
for key, value in my_dict.items():
CommonUtil.do(f"select Alberta.Level from Alberta where ALberta.Level = {key}")
#print (f"make it this color {value}")
#CommonUtil.do(f" Update Selection Set Style Pen (1,2,{value})")
------------------------------
Tanner Mork
Knowledge Community Shared Account
Burlington MA
------------------------------