I have several python scripts that I would like to have run outside of ArcGIS Pro. Its mainly to export map series weekly without having to manually open the project. I keep hitting a dead end because most of my python scripts do nothing even when ran in the project if I set arcpy.mp.ArcGISProject to reference the path of the project. All of my scripts work if I change the pathname to ("Current") but obviously that can't be run outside of Pro. Here are two samples of python scripts I am trying to get to work.
## BLOCK DETAILS TO BLOCK NAMES ##
aprx = arcpy.mp.ArcGISProject("C:\\GIS Local Directory\\RanchMaps.aprx")
for m in aprx.listMaps("Default Map"):
lyr = m.listLayers("Block Boundary")[0]
z = ["default"], ["details open"], ["Ranches Zoomed In"], ["Center Unlocked"], ["Center Locked"], ["Center Left Locked"]
for i in z:
if lyr.supports("SHOWLABELS"):
lblClass = lyr.listLabelClasses(i[0])[0]
lblClass.visible = False
if lyr.supports("SHOWLABELS"):
lblClass = lyr.listLabelClasses("block name")[0]
lblClass.visible = True
import arcpy
aprx = arcpy.mp.ArcGISProject("C:\\GIS Local Directory\\RanchMaps.aprx")
m = aprx.listMaps("Default Map")[0]
lyrList = m.listLayers()
for lyr in lyrList:
if lyr.longName == "Ranches (Sun Pacific)\\Block Details":
lyr.visible = False
if lyr.longName == "Ranches (Sun Pacific)\\Block Names":
lyr.visible = True
aprx.save()
del aprx
Again they both work as intended if I change the project path name to ("CURRENT")
Thanks for any help