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 🙂
Solved! Go to Solution.
I'm not as familiar with Python Toolboxes, as I am with regular Toolboxes, but by my understanding Right-Click>>Edit and then click Run would NOT be running it in the project.
That's going to run it in whichever IDE you have set up.
Try double-clicking it in the catalog, rather than Right-click>>Edit. Does that work as expected?
If the project is closed, then try using the full path to the aprx
the project is open, running properly. there is also an active map and active layers.
notebooks know the existence of 'current' are you running the toolbox from within Pro as well?
yes. i browsed through the catalog to the toolbox, right-click >> Edit. in the editor I clicked Run. that should be from within?
I'm not as familiar with Python Toolboxes, as I am with regular Toolboxes, but by my understanding Right-Click>>Edit and then click Run would NOT be running it in the project.
That's going to run it in whichever IDE you have set up.
Try double-clicking it in the catalog, rather than Right-click>>Edit. Does that work as expected?
thanks, yes now it's working. thanks 🙂