I am trying to automate the export of several rasters applied to a certain Layout.mxd using the following steps (simplified):
mxd = arcpy.mapping.MapDocument(r'D:\MyFolder\MyLayout.mxd')df = arcpy.mapping.ListDataFrames(mxd)source_lyr = arcpy.mapping.ListLayers(mxd, "sym_lyr", df)target_lyr = arcpy.mapping.ListLayers(mxd, "tar_lyr", df)arcpy.mapping.UpdateLayer(df, target_lyr, source_lyr)
The target_lyr- Layers are imported rasters and the import works perfectly - the same for the PDF-export directly after this code sample.
The problem is that "UpdateLayer" basically has no effect at all. When I try to run the above code in ArcMap Desktop, it won't work neither unless I replace
mxd = arcpy.mapping.MapDocument(r'D:\MyFolder\MyLayout.mxd')
mxd = arcpy.mapping.MapDocument("CURRENT")
However, I can't apply "CURRENT" in my Python script because it is not running in Foreground of the opened "MyLayout.mxd". It is also impossible for me to implement my Python Script as an AddIn of ArcMap because the export-map only is a subroutine of a complex program that needs to output maps.
In addition, I tried the following:
Does anyone have an idea how else I can apply the symbology of source_lyr to target_lyr or how I can define step-by-step the symbology using a defined classified colorjet (the colors are very important in this case)?
Otherwise, does anyone know what exactly makes that "CURRENT" works but the "ABSOLUTE_PATH" does not, resp., how I can fix the issue?
(I'm using the ArcGISx6410.5 python interpreter)
I am grateful for any idea or proposition.