I am looking at this documentation for post processing validation resource within a python toolbox and it utilizes the arcpy.mp module for manipulating the contents of existing projects (.aprx) and layer files (.lyrx). The example in that link above makes it seem that arcpy.mp can be used inside a python toolbox. However, I'm reading that arcpy.mp requires that some methods and properties only work when ran inside the python pane or a script tool inside of ArcPro (ArcGISProject object resource ). Does the arcpy.mp only work when its a geoprocessing toolbox and not a python toolbox thats executed in an IDE?
Solved! Go to Solution.
The main issue you'll find is that arcpy.mp.ArcGISProject("CURRENT") won't work outside of ArcGIS Pro. This includes scripts run from an IDE or external python interpreter or script tools/python toolbox tools started from ArcGIS Pro but running in the background.
You can use arcpy.mp outside of ArcGIS Pro, but to instantiate an ArcGISProject object, you need to use arcpy.mp.ArcGISProject(r"Drive:\Path\to\project.aprx) and understand that any changes you make won't be reflected in an open ArcGIS Pro project, but you need to save the ArcGISProject object and then open it in Pro to see changes.
The main issue you'll find is that arcpy.mp.ArcGISProject("CURRENT") won't work outside of ArcGIS Pro. This includes scripts run from an IDE or external python interpreter or script tools/python toolbox tools started from ArcGIS Pro but running in the background.
You can use arcpy.mp outside of ArcGIS Pro, but to instantiate an ArcGISProject object, you need to use arcpy.mp.ArcGISProject(r"Drive:\Path\to\project.aprx) and understand that any changes you make won't be reflected in an open ArcGIS Pro project, but you need to save the ArcGISProject object and then open it in Pro to see changes.