Select to view content in your preferred language

Retriving paths for network datasets in Enterprise database

398
1
Jump to solution
12-20-2022 12:50 PM
StephenCochrane
Occasional Contributor

I am developing some ArcGIS Pro UI tools that needs to run a custom python geoprocessing tool as part of the workflow.

I would like to grab the selected network dataset in the map and pass the path of the network dataset on as a parameter to the geoprocessing tool. Retrieving a path for a network dataset located in GDB works fine using the GetDataConnection() on the network dataset layer.

However, when the networks dataset is located in a sql server enterprise geodatabase I am not able to get valid network dataset path for the layer. Preferable the path should use the sde connection file used when the network dataset layer was added to the map (but any valid path pointing out the network dataset for use in a geoprocessing tool would do).

Is this possible in any way?

0 Kudos
1 Solution

Accepted Solutions
StephenCochrane
Occasional Contributor

Well, I think I figured this one out on my own.

It seems I was doing it more complicated than necessary. I was trying to retrieve the path to the network dataset and pass this on to geoprocessing tool as a parameter. But the solution is quite simple and I just have to pass on the actual network dataset layer object as a parameter. So basically this works:

 

	public void RunGpTool(string toolPath, NetworkAnalystLayer ndLayer)
	{
		var args = Geoprocessing.MakeValueArray(ndLayer);
		IGPResult result = await Geoprocessing.ExecuteToolAsync(toolPath, args, flags: GPExecuteToolFlags.AddOutputsToMap);
	}

View solution in original post

0 Kudos
1 Reply
StephenCochrane
Occasional Contributor

Well, I think I figured this one out on my own.

It seems I was doing it more complicated than necessary. I was trying to retrieve the path to the network dataset and pass this on to geoprocessing tool as a parameter. But the solution is quite simple and I just have to pass on the actual network dataset layer object as a parameter. So basically this works:

 

	public void RunGpTool(string toolPath, NetworkAnalystLayer ndLayer)
	{
		var args = Geoprocessing.MakeValueArray(ndLayer);
		IGPResult result = await Geoprocessing.ExecuteToolAsync(toolPath, args, flags: GPExecuteToolFlags.AddOutputsToMap);
	}
0 Kudos