AnsweredAssumed Answered

Need to get selected features for Geoprocessing.ExecuteToolAsync

Question asked by Matthew.Washburn_TXDOT on May 11, 2019
Latest reply on May 17, 2019 by bulla_b

I'm trying to execute the CalculateGeometryAttributes geoprocessing tool with some hard-coded arguments. The code I have is working, but it's running on the entire feature class. I need it to only run on the selected records. Here is what I have now:


//// Tool parameters
string in_features = @"C:PathToFeatureClass";
string geometry_property = "SEG_LEN LENGTH";
string length_unit = "MILES_US";

//// Path to tool using toolbox alias
string tool_path = "management.CalculateGeometryAttributes";

//// Construct the value array to be passed as parameter to ExecuteToolAsync
var args = await QueuedTask.Run(() =>
    // Create spatial reference and pass to value array constuctor
    var spatial_ref = SpatialReferenceBuilder.CreateSpatialReference(3081);
    return Geoprocessing.MakeValueArray(in_features, geometry_property, length_unit, null, spatial_ref);

//// Execute the tool with hard-coded args
await Geoprocessing.ExecuteToolAsync(tool_path, args);


I'm assuming I need to somehow check if any features are selected, then pass just those selected to the tool. Otherwise, it should run on all features.


Any help is appreciated!