Hi,
I am attempting to call a Python-tool that I made, from within an add-in for ArcGIS Pro 2.9.1 using the following .NET code:
internal class LoadInfrastructureData : Button
{
protected override void OnClick()
{
string toolPath = "trafficanalyst.InfrastructureConnectivityTool";
string linklayerPath = "C:\\Temp\\NaestvedDemoModelND.gdb\\TA\\Link";
string networkDatasetPath = "C:\\Temp\\NaestvedDemoModelND.gdb\\TA\\TA_ND";
string linkConnectivityPath = "C:\\Temp\\LinkConnectivity.csv";
string pointCandidatesPath = "C:\\Temp\\PointCandidates.csv";
string stopLayerPath = "C:\\Temp\\NaestvedDemoModelND.gdb\\TA\\Stop";
string viaPointsPath = "#";
string stopLayerWhereClause = "#";
string linkLayerWhereClause = "#";
string initialSearchDistance = "50";
string maxSearchDistance = "150";
string maxSnapDistance = "0.1";
string[] args = {
linklayerPath,
networkDatasetPath,
linkConnectivityPath,
pointCandidatesPath,
stopLayerPath,
viaPointsPath,
stopLayerWhereClause,
linkLayerWhereClause,
initialSearchDistance,
maxSearchDistance,
maxSnapDistance
};
var loadInfrastructureTask = QueuedTask.Run(async () =>
{
IGPResult result = await Geoprocessing.ExecuteToolAsync(toolPath, args, flags:GPExecuteToolFlags.None);
});
}
I have tried using the following as toolpath when calling Geoprocessing.ExecuteToolAsync(toolPath, args):
Common to all four ways of specifying the toolPath parameter, is that I get the value 2147483647 as the ErrorCode from the returned IGPResult as shown below:
If I replace toolPath and args with a standard Esri tool, it works fine.
If I run my Python-tool from within ArcGIS Pro GeoProcessing, it works fine.
If I run my Python-tool via an ArcGIS Pro Python prompt, it works fine.
What am I doing wrong?