|
POST
|
I went through my script line by line, commented out functions, and re-ran through Task Scheduler with 'Run whether user is logged on or not', until it no longer worked. It finally "failed" when I un-commented the 'exportToPDF' function. Although, it doesn't really fail, Task Scheduler will still show the Last Run Result as successful, it just doesn't seem to actually export anything. I tried exportToJPEG and exportToPNG, both with the same result as exportToPDF. Below is a copy of a log my script outputs when I leave the 'exportToPDF' function commented out. Even though it may say successfully exported a PDF, it's simply indicating where the PDF should be written to. You can see the script has no problem accessing the ArcGIS Pro document, updating layer definition queries, turning layers on or off, setting the map frame extent to that of a layer, adjusting the map frame scale, updating layout text elements, etc... it's the 'exportTo...' function that does not work. Permissions are not an issue. My log is being written to a different server successfully, and the output PDFs are being written to a different server successfully if I change the Task Scheduler property to 'Run only when user is logged on'. So...even though previous comments indicated this would be fixed at ArcGIS Pro 2.0, it doesn't appear that it has been. Exporting layouts through Task Scheduler with 'Run whether user is logged on or not' seems to be a bug, and not possible, at least based on our system environment, shown below. System Environment OS: Windows Server 2012 R2 ArcGIS Pro Version: 2.0 ArcGIS Pro License Type: Single Use Advanced Task Scheduler Action shown below. I see in the Pro docs it's recommended to use the propy.bat file, so I am, with an argument set to the file path of my script. Example log file User: MBoyle
Time: 2017-06-30 10:14:46 AM
Script: E:\GIS-Data\Scripts\DailyReappraisalMaps.py
--------------------------------------------------
2017-06-30 10:14:46 AM: Attempting to truncate ..\Matt\Production\Assessor\Reappraisal\Maps\DailyReappraisal\DailyReappraisal.gdb\asrRprslMapAreaY...
2017-06-30 10:14:48 AM: Successfully truncated ..\Matt\Production\Assessor\Reappraisal\Maps\DailyReappraisal\DailyReappraisal.gdb\asrRprslMapAreaY... (Elapsed time: 1.77 seconds)
2017-06-30 10:14:49 AM: Attempting to load gdb.DBO.svw_asrRprslMapAreaY into ..\Matt\Production\Assessor\Reappraisal\Maps\DailyReappraisal\DailyReappraisal.gdb\asrRprslMapAreaY...
2017-06-30 10:14:54 AM: Successfully loaded 4 rows from gdb.DBO.svw_asrRprslMapAreaY into ..\Matt\Production\Assessor\Reappraisal\Maps\DailyReappraisal\DailyReappraisal.gdb\asrRprslMapAreaY... (Elapsed time: 3.96 seconds)
--------------------------------------------------
2017-06-30 10:14:54 AM: ..Some-Folder\Reappraisal\In-House\Reports\Maps\2017-06-29 already exists; skipping attempt to create...
--------------------------------------------------
2017-06-30 10:14:58 AM: ArcGIS Pro Project: ..\Matt\Production\Assessor\Reappraisal\Maps\DailyReappraisal\DailyReappraisal.aprx
--------------------------------------------------
2017-06-30 10:14:58 AM: Maps:
2017-06-30 10:14:58 AM: Reappraisal
--------------------------------------------------
2017-06-30 10:14:58 AM: Layouts:
2017-06-30 10:14:58 AM: Landscape
2017-06-30 10:14:58 AM: Portrait
--------------------------------------------------
2017-06-30 10:14:58 AM: Orientations:
2017-06-30 10:14:58 AM: L
2017-06-30 10:14:58 AM: P
--------------------------------------------------
2017-06-30 10:14:59 AM: Landscape Features:
2017-06-30 10:14:59 AM: MapArea=Marion 1040
2017-06-30 10:14:59 AM: OID=1
2017-06-30 10:14:59 AM: *~*~*~*~*~*~*~*~*
2017-06-30 10:14:59 AM: MapArea=Marion 1018
2017-06-30 10:14:59 AM: OID=2
--------------------------------------------------
2017-06-30 10:14:59 AM: Portrait Features:
2017-06-30 10:14:59 AM: MapArea=Marion 1024
2017-06-30 10:14:59 AM: OID=3
2017-06-30 10:14:59 AM: *~*~*~*~*~*~*~*~*
2017-06-30 10:14:59 AM: MapArea=Marion 1019
2017-06-30 10:14:59 AM: OID=4
--------------------------------------------------
2017-06-30 10:14:59 AM: Attempting to update 'Parcels Visited Yesterday' layer name within 'Reappraisal' map to 'Parcels Visited 06/29/2017'...
2017-06-30 10:14:59 AM: Successfully updated 'Parcels Visited Yesterday' layer name within 'Reappraisal' map to 'Parcels Visited 06/29/2017'... (Elapsed time: 0.00 seconds)
--------------------------------------------------
2017-06-30 10:15:08 AM: There are 2 landscape pages to export...
--------------------------------------------------
2017-06-30 10:15:08 AM: Attempting to turn on 'Assessor Map Area Index (L)' layer within 'Reappraisal' map...
2017-06-30 10:15:08 AM: Successfully turned on 'Assessor Map Area Index (L)' layer within 'Reappraisal' map... (Elapsed time: 0.00 seconds)
--------------------------------------------------
2017-06-30 10:15:08 AM: Attempting to turn off 'Assessor Map Area Index (P)' layer within 'Reappraisal' map...
2017-06-30 10:15:08 AM: Successfully turned off 'Assessor Map Area Index (P)' layer within 'Reappraisal' map... (Elapsed time: 0.00 seconds)
--------------------------------------------------
2017-06-30 10:15:08 AM: Attempting to update definition query of 'Assessor Map Area Index (L)' layer to 'OBJECTID=1'...
2017-06-30 10:15:08 AM: Successfully updated definition query of 'Assessor Map Area Index (L)' layer to 'OBJECTID=1'... (Elapsed time: 0.04 seconds)
2017-06-30 10:15:08 AM: Attempting to set 'Data View Map Frame' map frame within 'Landscape' layout to the extent of the 'Assessor Map Area Index (L)' layer...
2017-06-30 10:15:08 AM: Successfully set 'Data View Map Frame' map frame within 'Landscape' layout to the extent of the 'Assessor Map Area Index (L)' layer... (Elapsed time: 0.03 seconds)
2017-06-30 10:15:08 AM: Attempting to apply a 5.0% padding to 'Landscape' layout scale; setting layout scale to 1:8,965...
2017-06-30 10:15:08 AM: Successfully applied a 5.0% padding to 'Landscape' layout scale; setting layout scale to 1:8,965... (Elapsed time: 0.01 seconds)
2017-06-30 10:15:08 AM: Attempting to update 'Landscape' layout 'MapArea' text element to 'Marion 1040'...
2017-06-30 10:15:08 AM: Successfully updated 'Landscape' layout 'MapArea' text element to 'Marion 1040'... (Elapsed time: 0.00 seconds)
2017-06-30 10:15:08 AM: Attempting to export 'Landscape' layout to: ..Some-Folder\Reappraisal\In-House\Reports\Maps\2017-06-29\Marion 1040.pdf...
2017-06-30 10:15:08 AM: Successfully exported 'Landscape' layout to: ..Some-Folder\Reappraisal\In-House\Reports\Maps\2017-06-29\Marion 1040.pdf... (Elapsed time: 0.00 seconds)
--------------------------------------------------
2017-06-30 10:15:08 AM: Attempting to update definition query of 'Assessor Map Area Index (L)' layer to 'OBJECTID=2'...
2017-06-30 10:15:08 AM: Successfully updated definition query of 'Assessor Map Area Index (L)' layer to 'OBJECTID=2'... (Elapsed time: 0.04 seconds)
2017-06-30 10:15:08 AM: Attempting to set 'Data View Map Frame' map frame within 'Landscape' layout to the extent of the 'Assessor Map Area Index (L)' layer...
2017-06-30 10:15:08 AM: Successfully set 'Data View Map Frame' map frame within 'Landscape' layout to the extent of the 'Assessor Map Area Index (L)' layer... (Elapsed time: 0.03 seconds)
2017-06-30 10:15:08 AM: Attempting to apply a 5.0% padding to 'Landscape' layout scale; setting layout scale to 1:5,612...
2017-06-30 10:15:08 AM: Successfully applied a 5.0% padding to 'Landscape' layout scale; setting layout scale to 1:5,612... (Elapsed time: 0.01 seconds)
2017-06-30 10:15:08 AM: Attempting to update 'Landscape' layout 'MapArea' text element to 'Marion 1018'...
2017-06-30 10:15:08 AM: Successfully updated 'Landscape' layout 'MapArea' text element to 'Marion 1018'... (Elapsed time: 0.00 seconds)
2017-06-30 10:15:08 AM: Attempting to export 'Landscape' layout to: ..Some-Folder\Reappraisal\In-House\Reports\Maps\2017-06-29\Marion 1018.pdf...
2017-06-30 10:15:08 AM: Successfully exported 'Landscape' layout to: ..Some-Folder\Reappraisal\In-House\Reports\Maps\2017-06-29\Marion 1018.pdf... (Elapsed time: 0.00 seconds)
--------------------------------------------------
2017-06-30 10:15:08 AM: There are 2 portrait pages to export...
--------------------------------------------------
2017-06-30 10:15:08 AM: Attempting to turn on 'Assessor Map Area Index (P)' layer within 'Reappraisal' map...
2017-06-30 10:15:08 AM: Successfully turned on 'Assessor Map Area Index (P)' layer within 'Reappraisal' map... (Elapsed time: 0.00 seconds)
--------------------------------------------------
2017-06-30 10:15:08 AM: Attempting to turn off 'Assessor Map Area Index (L)' layer within 'Reappraisal' map...
2017-06-30 10:15:08 AM: Successfully turned off 'Assessor Map Area Index (L)' layer within 'Reappraisal' map... (Elapsed time: 0.00 seconds)
--------------------------------------------------
2017-06-30 10:15:08 AM: Attempting to update definition query of 'Assessor Map Area Index (P)' layer to 'OBJECTID=3'...
2017-06-30 10:15:08 AM: Successfully updated definition query of 'Assessor Map Area Index (P)' layer to 'OBJECTID=3'... (Elapsed time: 0.04 seconds)
2017-06-30 10:15:08 AM: Attempting to set 'Data View Map Frame' map frame within 'Portrait' layout to the extent of the 'Assessor Map Area Index (P)' layer...
2017-06-30 10:15:08 AM: Successfully set 'Data View Map Frame' map frame within 'Portrait' layout to the extent of the 'Assessor Map Area Index (P)' layer... (Elapsed time: 0.03 seconds)
2017-06-30 10:15:08 AM: Attempting to apply a 5.0% padding to 'Portrait' layout scale; setting layout scale to 1:4,046...
2017-06-30 10:15:08 AM: Successfully applied a 5.0% padding to 'Portrait' layout scale; setting layout scale to 1:4,046... (Elapsed time: 0.01 seconds)
2017-06-30 10:15:08 AM: Attempting to update 'Portrait' layout 'MapArea' text element to 'Marion 1024'...
2017-06-30 10:15:08 AM: Successfully updated 'Portrait' layout 'MapArea' text element to 'Marion 1024'... (Elapsed time: 0.00 seconds)
2017-06-30 10:15:08 AM: Attempting to export 'Portrait' layout to: ..Some-Folder\Reappraisal\In-House\Reports\Maps\2017-06-29\Marion 1024.pdf...
2017-06-30 10:15:08 AM: Successfully exported 'Portrait' layout to: ..Some-Folder\Reappraisal\In-House\Reports\Maps\2017-06-29\Marion 1024.pdf... (Elapsed time: 0.00 seconds)
--------------------------------------------------
2017-06-30 10:15:08 AM: Attempting to update definition query of 'Assessor Map Area Index (P)' layer to 'OBJECTID=4'...
2017-06-30 10:15:08 AM: Successfully updated definition query of 'Assessor Map Area Index (P)' layer to 'OBJECTID=4'... (Elapsed time: 0.04 seconds)
2017-06-30 10:15:08 AM: Attempting to set 'Data View Map Frame' map frame within 'Portrait' layout to the extent of the 'Assessor Map Area Index (P)' layer...
2017-06-30 10:15:08 AM: Successfully set 'Data View Map Frame' map frame within 'Portrait' layout to the extent of the 'Assessor Map Area Index (P)' layer... (Elapsed time: 0.03 seconds)
2017-06-30 10:15:08 AM: Attempting to apply a 5.0% padding to 'Portrait' layout scale; setting layout scale to 1:4,815...
2017-06-30 10:15:08 AM: Successfully applied a 5.0% padding to 'Portrait' layout scale; setting layout scale to 1:4,815... (Elapsed time: 0.01 seconds)
2017-06-30 10:15:08 AM: Attempting to update 'Portrait' layout 'MapArea' text element to 'Marion 1019'...
2017-06-30 10:15:08 AM: Successfully updated 'Portrait' layout 'MapArea' text element to 'Marion 1019'... (Elapsed time: 0.00 seconds)
2017-06-30 10:15:08 AM: Attempting to export 'Portrait' layout to: ..Some-Folder\Reappraisal\In-House\Reports\Maps\2017-06-29\Marion 1019.pdf...
2017-06-30 10:15:08 AM: Successfully exported 'Portrait' layout to: ..Some-Folder\Reappraisal\In-House\Reports\Maps\2017-06-29\Marion 1019.pdf... (Elapsed time: 0.00 seconds)
--------------------------------------------------
2017-06-30 10:15:10 AM: End time of script (Elapsed time: 24.06 seconds)
--------------------------------------------------
... View more
06-30-2017
08:36 AM
|
1
|
1
|
3885
|
|
POST
|
Just for a test, I created a simple python script (below) that calls some basic arcpy functions to see whether or not it's arcpy in general or some specific functions that are causing an issue. The script below will output a .txt file to a user's desktop showing whether or not a sample feature class exists and if it does, some basic describe properties. I was able to execute this script using python 3.5 that comes with ArcGIS Pro and setting Task Scheduler to 'Run whether user is logged on or not' ... so, it may be the actual layout exporting functions that are an issue. # import modules
import os
userDesktop = os.path.join(os.path.expanduser('~'), 'Desktop')
testFc = r'...path to fc...'
def test_arcpy(output_log_folder, test_fc_path):
log_path = os.path.join(output_log_folder, 'arcpyTest.txt')
f = open(log_path, 'w')
import arcpy
f.write('Successfully imported arcpy...\n')
# try testing if fc exists
if arcpy.Exists(test_fc_path):
f.write('{0} exists...\n'.format(test_fc_path))
# try testing some describe functions
desc = arcpy.Describe(test_fc_path)
data_type = desc.dataType
shp_type = desc.shapeType
oid_fld = desc.OIDFieldName
sr = desc.spatialReference.name
f.write(' Data Type: {0}\n'.format(data_type))
f.write(' Shape Type: {0}\n'.format(shp_type))
f.write(' OID Field: {0}\n'.format(oid_fld))
f.write(' Spatial Reference: {0}\n'.format(sr))
else:
f.write('{0} does not exist...'.format(test_fc_path))
f.close()
# test arcpy functions
test_arcpy(userDesktop, testFc)
... View more
06-29-2017
11:53 AM
|
0
|
1
|
3885
|
|
POST
|
I would second that it points to python 3.5. I'm using the same username on the same server to execute both 2.7 and 3.5 scripts. My 2.7 scripts have no issue running when set to 'Run whether user is logged on or not'.
... View more
06-29-2017
10:58 AM
|
0
|
3
|
3885
|
|
POST
|
I agree that somewhere a specific (or all) arcpy function(s) seems to be an issue. If I comment out all the functions that use arcpy and re-run my script, it executes fine with 'Run whether user is logged on or not'. The script will successfully create a log (.txt file) and send an email when complete.
... View more
06-29-2017
10:43 AM
|
1
|
0
|
4075
|
|
POST
|
I am using ArcGIS Pro 2.0 (Single Use Advanced)...and after reading through the thread, my script will work ONLY when the task is set to 'Run only when user is logged on'. If I try to execute the script using 'Run whether user is logged on or not' it will fail. Thanks for pointing me in the direction of the other thread.
... View more
06-29-2017
10:35 AM
|
1
|
6
|
6132
|
|
POST
|
I was pointed to this thread because I'm having a similar issue. I have a python script that is exporting PDFs from an ArcGIS Pro project. The script works as expected using an IDE (PyCharm) but when I try to migrate it to task scheduler, it will ONLY work when I have 'Run only when user is logged on'. If I change this property to 'Run whether user is logged on or not' it will fail. The system environment the script is being run on: OS: Windows Server 2012 R2 Pro Version: ArcGIS Pro 2.0 Pro License Type: Single Use Advanced Python exe: ..\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe So...if I'm reading the thread above correctly...starting at Pro 2.0 you should be able to export out documents (PDF, PNG, JPG, etc...) from a layout...which again, I can confirm is doable, but ONLY if the task is set to 'Run only when user is logged on'. Is there no way to execute this when the user is not logged on?
... View more
06-29-2017
10:33 AM
|
0
|
11
|
4075
|
|
POST
|
I am in the process of migrating a scheduled task from ArcMap to ArcGIS Pro that exports maps to PDFs on a daily basis. I have the python script written, and it executes as expected when running through an IDE (PyCharm) using the python executable delivered with ArcGIS Pro (..\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe). When I try executing the same script through Windows Task Scheduler, I can tell the script is running because a .txt file is generated to log processes, however, at some point the script is failing as the maps are not being exported. The task scheduler returns a code of 0xFFFFFFFF and I haven't found anything of substance for this code. There are no warnings or errors in the task history either to give any clues. We have several other tasks that are running just fine using python 2.7 along with ArcMap/ArcGIS Desktop using my domain account, so the username I'm using has sufficient permissions to execute a task. I also have ArcGIS Pro setup to login automatically, which again, works fine through the IDE. I tried using a Single Use license, with the same result. If I comment out all the ArcGIS Pro / arcpy functions, the script will execute as expected through Task Scheduler (creates a log, and sends an email). It seems to be specific to the arcpy functions. Is anyone running a Windows Task Scheduler task using ArcGIS Pro projects successfully? If so, am I missing something? Is there some sort of permission setting I'm missing? Any ideas of where to look...?
... View more
06-29-2017
09:33 AM
|
1
|
11
|
9969
|
|
POST
|
I checked one of the triggers I'm using and noticed a slight variance than the above screenshot...which I probably noticed after trying to edit features! The sample below should take care of handling features were a sequence has already been applied. The add (a) delta table for this test feature class has the trigger below applied to it, which is set to update the ID field on an insert/create IF the ID field is NULL. You can see on subsequent edits of the feature, the 'ID' field remains the same value because the field is not NULL, and thus the trigger is skipped. Modified trigger to account for already-populated sequence value. The 'IF' statement on line 27 will check the inserted table to see if the sequence field (ID in this example) is already populated. If it's not, the next value within the sequence will be grabbed and populated into the 'ID' field as shown on line 35. I blocked out our database and schema name. Simply replace with your values. Add (a) delta table showing edits. ID field remains as-is on subsequent edits because it is already populated.
... View more
06-28-2017
12:41 PM
|
3
|
4
|
3983
|
|
POST
|
Yea...I've looked through the classes. I would think it'd be a method within the layouts, but I don't see anything. Was hoping someone else had already dove into this, and I was missing it somewhere.
... View more
06-23-2017
02:19 PM
|
0
|
0
|
4008
|
|
POST
|
I've seen these pages, however I don't see any documentation or sample python docs for how to use python to iterate over a map series and export the pages within a series. That's what I'm looking for, whether or not this is possible with ArcGIS Pro.
... View more
06-23-2017
01:20 PM
|
0
|
2
|
4008
|
|
POST
|
I was able to add in content source folders for my project, and when running sys.path, it returns the folders that are shown within ArcGIS Pro (screenshot below), but I am still getting an error that a module can't be found. sys.path error message with importing arcpy
... View more
06-23-2017
09:51 AM
|
0
|
0
|
2602
|
|
POST
|
I'm not running on a machine that has Server installed.
... View more
06-23-2017
09:12 AM
|
0
|
0
|
2602
|
|
POST
|
I'm by far an expert when it comes to Python...so, I generally use PyCharm when it comes to writing scripts as I find it to be a great IDE for Python. I'm starting the process of moving some of my 2.7.x scripts to 3.5.x for use with ArcGIS Pro. I have configured PyCharm to use the python interpreter packaged with ArcGIS Pro 1.4.1, located at the following: C:\Program Files\ArcGIS\Pro\bin\Python. However, arcpy is not recognized as an available module. If I run sys.path from within PyCharm, I get the following paths: If I run sys.path from within ArcGIS Pro, I get the following paths: What do I need to do in order to get PyCharm to be able to use arcpy? Do I need to add system environmental variable paths? If so, from the list returned in ArcGIS Pro, how many need to be added? Is there some other way of getting the arcpy module to be recognized within PyCharm? Is there a best practice that is used with python? Thanks!
... View more
06-23-2017
08:30 AM
|
0
|
7
|
5299
|
|
POST
|
I'm considering moving some of my map production projects to ArcGIS Pro, but most of them rely on data driven pages and python scripts to automatically iterate over the pages and export out PDFs. I have looked through the arcpy.mp module and don't see any method, class, or function for accessing map series properties...maybe I'm missing it...? Without having the ability to script and export a map series, I'm kind of wondering why this is even a part of ArcGIS Pro...? Is there going to be future development in ArcGIS Pro that will provide the capability of iterating over map series pages and use the already existing exportToPDF, exportToJPEG, exportToPNG, etc...?
... View more
06-23-2017
06:42 AM
|
0
|
22
|
14522
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-03-2026 09:59 AM | |
| 1 | 03-02-2026 11:02 AM | |
| 6 | 02-18-2026 04:58 PM | |
| 2 | 02-18-2026 05:01 PM | |
| 1 | 12-09-2025 07:06 AM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|