<?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 Pass selected features to a GP process in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/pass-selected-features-to-a-gp-process/m-p/33895#M880</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had a bit of trouble running this down. Thought it might help someone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; IMxDocument pMxDoc = (IMxDocument)ArcMap.Application.Document;
 IContentsView pTOC = pMxDoc.CurrentContentsView;
 IFeatureLayer exportLayer = (IFeatureLayer)pTOC.SelectedItem; // Selected Layer

 if (!exportAll)
 {
 IFeatureLayerDefinition iDefLayer = (IFeatureLayerDefinition)pTOC.SelectedItem;
 exportLayer = iDefLayer.CreateSelectionLayer(pTOC.Name, true, null, null);&amp;nbsp; // Selected features
 }

 Geoprocessor gp = new Geoprocessor();
 gp.OverwriteOutput = true;
 gp.AddOutputsToMap = false;

 LayerToKML layerToKML = new LayerToKML();
 layerToKML.layer = exportLayer;
 layerToKML.layer_output_scale = 10000;
 layerToKML.out_kmz_file = fileName;

 try {
 object result = gp.Execute(layerToKML, null);
 messages = new string[gp.MessageCount];
 for (int i = 0; i &amp;lt; gp.MessageCount; i++)
 {
 messages&lt;I&gt; = gp.GetMessage(i);
 }

 return true;
 }
 catch (Exception ex) {
 messages = new string[gp.MessageCount];
 for (int i = 0; i &amp;lt; gp.MessageCount; i++)
 {
 _logger.Error($"GP Message #{i} :"+gp.GetMessage(i));
 }
 return false;
 }&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 15:56:36 GMT</pubDate>
    <dc:creator>JordanBaumgardner</dc:creator>
    <dc:date>2021-12-12T15:56:36Z</dc:date>
    <item>
      <title>Pass selected features to a GP process</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/pass-selected-features-to-a-gp-process/m-p/33895#M880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had a bit of trouble running this down. Thought it might help someone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; IMxDocument pMxDoc = (IMxDocument)ArcMap.Application.Document;
 IContentsView pTOC = pMxDoc.CurrentContentsView;
 IFeatureLayer exportLayer = (IFeatureLayer)pTOC.SelectedItem; // Selected Layer

 if (!exportAll)
 {
 IFeatureLayerDefinition iDefLayer = (IFeatureLayerDefinition)pTOC.SelectedItem;
 exportLayer = iDefLayer.CreateSelectionLayer(pTOC.Name, true, null, null);&amp;nbsp; // Selected features
 }

 Geoprocessor gp = new Geoprocessor();
 gp.OverwriteOutput = true;
 gp.AddOutputsToMap = false;

 LayerToKML layerToKML = new LayerToKML();
 layerToKML.layer = exportLayer;
 layerToKML.layer_output_scale = 10000;
 layerToKML.out_kmz_file = fileName;

 try {
 object result = gp.Execute(layerToKML, null);
 messages = new string[gp.MessageCount];
 for (int i = 0; i &amp;lt; gp.MessageCount; i++)
 {
 messages&lt;I&gt; = gp.GetMessage(i);
 }

 return true;
 }
 catch (Exception ex) {
 messages = new string[gp.MessageCount];
 for (int i = 0; i &amp;lt; gp.MessageCount; i++)
 {
 _logger.Error($"GP Message #{i} :"+gp.GetMessage(i));
 }
 return false;
 }&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 15:56:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/pass-selected-features-to-a-gp-process/m-p/33895#M880</guid>
      <dc:creator>JordanBaumgardner</dc:creator>
      <dc:date>2021-12-12T15:56:36Z</dc:date>
    </item>
  </channel>
</rss>

