<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ExecuteToolAsync CalculateGeometryAttributes  Error in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203350#M8595</link>
    <description>&lt;P&gt;Hi - I'm making an ExecuteToolAsync call to&amp;nbsp;CalculateGeometryAttributes tool using ArcGIS Pro SDK 3.0 and am getting a&amp;nbsp;System.Linq.Enumerable.WhereListIterator&amp;lt;ArcGIS.Desktop.Core.Geoprocessing.IGPMessage error.&amp;nbsp; I've based my call on the tool reference located here:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-geometry-attributes.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-geometry-attributes.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I believe the error is related to the geometry_property parameter&amp;nbsp;&lt;SPAN&gt;[[Field, Property],...]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;my code is here:&lt;/P&gt;&lt;LI-CODE lang="c"&gt; var progDlg = new ProgressDialog("Processing Areas", "Cancel", 100, true);
            progDlg.Show();
            var inputLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().First(l =&amp;gt; l.Name.Equals(LayerNames.TempLAClip));
            var toolName = "management.CalculateGeometryAttributes";//based on my GP tool cache 
            var fieldParams = new List&amp;lt;string&amp;gt;() { "Ft2", "AREA" };
            var fieldParamList = new List&amp;lt;List&amp;lt;string&amp;gt;&amp;gt;();//this appears to be a list of lists (I also tried just using a list and got same error
            fieldParamList.Add(fieldParams);
            var units = "SQUARE_FEET_US";
            var calcParams = await QueuedTask.Run(() =&amp;gt;
            {
                return Geoprocessing.MakeValueArray(
                    new object[] { inputLayer, fieldParamList, units });
            });
            IGPResult result = await Geoprocessing.ExecuteToolAsync(toolName, calcParams, null, new CancelableProgressorSource(progDlg).Progressor, GPExecuteToolFlags.Default);

 if (result.IsCanceled)//fails or is canceled
            {
                _vm.StatusMessage = "Calculation Canceled";
                return false;
            }
            else if (result.IsFailed)//get error message here
            {
                _vm.StatusMessage = "Calculation Failed";
                return false;
            }
            else
            {
                return true;
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;any suggestions of how to fix this error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;</description>
    <pubDate>Tue, 16 Aug 2022 16:21:42 GMT</pubDate>
    <dc:creator>PeteVitt</dc:creator>
    <dc:date>2022-08-16T16:21:42Z</dc:date>
    <item>
      <title>ExecuteToolAsync CalculateGeometryAttributes  Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203350#M8595</link>
      <description>&lt;P&gt;Hi - I'm making an ExecuteToolAsync call to&amp;nbsp;CalculateGeometryAttributes tool using ArcGIS Pro SDK 3.0 and am getting a&amp;nbsp;System.Linq.Enumerable.WhereListIterator&amp;lt;ArcGIS.Desktop.Core.Geoprocessing.IGPMessage error.&amp;nbsp; I've based my call on the tool reference located here:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-geometry-attributes.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-geometry-attributes.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I believe the error is related to the geometry_property parameter&amp;nbsp;&lt;SPAN&gt;[[Field, Property],...]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;my code is here:&lt;/P&gt;&lt;LI-CODE lang="c"&gt; var progDlg = new ProgressDialog("Processing Areas", "Cancel", 100, true);
            progDlg.Show();
            var inputLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().First(l =&amp;gt; l.Name.Equals(LayerNames.TempLAClip));
            var toolName = "management.CalculateGeometryAttributes";//based on my GP tool cache 
            var fieldParams = new List&amp;lt;string&amp;gt;() { "Ft2", "AREA" };
            var fieldParamList = new List&amp;lt;List&amp;lt;string&amp;gt;&amp;gt;();//this appears to be a list of lists (I also tried just using a list and got same error
            fieldParamList.Add(fieldParams);
            var units = "SQUARE_FEET_US";
            var calcParams = await QueuedTask.Run(() =&amp;gt;
            {
                return Geoprocessing.MakeValueArray(
                    new object[] { inputLayer, fieldParamList, units });
            });
            IGPResult result = await Geoprocessing.ExecuteToolAsync(toolName, calcParams, null, new CancelableProgressorSource(progDlg).Progressor, GPExecuteToolFlags.Default);

 if (result.IsCanceled)//fails or is canceled
            {
                _vm.StatusMessage = "Calculation Canceled";
                return false;
            }
            else if (result.IsFailed)//get error message here
            {
                _vm.StatusMessage = "Calculation Failed";
                return false;
            }
            else
            {
                return true;
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;any suggestions of how to fix this error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 16:21:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203350#M8595</guid>
      <dc:creator>PeteVitt</dc:creator>
      <dc:date>2022-08-16T16:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteToolAsync CalculateGeometryAttributes  Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203519#M8597</link>
      <description>&lt;P&gt;Hi Pete,&lt;/P&gt;&lt;P&gt;&amp;nbsp;I think that the problem is that you are specifying the 'length' unit instead of the 'area' unit parameter.&amp;nbsp; The following snippet worked for me (notice that i inserted "" as the length unit before the area parameter):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var inputLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().First(l =&amp;gt; l.Name.Equals(layerName));
var toolName = "management.CalculateGeometryAttributes";//based on my GP tool cache 
var fieldParams = "TheInteger AREA";
var unit = "SQUARE_METERS";
var calcParams = Geoprocessing.MakeValueArray(
      new object[] { inputLayer, fieldParams, "", unit, MapView.Active.Map.SpatialReference });
IGPResult result = await Geoprocessing.ExecuteToolAsync(toolName, calcParams, null, new CancelableProgressorSource(progDlg).Progressor, GPExecuteToolFlags.Default);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 21:55:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203519#M8597</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2022-08-16T21:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteToolAsync CalculateGeometryAttributes  Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203524#M8598</link>
      <description>&lt;P&gt;Thanks Wolf, that solved the problem&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 22:16:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203524#M8598</guid>
      <dc:creator>PeteVitt</dc:creator>
      <dc:date>2022-08-16T22:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteToolAsync CalculateGeometryAttributes  Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203535#M8599</link>
      <description>&lt;P&gt;When faced with what syntax to use when running GP tools via ExecuteToolAsync I typically follow the same approach which u may find useful:&lt;/P&gt;&lt;P&gt;1. Open the GP Tool Dialog.&lt;/P&gt;&lt;P&gt;2. Manually configure the GP Tool Dialog with the desired options (may be some trial and error here)&lt;/P&gt;&lt;P&gt;3. Run the tool&lt;/P&gt;&lt;P&gt;4. Click on "View Details", then "Parameters" to view the parameters &lt;U&gt;&lt;EM&gt;the tool used&lt;/EM&gt;&lt;/U&gt; based on my dialog options.&lt;/P&gt;&lt;P&gt;5. Transfer the options from the "View Details" parameters to the addin code. Typically, ";" (semi-colons) in the output params indicates an input list. Again, u may have a bit of fiddling here to get this right. However, every parameter that is shown on the View Details &lt;EM&gt;with an assigned value&lt;/EM&gt; should have a corresponding parameter variable in your addin code.&lt;/P&gt;&lt;P&gt;For&amp;nbsp;Calculate Geometry Attributes, this looks like:&lt;/P&gt;&lt;P&gt;1. Open the dialog and configure:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tool_dialog.png" style="width: 431px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/48781iADEBD5613FDA679E/image-size/large?v=v2&amp;amp;px=999" role="button" title="tool_dialog.png" alt="tool_dialog.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;2. Run the tool, "View Details"...shows these parameter values based on my selections:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="view_details_params.png" style="width: 850px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/48782i6A4D8A40BB9FD62C/image-size/large?v=v2&amp;amp;px=999" role="button" title="view_details_params.png" alt="view_details_params.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;3. Transfer the parameters to the addin code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class RunCalcGeomAttribs : Button {
 protected override async void OnClick() {
   var inputLayer =
     MapView.Active.Map.GetLayersAsFlattenedList()
      .OfType&amp;lt;FeatureLayer&amp;gt;().First(l =&amp;gt; l.Name == "Portland_PD_Precincts");
   var toolName = "management.CalculateGeometryAttributes";

   var geom_attribs = new List&amp;lt;string&amp;gt;() {
     "AREA AREA_GEODESIC", "LENGTH PERIMETER_LENGTH_GEODESIC", "VERTICES POINT_COUNT"
   };
   var length_unit = "FEET_US";
   var area_unit = "SQUARE_FEET_US";

   var calcParams = Geoprocessing.MakeValueArray(
       new object[] { inputLayer, geom_attribs, length_unit, area_unit });

   IGPResult result = await Geoprocessing.ExecuteToolAsync(
         toolName, calcParams, null, CancelableProgressor.None,
              GPExecuteToolFlags.InheritGPOptions);

   var str = "No errors";
   if (result.IsFailed) {
     str = string.Join(',', result.ErrorMessages?.Select(
             m =&amp;gt; m.Text).ToList() ?? new List&amp;lt;string&amp;gt;());
   }
   System.Diagnostics.Debug.WriteLine(str);
 }
}&lt;/LI-CODE&gt;&lt;P&gt;Notice that the format of the params in my code are different than yours based on what the View Details dialog provided.&lt;/P&gt;&lt;P&gt;4. This gives the final output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="geom_attrib_out.png" style="width: 674px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/48783i936FF9D328C2DDE9/image-size/large?v=v2&amp;amp;px=999" role="button" title="geom_attrib_out.png" alt="geom_attrib_out.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can always double-check if your params are correct by calling Geoprocessing.OpenToolDialog or OpenToolDialogAsync - it should give the same tool dialog view "pre-configured" with the same options. If OpenToolDialog doesn't open the tool dialog correctly then chances are that GP.ExecuteToolAsync won't work correctly either.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; ...
 var calcParams = Geoprocessing.MakeValueArray(
   new object[] { inputLayer, geom_attribs, length_unit, area_unit });
 //use OpenToolDialog to check param format is correct
 Geoprocessing.OpenToolDialogAsync(toolName, calcParams);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 22:34:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203535#M8599</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-08-16T22:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteToolAsync CalculateGeometryAttributes  Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203539#M8600</link>
      <description>&lt;P&gt;very helpful&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 22:44:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/executetoolasync-calculategeometryattributes-error/m-p/1203539#M8600</guid>
      <dc:creator>PeteVitt</dc:creator>
      <dc:date>2022-08-16T22:44:34Z</dc:date>
    </item>
  </channel>
</rss>

