Currently I have to enter color values manually to an ArcGIS Pro Style (.stylx), which is time consuming and laborious. I suggest the ability to add colors to an ArcGIS Pro style with a batch process or as a file. I envision something similar to the process of adding swatch files (.ase) to Adobe Illustrator. Alternatively the user could prepare a .csv with HEX, RGB, CMYK values, etc., color mode, and the other field values in Catalog that must currently be entered manually.
I agree this would be very useful! I found this post a while back, it seems that this can be done with python, but I never figured it out myself. Seeing your post inspired me to take another stab at it. If you update the path to your stylx file and your spreadsheet, something like this should work for you.
import sqlite3
import pandas as pd
import json
# Connect to stylx file (tested this on a copy of favorites)
stylx_file = r"C:\Users\username\AppData\Roaming\Esri\ArcGISPro\Favorites - Copy.stylx"
conn = sqlite3.connect(stylx_file)
cursor = conn.cursor()
# Get the items table
cursor.execute("SELECT * FROM Items LIMIT 1000;")
items = cursor.fetchall()
new_id = len(items)+1
# Load in your colors, assuming you have a spreadsheet with the referenced fields
excel_file = r"C:\Users\username\AppData\Roaming\Esri\ArcGISPro\addColors.xlsx"
df = pd.read_excel(excel_file)
df.fillna('', inplace=True)
# Loop through and insert rows
for row in df.itertuples():
content = {'type':'CIMCMYKColor','values':[row.C, row.M, row.Y, row.K,100-row.alpha]}
new_row = (new_id,1,row.Category,row.Name,row.Tags,json.dumps(content))
cursor.execute('INSERT INTO ITEMS(ID, CLASS, CATEGORY, NAME, TAGS, CONTENT) VALUES(?,?,?,?,?,?)', new_row)
new_id += 1
# save and close
conn.commit()
conn.close()
@BrennanSmith1 That's great! I'll check it out! Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.