Get style of the layer using Arcpy

175
5
Jump to solution
01-18-2021 06:44 PM
PhongTrần
New Contributor II

Hello,

I am trying to extract the style from the selected layer using Arcpy; but, it seems like there are no properties like color, size, font, etc,...

I run this code on the Python console in ArcMap:

 

mxd = arcpy.mapping.MapDocument("CURRENT")
layers = arcpy.mapping.ListLayers(mxd)

exampleLayer = layers[0] # This is Feature layer
# I want to get properties like color, size,... from the layer
# But it is not supported

 

 

I am hoping someone can help me out! 

Many thank!

Reply
0 Kudos
2 Solutions

Accepted Solutions
DanPatterson
MVP Frequent Contributor
Reply
0 Kudos
PhongTrần
New Contributor II

Thanks for your help, it looks like I have to use arcpy.mp (Python 3) instead of arcpy.mapping (Python 2) to read these properties like color, size, or font.

It means I have to use ArcGIS Pro instead of ArcGIS Desktop because of this 

View solution in original post

5 Replies
jcarlson
Regular Contributor

Refer to the arcpy documentation for the Layer class. You'll see that by calling various properties, like exampleLayer.symbology and exampleLayer.symbologyType, you can access the layer's properties you're looking for.

- Josh Carlson
Kendall County GIS
Reply
0 Kudos
PhongTrần
New Contributor II

Thanks for your quick response, but I have tried it before.

In my case, the exampleLayer.symbology is UniqueValuesSymbology . It has properties like description, labels, value, and the value field. But what I want is properties like color, size, font,...

Reply
0 Kudos
DanPatterson
MVP Frequent Contributor
Reply
0 Kudos
PhongTrần
New Contributor II

Thanks for your help, it looks like I have to use arcpy.mp (Python 3) instead of arcpy.mapping (Python 2) to read these properties like color, size, or font.

It means I have to use ArcGIS Pro instead of ArcGIS Desktop because of this 

View solution in original post

DanPatterson
MVP Frequent Contributor

Thats right... CIM has only been recently introduced and not backported to ArcMap.

Time to move on, python 2.7 is done in any event and ArcMap will be terminal soon 😉


... sort of retired...