Is it possible to set a Symbol Template for a GraduatedSymbolsRenderer using ArcPy for ArcGIS Pro?
The reason I ask is that running the test code below gives an error of:
Traceback (most recent call last):
File "C:\Temp\test.py", line 10, in <module>
symTemp = sym.renderer.symbolTemplate
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\arcobjects\_base.py", line 90, in _get
return convertArcObjectToPythonObject(getattr(self._arc_object, attr_name))
RuntimeError
To run the code I created a test project and added one layer into it which had the ne_10m_populated_places.shp from Natural Earth as its data source.
This is the test code, and it is very close to a code sample from the GraduatedSymbolsRenderer documentation:
import arcpy
aprx = arcpy.mp.ArcGISProject(
r"C:\Temp\Projects\TestProject\TestProject.aprx")
mapx = aprx.listMaps("Map")[0]
lyr = mapx.listLayers("ne_10m_populated_places")[0]
sym = lyr.symbology
sym.updateRenderer('GraduatedSymbolsRenderer')
symTemp = sym.renderer.symbolTemplate # Line giving error
symTemp.applySymbolFromGallery("Circle 1")
symTemp.color = {'RGB' : [38,115,0,0]}
sym.renderer.updateSymbolTemplate(symTemp)
sym.renderer.classificationField = "POP2020"
sym.renderer.breakCount = 10
sym.renderer.minimumSymbolSize = 4
sym.renderer.maximumSymbolSize = 16
lyr.symbology = sym
aprx.save()
I ran my test using ArcGIS Pro 2.4.1 on Windows 10 Pro for Workstations.