I was wondering if there is a ArcPy function to create a new project from scratch given a root directory where I would want the project to be created.
This is by far the best workaround currently available at Pro 3.5. I will say, the minimum webmap definition needed to get ConvertWebMapToArcGISProject to work is:
{"mapOptions":{"extent":{}}}
You can use the ConvertWebMapToProject function with a minimal map definition to get a project file in memory, which you can then save to disk:
z = arcpy.mp.ConvertWebMapToArcGISProject("""{ "mapOptions": { "extent": { "xmin": -12933906.537, "ymin": 3993856.886, "xmax": -12933371.998, "ymax": 3994375.189, "spatialReference": { "wkid": 102100 } } }, "operationalLayers": [], "baseMap": [], "exportOptions": {}, "layoutOptions": {}, "reportOptions": {} }""").ArcGISProject.saveACopy(r"C:\path\to\project.aprx")
A bit hacky but it works. If you want a more comprehensive project as a base you're better off with @CodyPatterson's template method.
Hey @YahyaMasri
No problem! From what I've found, it doesn't appear to currently be a function within the documentation, I saw someone had mentioned a create() function, but that doesn't exist.
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject.htm
Definitely suitable for an idea on the ideas forum!
Cody
Thanks for the quick reply, Cody!
Is there no other way to create a new project if there is for example no blank template project? Thanks for the help and the link!
Here's a link to a similar post, would this work for you?
https://community.esri.com/t5/python-questions/arcpy-function-for-creating-a-new-arcgis-project/td-p/1119035
The gist is to have a blank template project, and then copy that project to make a new blank one.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.