有图层样式生成符号库
import arcpy import sqlite3 aprx = arcpy.mp.ArcGISProject(r"CURRENT") m = aprx.activeMap groupLayer = arcpy.GetParameterAsText(0) lyrs = m.listLayers() stylx_path = arcpy.GetParameterAsText(1) stylxDB = sqlite3.connect(stylx_path) cursor = stylxDB.cursor() category_switch = {4: "一级类", 5: "二级类", 6: "三级类", } class_switch = {"Point": 3, "Polyline": 4, "Polygon": 5} for lyr in lyrs: longName = lyr.longName if longName.startswith(groupLayer) and lyr.isGroupLayer == False: type = arcpy.Describe(lyr).featureClass.shapeType classValue = class_switch.get(type) sym = lyr.symbology if sym.renderer.type == 'SimpleRenderer': try: cim = lyr.getDefinition("V2").renderer.symbol.symbol content = arcpy.cim.GetJSONForCIMObject(cim, "V2") name = lyr.name key = lyr.name category = category_switch.get(len(name)) new_row = (classValue, category, name, content, key) cursor.execute( 'INSERT INTO ITEMS(CLASS, CATEGORY, NAME, CONTENT, KEY) VALUES(?,?,?,?)', new_row) stylxDB.commit() arcpy.AddMessage("√ "+lyr.name) except: arcpy.AddMessage("× "+lyr.name) stylxDB.close() ———————————————— 版权声明:本文为CSDN博主「学学GIS」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/baidu_28157641/article/details/125951148