Got few layer (3) in a map in ArcGIS Pro project. Before I export the layout that its MapFrame is reference to the map holding these 3 layers I am trying to set the top 2 layers transparency so the bottom layer will be visible later when the layout is exported (as PDF file that is). I also tried to change the bottom layer to color black.
The changes does not takes place. I don't see that the layers I call a change in transparency (lyr1 & lyr2; see code below) actually become less opaque. If I look at the color properties if each of these layers the transparency value is 0 and not the 70 or 60 I set it to. lyr3 is not turning black.
I am adding the code here, if anyone can suggest what am I doing wrong and how I can fix it, I'll appreciate it.
import arcpy
import arcpy.mp as map
from arcpy import env as ENV
try:
#init variables:
ENV.workspace = r"C:\Users\User\Desktop\PythonClassHWEx\L10_ClassWork\Ex10\Ex10.gdb"
ENV.overwriteOutput = True
arcpy.env.addOutputsToMap = False
aprx = map.ArcGISProject(r"C:\Users\User\Desktop\PythonClassHWEx\L10_ClassWork\Ex10\Ex10_updated.aprx")
map2 = aprx.listMaps('Map2')[0]
lyr1 = map2.listLayers('layer1')[0]
lyr2 = map2.listLayers('layer2')[0]
lyr3 = map2.listLayers('layer3')[0]
#Set layer 1&2 transparency:
lyr1.transperancy = 70
lyr2.transperancy = 60
lyr3.symbology.renderer.symbol.color = {'RGB' : [255, 0, 0, 0]}
#Export layout2 to PDF
output = r"C:\Users\User\Desktop\PythonClassHWEx\L10_ClassWork\Ex10\Layout2.pdf"
pdflyt = aprx.listLayouts("Layout2*")[0]
pdflyt.exportToPDF(output)
print("Finished exporting layout2 as PDF file\n")
print('Script Done!')
except arcpy.ExecuteError:
print(arcpy.ExecuteError.args[0])
except Exception as e:
print("Error: " + e.args[0])