How to get current APRX in Python Toolbox?

426
1
09-28-2023 01:12 PM
JK10
by
Emerging Contributor

What is the best way to get the current APRX in a Python Toolbox (.pyt) tool? I've found that if I use arcpy.mp.ArcGISProject("CURRENT") then the initial loading of the toolboxes will results in the error below. If I right click on the toolbox and refresh then everything works fine until the next time I close and re-open the APRX.

Traceback (most recent call last):
  File "<string>", line 100, in __init__
  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: CURRENT

 

0 Kudos
1 Reply
AlfredBaldenweck
MVP Regular Contributor

That always works for me?

What part of the pyt is this in?

0 Kudos