<?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 Re: Geoprocessing with objects/classes in .NET in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205043#M8623</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/42133"&gt;@GKmieliauskas&lt;/a&gt;&amp;nbsp;that is exactly what I have in my original post. It doesnt work. I also posted the error.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Aug 2022 16:04:55 GMT</pubDate>
    <dc:creator>AbelPerez</dc:creator>
    <dc:date>2022-08-22T16:04:55Z</dc:date>
    <item>
      <title>Geoprocessing with objects/classes in .NET</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1204790#M8613</link>
      <description>&lt;P&gt;With Pro 3.0 I am trying to implement the SelectLayerByLocation geoprocessing tool. I have &lt;U&gt;&lt;STRONG&gt;objects/classes&lt;/STRONG&gt;&lt;/U&gt; that I want to pass in to the tool. I've looked at the community samples and the ESRI forums and I must be missing something because this throws an exception&lt;/P&gt;&lt;P&gt;System.InvalidOperationException&lt;BR /&gt;HResult=0x80131509&lt;BR /&gt;Message=convert unsupported type&lt;BR /&gt;Source=ArcGIS.Desktop.GeoProcessing&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;object[] listOfParameter = { SelectedProximityLayer, "WITHIN_A_DISTANCE_GEODESIC", featOrigin, "100 NAUTICALMILES", "NEW_SELECTION", "NOT_INVERT" };
var parameters = Geoprocessing.MakeValueArray(listOfParameter); //exception here
var gpResult = await Geoprocessing.ExecuteToolAsync("SelectLayerByLocation_management", parameters);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With ArcMap you could call out a native .NET API to do this and I can't find anything similar with Pro:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;Dim selLyrLoc As New SelectLayerByLocation
selLyrLoc.in_layer = pPointProxLayer                            'the selection will be applied to this layer
selLyrLoc.overlap_type = "WITHIN_A_DISTANCE_GEODESIC"           'we want features within a geodesic distance
selLyrLoc.select_features = pFeatSelOrigin                      'this is the source feature
selLyrLoc.search_distance = "100 NAUTICALMILES"                 'search within 100 NM of the source
selLyrLoc.selection_type = "NEW_SELECTION"                      'new selection
selLyrLoc.invert_spatial_relationship = "NOT_INVERT"            'do not invert selection

