arcpy.mp listColorRamps() returns empty list ?

301
3
08-29-2018 12:31 PM
MollyBarth
New Contributor III

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!

Tags (2)
0 Kudos
3 Replies
DanPatterson_Retired
MVP Esteemed Contributor

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)'
0 Kudos
MollyBarth
New Contributor III

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().

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

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.