Hi
I used this code with ArcGIS Pro 2.x without any problems from my .pyt-toolbox. Now (3.3.1) I always get "OSError: CURRENT". It still works when I call it from a python notebook, which I have opened in my ArcGIS Pro project. But I need to get it to work again in this setup:
I'm creating a Dockpane using the ArcGIS Pro SDK. On that dockpane is a button, when clicked, this happens:
string installPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string toolboxPath = System.IO.Path.Combine(installPath, "Data.pyt\\Repair");
await Geoprocessing.ExecuteToolAsync(toolboxPath, null, null, null, null, GPExecuteToolFlags.None);
this executes my tool and this works.
The Repair method is now reduced to :
p = arcpy.mp.ArcGISProject('CURRENT')
m = p.listMaps()[0]
l = m.listLayers()[0]
pprint.pprint(l.connectionProperties)
this does work in my notebook but from my pyt-toolbox I get "OSError: CURRENT".
I already tried to run the Tool from within an ArcGIS Pro project, but it doesn't work either, when there is an active map. however, if there is no active map, I get "index out of range".
any ideas would be appreciated 🙂