2

I've got various polyline shapefiles loaded in ArcGIS, each using the default line style with different colors. For a python addin I'm working on I would like to use arcpy to read the RGB value of these colors. Would that be possible?

I noticed this question: Read layer symbology class color with ArcPy But it deals with raster layers and therefore I assume my question is not a duplicate (please let me know if this is still the case)

joosthoek
  • 307
  • 1
  • 10

1 Answers1

3

This answer is as of ArcGIS Desktop 10.3.1. It could change in the future since arcpy.mapping is constantly evolving.

If you are using default line styles, then your layer.symbologyType should be equal to u'OTHER'.

There is no way through arcpy or arcpy.mapping to access the symbology properties for a layer with u'OTHER' symbology. You should get a result of "NameError: The attribute 'symbology' is not supported on this instance of Layer" when trying to access the symbology attribute for that layer.

Even if the symbology was one of the types supported by arcpy.mapping, none of the supported types currently supports reading the color values of individual symbols.

blord-castillo
  • 6,447
  • 22
  • 42
  • Ah ok, so it's not possible. Thanks for your answer! – joosthoek Oct 23 '15 at 06:27
  • 1
    There is another option, but I am not sure you want to go this deep. You could construct a wrapper around ISymbologyControl http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/d/001600000324000000.htm using something like Iron Python (http://ironpython.codeplex.com/) or Python for .Net (http://pythonnet.sourceforge.net/readme.html). Or you can go the C++ route (http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/ISymbologyControl_Interface/000600000324000000/) with something like this https://github.com/arcpy/arcpy-cpp-interop – blord-castillo Oct 23 '15 at 15:41
  • I understand how that could work yes. But it would indeed go a bit too deep. Thanks for mentioning the links and this idea though, it might come in handy sometime! – joosthoek Oct 24 '15 at 17:39