Select to view content in your preferred language

Legends in arcpy for arcgis pro 1.4

1129
3
02-14-2017 01:45 AM
Marliesde_Keizer
Deactivated User

I am adding map layers in an arcpy script within arcgis pro 1.4. The layer is added to the legend, but how can I then format the legend items in the arcpy script? I could do this in arcpy for arcmap using the mapping module, but that isn't available in arcgis pro?! Is there another way?

More concrete, how can I translate the script below to something that works in arcpy for acrgis pro:

styleItem = arcpy.mapping.ListStyleItems("USER_STYLE", "Legend Items", "NewDefaultLegendStyle")[0]lyr = arcpy.mapping.ListLayers(mxd, 'Rivers', df)[0]legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]legend.updateItem(lyr, styleItem)
3 Replies
DanPatterson_Retired
MVP Emeritus

A quick note... arcpy.mapping in arcmap is now arcpy.ma in PRO have a look at the object model, but it may be as simple as changing mapping to ma

0 Kudos
Marliesde_Keizer
Deactivated User

mapping is changed to mp, right? That is also where the link is forwarding to. Just changing mapping into mp is not working. It seems to be a differently set up module. Any other suggestions?

0 Kudos
DanPatterson_Retired
MVP Emeritus

It is a matter of browsing around, but there is a diagram on this link that may help with navigation, since things have 'moved around' as they indicate

0 Kudos