When I add a layer this by default is "OTHER", I want to apply unique value by default programmatically by some field.
import arcpy dirmxd = "D:\Borrrar\D143\Ejecutables\D143v10_3.mxd" fc = "D:\Borrrar\D143\BaseMapas.gdb\estruclin" mxd=arcpy.mapping.MapDocument(mxd) df = arcpy.mapping.ListDataFrames(mxd)[0] layer = arcpy.MakeFeatureLayer_management(fc,"estruc") lyr = arcpy.mapping.Layer(layer) arcpy.mapping.AddLayer(df, lyr, "AUTO_ARRANGE") tipo = lyr.symbologyType ### print OTHER
I don´t have a lyr, I have a general style that I want to apply with class styleItem: legend.updateItem(lyr, styleItem)
I seen a example: http://desktop.arcgis.com/es/desktop/latest/analyze/arcpy-mapping/styleitem-class.htm
but first I need a layer classify by unique value.
Perhaps I have to generate the classified layer before add, but I don't know how to do it without ever having another layer of reference.
Thanks and regards...
Aura ... have you explored some of the appropriate portions of the arcpy classes and methods? for example
UniqueValuesSymbology—Help | ArcGIS for Desktop
import arcpy mxd = arcpy.mapping.MapDocument("current") lyr = arcpy.mapping.ListLayers(mxd, "Population")[0] if lyr.symbologyType == "UNIQUE_VALUES": lyr.symbology.valueField = "SUB_REGION" lyr.symbology.addAllValues() arcpy.RefreshActiveView() arcpy.RefreshTOC() del mxd
Of course I've seen the class , this can only be used if the layer previously is defined with "UNIQUE_VALUES ". But as I explained earlier when I add the default layer symbology is OTHERS, I would like to generate a unique symbology when I make the layer . ¿Could you help me with an example?
I only see UpdateLayer—Help | ArcGIS for Desktop which implies you have to have something already prepared to use. I can't find anything offhand to actually create the classification within arcpy mapping or arcpy ma (in PRO), but I don't do much mapping automation, so I will have to defer to those that do.