Is there a way to programmatically access and change the properties of a symbol (or part of it, e.g. pattern agnle) as shown in the window below?
I am aware of the symbol class and its properties.
No. You found CIM. That is all for python access.
help(arcpy.cim) arcpy.cim.GetJSONForCIMObject(l_cim, "V2")
Wow... that was quick. Thank you, @DanPatterson, for pointing me to Esri's Cartographic Information Model.
The section Additional Resources and Sample Scripts links to the GitHub repository and a sample project with a script to create a dashed effect:
# Author: Esri # Date: March 2020 # Version: ArcGISPro 2.5 # Purpose: This script creates or modifies the dash effects for a line symbol. # Notes: - The script is intended to work from a script tool provided with # a sample project using "CURRENT". To see the changes happen be # sure to activate the appropriate map or layout. # - In addition to this sample script demonstating how the CIM # provides access to capabilities not in the managed Python API, # is also demonstrates a method for creating CIM objects that are # necessary to set desired properties. p = arcpy.mp.ArcGISProject('current') m = p.listMaps('Symbology')[0] l = m.listLayers('States_SingleSymbol')[0] l_cim = l.getDefinition('V2') #Get the Layer's CIM definition #Symbol Level 1 (Solid Stroke) symLvl1 = l_cim.renderer.symbol.symbol.symbolLayers[0] #If a dashed effect does not exist, create one if len(symLvl1.effects) == 0: newDash = arcpy.cim.CreateCIMObjectFromClassName('CIMGeometricEffectDashes', 'V2') newDash.dashTemplate = [5, 5] symLvl1.effects = [newDash] #If a dashed effects does exist, modify it else: dash = symLvl1.effects[0] dash.dashTemplate = [10, 10] l.setDefinition(l_cim) #Set the Layer's CIM definition
This serves as a good starting point. Do you know of an easy way to expose the JSON structure of existing symbol styles? Or how to gain insight into the hierarchy?
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.