'run the geoprocessor
Dim res As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult = CType(GP.Execute(selLyrLoc, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see that the parameter list is a string list but how do I feed my objects /classes to any geoprocessing tool?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 22:58:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1204790#M8613</guid>
      <dc:creator>AbelPerez</dc:creator>
      <dc:date>2022-08-20T22:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing with objects/classes in .NET</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1204823#M8614</link>
      <description>&lt;P&gt;After looking at the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/select-layer-by-location.htm" target="_self"&gt;documentation&lt;/A&gt; and my prior work with ArcMap I see where I erred. The parameter&amp;nbsp;&lt;SPAN&gt;Selecting Features is defined as a&amp;nbsp;Feature Layer and I was trying to pass it a Feature object. All I had to do was select my feature in the layer and pass it the layer like so:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//clear the origin layer of ALL selections
SelectedOriginLayer.ClearSelection();

//select ONLY the origin feature in the origin layer
var qf = new QueryFilter();
qf.WhereClause = "FID=1";
Selection selOrigin = SelectedOriginLayer.Select(qf, SelectionCombinationMethod.New);

//clear the proximity layer of ALL selections
SelectedProximityLayer.ClearSelection();

//gp
List&amp;lt;object&amp;gt; values = new List&amp;lt;object&amp;gt;();
values.Add(SelectedProximityLayer);                     //in_layer: the selection will be applied to this layer
values.Add("WITHIN_A_DISTANCE_GEODESIC");               //overlap_type: we want features within a geodesic distance
values.Add(SelectedOriginLayer);                        //select_features: this is the source (the original)
values.Add("100 NAUTICALMILES");                        //search_distance: search within 100 NM of the source
values.Add("NEW_SELECTION");                            //selection_type: new selection
values.Add("NOT_INVERT");                               //invert_spatial_relationship: do not invert selection

var parameters = Geoprocessing.MakeValueArray(values);
IGPResult gpResult = await Geoprocessing.ExecuteToolAsync("SelectLayerByLocation_management", parameters);&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2022 18:38:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1204823#M8614</guid>
      <dc:creator>AbelPerez</dc:creator>
      <dc:date>2022-08-21T18:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing with objects/classes in .NET</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1204842#M8615</link>
      <description>&lt;P&gt;Unfortunately it didn't work. I have been trying for 2 days to get this to work and its a bit disappointing to me that at Pro 3.0 that geometry objects are not supported with geoprocessing. At least the ones I have tested. This is what ended up working for me after numerous tests (why are we still relying on strings when we have classes and objects?):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//clear the origin layer of ALL selections
SelectedOriginLayer.ClearSelection();

//select ONLY the origin feature in the origin layer
var qf = new QueryFilter();
qf.WhereClause = "FID=1";
Selection selOrigin = SelectedOriginLayer.Select(qf, SelectionCombinationMethod.New);

//clear the proximity layer of ALL selections
SelectedProximityLayer.ClearSelection();

//gp
List&amp;lt;string&amp;gt; vals= new List&amp;lt;string&amp;gt;();
vals.Add(SelectedProximityLayer.URI);                  //in_layer: the selection will be applied to this layer
vals.Add("WITHIN_A_DISTANCE_GEODESIC");               //overlap_type: we want features within a geodesic distance
vals.Add(SelectedOriginLayer.URI);                     //select_features: this is the source (the original)
vals.Add("100 NAUTICALMILES");                        //search_distance: search within 100 NM of the source
vals.Add("NEW_SELECTION");                            //selection_type: new selection
vals.Add("NOT_INVERT");                               //invert_spatial_relationship: do not invert selection

IGPResult gpResult = await Geoprocessing.ExecuteToolAsync("SelectLayerByLocation_management", vals);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Aug 2022 23:02:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1204842#M8615</guid>
      <dc:creator>AbelPerez</dc:creator>
      <dc:date>2022-08-21T23:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing with objects/classes in .NET</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1204885#M8616</link>
      <description>&lt;P&gt;The way to set geoprocessing parameters is like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var parameters = Geoprocessing.MakeValueArray(SelectedProximityLayer, "WITHIN_A_DISTANCE_GEODESIC", featOrigin, "100 NAUTICALMILES", "NEW_SELECTION", "NOT_INVERT");&lt;/LI-CODE&gt;&lt;P&gt;There is no need to form object or string array. Geoprocessing MakeValueArray knows how to convert each parameter depending on it type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 05:51:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1204885#M8616</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-08-22T05:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing with objects/classes in .NET</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205043#M8623</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/42133"&gt;@GKmieliauskas&lt;/a&gt;&amp;nbsp;that is exactly what I have in my original post. It doesnt work. I also posted the error.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 16:04:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205043#M8623</guid>
      <dc:creator>AbelPerez</dc:creator>
      <dc:date>2022-08-22T16:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing with objects/classes in .NET</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205124#M8626</link>
      <description>&lt;P&gt;Abel, Looking at the tool help regarding input parameters, as written, this does looks correct to me also&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//gp
List&amp;lt;string&amp;gt; vals= new List&amp;lt;string&amp;gt;();
vals.Add(SelectedProximityLayer.URI);
vals.Add(...);
...
await Geoprocessing.ExecuteToolAsync("SelectLayerByLocation_management",
                                        parameters)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my stab at this (which does work for me):&lt;/P&gt;&lt;P&gt;Given these inputs (using Crimes and Fire stations point data sets from the community samples data):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sel_by_layer_gp_dlg.jpg" style="width: 370px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49151iFC7423DFA80DEA62/image-size/large?v=v2&amp;amp;px=999" role="button" title="sel_by_layer_gp_dlg.jpg" alt="sel_by_layer_gp_dlg.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have this code - as Gintatuatas mentioned I just pass the param values straight to MakeValueArray:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class TestGP : Button
 {
  protected async override void OnClick()
  {
   var sel_tool_name = "SelectLayerByLocation_management";
   var input_layer = MapView.Active.Map.GetLayersAsFlattenedList()
            .OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault(l =&amp;gt; l.Name == "Crimes");
   if (input_layer == null) return;
   var sel_layer = MapView.Active.Map.GetLayersAsFlattenedList()
            .OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault(l =&amp;gt; l.Name == "Fire_Stations");
   if (sel_layer == null) return;
   var parameters = 
    Geoprocessing.MakeValueArray(
     input_layer, "WITHIN_A_DISTANCE_GEODESIC", sel_layer, "1000 Feet", 
                  "NEW_SELECTION", "NOT_INVERT");
   await Geoprocessing.ExecuteToolAsync(sel_tool_name, parameters);
   //test params by showing the tool dialog
   //await Geoprocessing.OpenToolDialogAsync(sel_tool_name, parameters);
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(these are my parameters returned from&amp;nbsp;Geoprocessing.MakeValueArray:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sel_by_layer_params.jpg" style="width: 507px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/49152iC596299F94DE6DFE/image-size/large?v=v2&amp;amp;px=999" role="button" title="sel_by_layer_params.jpg" alt="sel_by_layer_params.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 19:33:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205124#M8626</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-08-22T19:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing with objects/classes in .NET</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205197#M8631</link>
      <description>&lt;P&gt;Let me test this. The only difference I see is that I am using BasicFeatureLayer. Not sure why though. I think the example I was following used that class. Now that I look at the differences, the FeatureLayer class has more methods. So let me change to that class and test again.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 23:15:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205197#M8631</guid>
      <dc:creator>AbelPerez</dc:creator>
      <dc:date>2022-08-22T23:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing with objects/classes in .NET</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205646#M8637</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/42133"&gt;@GKmieliauskas&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/145101"&gt;@CharlesMacleod&lt;/a&gt;&amp;nbsp;well that seemed to work. thanks!!!&lt;/P&gt;&lt;P&gt;The only thing I did different was change my classes from BasicFeatureLayer to&amp;nbsp;FeatureLayer.&lt;BR /&gt;I wonder if the GP tools just dont work with the&amp;nbsp;BasicFeatureLayer class.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 23:13:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205646#M8637</guid>
      <dc:creator>AbelPerez</dc:creator>
      <dc:date>2022-08-23T23:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing with objects/classes in .NET</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205650#M8638</link>
      <description>&lt;P&gt;Actually I found the possible source of &lt;STRONG&gt;all&lt;/STRONG&gt; my problems. I suspect that many other devs might also make this simple mistake. The function&amp;nbsp;MakeValueArray takes as its input a variable number of objects as an array. I thought that if i passed it a List of Objects it would work as well. It does compile so merrily I went along. However, it is reading the List of Objects as a single object. What I needed to do was convert that List of Objects to an Array of objects AND then pass that to the GP tool.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//create the parameter list for the GP
List&amp;lt;object&amp;gt; vals = new List&amp;lt;object&amp;gt;();
vals.Add(lyrProximity);                               //in_layer: the selection will be applied to this layer
vals.Add("WITHIN_A_DISTANCE_GEODESIC");               //overlap_type: we want features within a geodesic distance
vals.Add(lyrOrigin);                                  //select_features: this is the source
vals.Add(radiusInNm.ToString() + " NAUTICALMILES");   //search_distance: search within xNM of the source
vals.Add("NEW_SELECTION");                            //selection_type: new selection
vals.Add("NOT_INVERT");                               //invert_spatial_relationship: do not invert selection

//var parameters = Geoprocessing.MakeValueArray(vals); //compiles but does not work
var parameters = Geoprocessing.MakeValueArray(vals.ToArray()); //compiles and works

IGPResult gpResult = await Geoprocessing.ExecuteToolAsync("SelectLayerByLocation_management", parameters);&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;</description>
      <pubDate>Tue, 23 Aug 2022 23:28:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205650#M8638</guid>
      <dc:creator>AbelPerez</dc:creator>
      <dc:date>2022-08-23T23:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing with objects/classes in .NET</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205652#M8639</link>
      <description>&lt;P&gt;Actually I found the possible source of all my problems. I suspect that many other devs might also make this simple mistake.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;//create the parameter list for the GP
List&amp;lt;object&amp;gt; vals = new List&amp;lt;object&amp;gt;();
vals.Add(lyrProximity);                               //in_layer: the selection will be applied to this layer
vals.Add("WITHIN_A_DISTANCE_GEODESIC");               //overlap_type: we want features within a geodesic distance
vals.Add(lyrOrigin);                                  //select_features: this is the source
vals.Add(radiusInNm.ToString() + " NAUTICALMILES");   //search_distance: search within xNM of the source
vals.Add("NEW_SELECTION");                            //selection_type: new selection
vals.Add("NOT_INVERT");                               //invert_spatial_relationship: do not invert selection

//var parameters = Geoprocessing.MakeValueArray(vals); //compiles but does not work
var parameters = Geoprocessing.MakeValueArray(vals.ToArray()); //compiles and works

IGPResult gpResult = await Geoprocessing.ExecuteToolAsync("SelectLayerByLocation_management", parameters);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Aug 2022 23:31:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/geoprocessing-with-objects-classes-in-net/m-p/1205652#M8639</guid>
      <dc:creator>AbelPerez</dc:creator>
      <dc:date>2022-08-23T23:31:50Z</dc:date>
    </item>
  </channel>
</rss>

