I hesitate to submit this, as the syntax for calling this geoprocessing tool from the Pro SDK would seem straight forward. The geoprocessing tool in Pro only appears to require an input feature layer to run. I have successfully navigated calling many other geoprocessing tools much more involved than this, so I did not anticipate any heartburn with this one.
However, I have not been able to have it successfully execute. I am using the same basic pattern as with other geoprocessing tools. I have tried many versions of this pattern, assigning values to the env array and trying different values for the arguments (strings of paths to the feature class, output feature layers, etc) with no luck. The feature layer passed in is a point feature class in a file geodatabase. I can successfully run the tool in native pro on the feature layer with success.
public Task<IGPResult> AddXYCoordinate4(FeatureLayer featureLayer)
{
var AddXY = @"C:\Program Files\ArcGIS\Pro\Resources\ArcToolBox\Toolboxes\Data Management Tools.tbx\Add XY Coordinates";
var args = Geoprocessing.MakeValueArray(featureLayer);
var env = Geoprocessing.MakeEnvironmentArray();
return Geoprocessing.ExecuteToolAsync(AddXY, args, env, null, null, GPExecuteToolFlags.None);
}
I would appreciate it if anyone could kindly assist me with how this tool should be called.
Thanks
Solved! Go to Solution.
Hi Thomas,
Geoprocessing function name is AddXY_management. You can run tool from geoprocessing dockpane, then go to history and Copy Python command. For example:
arcpy.management.AddXY("PopulationPoints")
Then change library and function names by places and add underscore between them.
Hi Thomas,
Geoprocessing function name is AddXY_management. You can run tool from geoprocessing dockpane, then go to history and Copy Python command. For example:
arcpy.management.AddXY("PopulationPoints")
Then change library and function names by places and add underscore between them.
Thanks so much for responding Gintautus. I guess calling the tool by the correct name "Management.AddXY" does make a difference. Your suggestion regarding reviewing the history is welcome.
I was under the mistaken impression the name of the tool appeared in the GeoProcessing Window when you called the tool interactively. In this case "Add XY Coordinates".
or when you look at the full tool box listing, it appears as:
Thanks again.