Hi,
I have been using arcpy.mp to automate map production but am having trouble with the listColorRamps() method.
I am running Python 3.6.5 and ArcPro 2.2.1.
If I run this code in the python window within an open aprx, I get a long list of available Color Ramp objects:
aprx=mp.ArcGISProject("CURRENT")
aprx.listColorRamps()
However, if I run similar code in IDLE, aprx.ListColorRamps() returns an empty list, and the rest of my map automation therefore fails.
aprx=mp.ArcGISProject(path+"/template.aprx")
aprx.listColorRamps()
Has anyone else experienced this and/or know of a workaround?
Thank you!
something is amiss
pth = r"C:\GIS\A_Tools_scripts\aprx_info\aprx_info.aprx"
proj = arcpy.mp.ArcGISProject(pth)
cr = proj.listColorRamps()[:2]
cr
Out[16]:
[<MappingColorRampObject at 0x298e44a1fd0>,
<MappingColorRampObject at 0x298e44a1d00>]
check your path to begin with and I noticed that you don't have arcpy before mp… could be a namespace issue.
I recommend not shortcutting shortcuts in code. And you can get its name and that is about all
cr0 = cr[0]
cr0.name
Out[21]: 'Accent (3 Classes)'
Thanks for the help. However, I tried the code as you describe above using the full arcpy.mp call and still no luck ... I get an empty list when calling listColorRamps().
Then if it doesn't work with a direct reference to the *.aprx nor with "CURRENT", that leaves something else... maybe even your installation.
Try a different project for a starter.
If you can try with a different user on your computer, I would as well.
If you have cohorts where you are, try on their machine.
Got to rule out the project, the machine and the user. You hopefully have done the reading from the *.aprx and "CURRENT" to rule that out.
Post back with more info Molly.
I'm experiencing the same problem now, in ArcGIS Pro 3.3. I have a script that, among other things, uses the listColorRamps method to get a hold of a specific color scheme and applies it to a renderer. It runs fine on my computer, both from the Python window in ArcGIS Pro and as a standalone script (from both VS Code and Python Command Prompt). On another computer it only works from the ArcGIS Pro Python window, but not when running it outside of Pro, then I get a list index out of range error for the color scheme I'm trying to get.
"Sign me in automatically" is checked when signing into ArcGIS Pro, and I'm not seeing a "RuntimeError: NotInitialized exception", so Python should be authorized to run outside ArcGIS Pro, if I'm reading this documentation correctly: https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/installing-python-for-arcgis-pro.htm
@MollyBarth did you find a solution to this?