0

I need to open an ArcGIS Pro project (.aprx) file in the ArcGIS Pro application inside of an arcpy script.

Does anyone know of a way to accomplish this?

I am using ArcGIS pro 2.4.1.

By open, I mean having the application actually open up on my screen. Similar to opening it from the start menu but utilizing the script instead.

1

I have done something similar to open PDF files in Adobe Acrobat Reader in the past so I just looked up this answer to Opening PDF generated by Python AddIn using Report (*.rlf) file automatcally? and tested:

import os
myfile = r"C:\Temp\Projects\TestProject\TestProject.aprx"
os.system("start " + myfile)

and it worked.

  • Woah! That works!! Thank you. Now is it possible to close that same file? – ketar Sep 30 at 18:25
  • @ketar I’ve never had a requirement to close an application opened this way. I always want the user to interact with it and then decide when they want to close it. – PolyGeo Sep 30 at 22:31
1

You can use:

aprx = arcpy.mp.ArcGISProject(r"C:\path\to\project.aprx")

For further things you can do with aprx refer to the documentation.

  • I meant open as in have it pop up, as if the icon was double clicked. Let me update the question. – ketar Sep 26 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.