I am working on applying symbology to multiple layers from lyr files for multiple MXDs within the IDE. I have been able to access the MXDs and iterate through and change the definition of "mxd". I am receiving the following error, however, when the ApplySymbologyFromLayer_management
process is run:
ERROR 000732: Input Layer: Dataset FCname does not exist or is not supported
My script is as follows:
# the MXDs to change, accessed and processed individually as 'i' is script not shown
mxd = arcpy.mapping.MapDocument(r'C:\Path\to\mxd\doc.mxd')
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == 'FCname':
arcpy.ApplySymbologyFromLayer_management(
in_layer="FCname",
in_symbology_layer="C:\Path\to\lyrs\FCname.lyr")
I have repeated the same ApplySymbologyFromLayer_management
tool within ArcMap successfully. Any ideas on why this process is not succeeding within my script?
1 Answer 1
You want to execute your code in Standalone.So you can't use input layer name, just use layer without any properties like name,... . save your mxd after the symbology changes. You can save the current mxd or save to another mxd file (Save a Copy).
# the MXDs to change, accessed and processed individually as 'i' is script not shown
import arcpy
mxd = arcpy.mapping.MapDocument(r'C:\Path\to\mxd\doc.mxd')
for lyr in arcpy.mapping.ListLayers(mxd,"FCname"):
arcpy.ApplySymbologyFromLayer_management(lyr,r"C:\Path\to\lyrs\FCname.lyr")
mxd.saveACopy("C:/MychangeSymbology.mxd")
-
-
IDE and standalone words are keywords you can use their to improve your question and help othersBBG_GIS– BBG_GIS2017年11月14日 19:08:36 +00:00Commented Nov 14, 2017 at 19:08
Explore related questions
See similar questions with these tags.