Select to view content in your preferred language

Cannot apply symbology without background geoprocessing

3896
2
02-25-2015 09:03 AM
DavidMartin
Frequent Contributor

I'm using 10.2.2 - ArcMap. If I run the Apply Symbology to Layer tool in ArcMap, with background geoprocessing enabled, it works as expected. However, disable background geoprocessing and while the tool appears to run without error, the layer's symbology is not updated.

Is this expected behaviour? Or a bug?

It means that if I have a script tool that must run in the foreground (e.g. because it addresses the current map document) then symbology cannot be applied to the output layer.

0 Kudos
2 Replies
DavidChambers1
Deactivated User

Hi David,

I just tested this at 10.2.2 with two polygon layers and it appears to work as expected with Background Processing disabled (tool running in the foreground) in the Geoprocessing > Geoprocessing Options window. Is this the background geoprocessing you are referring to? In addition:

1. What type of geometry do the input layer and symbology layer have?

2. What type of symbology does the symbology layer have?

0 Kudos
DavidMartin
Frequent Contributor

My apologies. I've investigated further and realised that the symptoms only arise with a very specific scenario that I only hit on accidentally and that it is easy enough to step around. My script  uses arcpy.mapping.MapDocument("CURRENT"), and  I had been outputting the feature class, rather than the feature layer. A new layer therefore got added to the ArcMap TOC based on the feature class, while in memory, a feature layer of the same name was still hanging around. When I subsequently ran the Apply Symbology to Layer tool in the foreground, I guess it applied the symbology to the in memory layer, while if I ran it in the background, it would apply it to the ArcMap TOC layer. An odd one! If you have any interest in replicating it, you can do so with this script.

import arcpy

# **********************************************************************************************************

# Remove this next line, and you can apply symbology afterwards, whether foreground or background processing

# Leave it, on the other hand, and you can only apply symbology afterwards when in background processing

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

# **********************************************************************************************************

fcPath =  arcpy.env.scratchGDB + r"\testing"

arcpy.MakeFeatureLayer_management(fcPath, "testing")

arcpy.SetParameter(0,fcPath)

Thanks for your help, David.