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:
<SPAN class="comment token">//// Tool parameters</SPAN>
<SPAN class="keyword token">string</SPAN> in_features <SPAN class="operator token">=</SPAN> <SPAN class="string token">@"C:PathToFeatureClass"</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">string</SPAN> geometry_property <SPAN class="operator token">=</SPAN> <SPAN class="string token">"SEG_LEN LENGTH"</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">string</SPAN> length_unit <SPAN class="operator token">=</SPAN> <SPAN class="string token">"MILES_US"</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//// Path to tool using toolbox alias</SPAN>
<SPAN class="keyword token">string</SPAN> tool_path <SPAN class="operator token">=</SPAN> <SPAN class="string token">"management.CalculateGeometryAttributes"</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//// Construct the value array to be passed as parameter to ExecuteToolAsync</SPAN>
<SPAN class="keyword token">var</SPAN> args <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// Create spatial reference and pass to value array constuctor </SPAN>
<SPAN class="keyword token">var</SPAN> spatial_ref <SPAN class="operator token">=</SPAN> SpatialReferenceBuilder<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateSpatialReference</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="number token">3081</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">MakeValueArray</SPAN><SPAN class="punctuation token">(</SPAN>in_features<SPAN class="punctuation token">,</SPAN> geometry_property<SPAN class="punctuation token">,</SPAN> length_unit<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN> spatial_ref<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//// Execute the tool with hard-coded args</SPAN>
<SPAN class="keyword token">await</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ExecuteToolAsync</SPAN><SPAN class="punctuation token">(</SPAN>tool_path<SPAN class="punctuation token">,</SPAN> args<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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!