AnsweredAssumed Answered

Python script running in Python window but not working as stand-alone script

Question asked by ryglan on Sep 21, 2020
Latest reply on Sep 21, 2020 by bixb0012

Hello, 

 

I don't know why this script doesn't work. When I run it from a window in arcgis pro it works but like stand-alone script it doesn't work. It does not print any error, but no layer is selected and created in the resulting pdf. Can anyone advise me please?

 

import arcpy
import os
import sys
import math
from datetime import datetime

arcpy.env.overwriteOutput = True

aprx = arcpy.mp.ArcGISProject(r"C:\\Users\\aneta.ryglova\\Desktop\\layout_zk.aprx")
lyt = aprx.listLayouts("Layout1*")[0]

arcpy.env.workspace = 'C:\\Users\\aneta.ryglova\\Documents\\ArcGIS\\Projects\\MyProject\\MyProject.gdb'

klad_ztm10 = arcpy.SelectLayerByAttribute_management("klad", "NEW_SELECTION", "zm10 = '25-32-19'")

klad_ztm10_vyber = arcpy.CopyFeatures_management(klad_ztm10, "C:\\Users\\aneta.ryglova\\Documents\\ArcGIS\\Projects\\MyProject\\MyProject.gdb\\klad_ztm10")

arcpy.FeatureVerticesToPoints_management(klad_ztm10_vyber, "C:\\Users\\aneta.ryglova\\Desktop\\layout pdf\\body1.shp", "ALL")

= aprx.listMaps('Map')[0]
lyr_pryc = m.listLayers("klad_Layer*")
for layer in lyr_pryc:
    layer.visible = False

lyt.exportToPDF(r"C:\\Users\\aneta.ryglova\\Desktop\\layout pdf\\zk11.pdf", resolution = 100, image_quality = 'FASTEST')

Outcomes