POST
|
Well, @MobiusSnake got me on the right "path" here ;-). I've tried feeding the path and file into os.path.isfile() in a number of tricky ways... here is my latest attempt: # For loop with file listing import arcpy, os.path with open(r"C:\GISData\aprx_list.txt") as aprx_files: for aprxPathFile in aprx_files: aprxPathFile = 'r{}'.format(aprxPathFile) print(aprxPathFile) if os.path.isfile(aprxPathFile): aprx = arcpy.mp.ArcGISProject(aprxPathFile) for m in aprx.listMaps(): print("Map: " + m.name) for lyr in m.listLayers(): print(" " + lyr.name) The print(aprxPathFile) prints out the results as: r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\fixit\fixit.aprx" r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\MyProject\MyProject.aprx" r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\MyProject1\MyProject1.aprx" r"C:\Users\gis_user\OneDrive - Company\Documents\ArcGIS\Projects\MyProject2\MyProject2.aprx" But os.path.isfile(aprxPathFile) returns False. Spooky part? I can copy the path and file text from one of these entries, paste it in to os.path.isfile() and I get True!
... View more
09-28-2023
12:28 PM
|
0
|
0
|
422
|
POST
|
Hey @MobiusSnake - I just put a file.exists() through os.path... looks like I just need to escape those "\\" delimiters from the text file!
... View more
09-27-2023
10:33 AM
|
0
|
0
|
490
|
POST
|
Good question - they definitely exist (although I whiteboarded the gis_user and Company parts of the paths in this post for privacy). Came from doing an old school "dir /s /b > aprx_list.txt", then doing a find and replace to get the double slashes for Python's persnickety behavior with spaces.
... View more
09-27-2023
10:27 AM
|
0
|
1
|
493
|
POST
|
Hi guys! My subject is pretty descriptive, but trying to figure out how to get this basic script to run! I've attempted running it from the Python windows within a Pro session and outside from the command line. Script: import arcpy with open(r"C:\GISData\aprx_list.txt") as aprx_files: for aprxPathFile in aprx_files: print(aprxPathFile) aprx = arcpy.mp.ArcGISProject(aprxPathFile) for m in aprx.listMaps(): print("Map: " + m.name) for lyr in m.listLayers(): print(" " + lyr.name) Contents of "aprx_list.txt" is: C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\fixit\\fixit.aprx C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\MyProject\\MyProject.aprx C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\MyProject1\\MyProject1.aprx C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\MyProject2\\MyProject2.aprx And, the result and error I'm getting from both environments is: C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\fixit\\fixit.aprx Traceback (most recent call last): File "<string>", line 6, in <module> File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 536, in __init__ self._arc_object = arcgisscripting._mapping.ArcGISProject(*gp_fixargs((aprx_path,), True)) OSError: C:\\Users\\gis_user\\OneDrive - Company\\Documents\\ArcGIS\\Projects\\fixit\\fixit.aprx Thanks in advance for the help!
... View more
09-27-2023
09:59 AM
|
0
|
4
|
508
|
POST
|
Travis, Have you received any information from ESRI on this? Following DevSummit this year, our rep told us they were targeting June of this year to integrate the dynamic segmentation (a.k.a., linear referencing) aspects of UPDM with geometric networks, but I have no idea what the data requirements are or how to get past the classic limitations of not being able to have route and "network dataset" data participating in a geometric network and vice-versa. Jack
... View more
06-14-2017
05:21 AM
|
0
|
2
|
830
|
POST
|
I'm trying to return route name and measure by clicking on a linear route feature like in ArcMap with the Identify Route Locations Tool?
... View more
11-29-2016
02:31 PM
|
0
|
0
|
628
|
POST
|
Nevermind. All I had to do was set "Sort Order" to my "Sequence" attribute in the dialog box... Sorry for the distraction, everybody!
... View more
10-18-2011
06:32 AM
|
0
|
0
|
171
|
POST
|
I have an attribute in my stops feature class called "Route" and "Sequence". "Route" contains a text string with the name of the route to be calculated. "Sequence" contains a long integer with a 1 or 2, indicating the beginning and ending (respectively) of a route that I need Network Analyst to honor as the start and end of a route calculation. The points in this feature class are topologically correct, one being at the beginning of the first polyline and the second at the end of the last polyline being traversed. How do I configure this setup in the native Network Analyst tools so I get the results I need?
... View more
10-18-2011
05:52 AM
|
0
|
1
|
785
|
Online Status |
Offline
|
Date Last Visited |
10-13-2023
12:40 AM
|