<?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: How can I buffer selected pros? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107844#M7233</link>
    <description>&lt;P&gt;After a few modifications, I finally managed to start, but now the whole application crashes: D&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 10:24:32 GMT</pubDate>
    <dc:creator>DavidMrázek</dc:creator>
    <dc:date>2021-10-15T10:24:32Z</dc:date>
    <item>
      <title>How can I buffer selected pros?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107411#M7226</link>
      <description>&lt;P&gt;Good day,&lt;BR /&gt;how can I trim the buffer layer 200 meters around, then save it in the auxiliary layer. My code attempt:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;protected override async void OnClick()&lt;BR /&gt;{&lt;BR /&gt;await OnSketchCompleteAsync();&lt;BR /&gt;}&lt;BR /&gt;protected async Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync()&lt;BR /&gt;{&lt;BR /&gt;var valueArray = await QueuedTask.Run(() =&amp;gt;&lt;BR /&gt;{&lt;BR /&gt;FeatureLayer fl = MapView.Active.Map.FindLayers("O_Klad_ZTM10").First() as FeatureLayer;&lt;BR /&gt;QueryFilter qf = new QueryFilter();&lt;BR /&gt;string whereClause = "ZTM10_nom LIKE '0602%'";&lt;BR /&gt;qf.WhereClause = whereClause;&lt;BR /&gt;var g = new List&amp;lt;object&amp;gt;();&lt;BR /&gt;using (RowCursor rowCursor = fl.Search(qf))&lt;BR /&gt;{&lt;BR /&gt;while (rowCursor.MoveNext())&lt;BR /&gt;{&lt;BR /&gt;g = new List&amp;lt;object&amp;gt;() { fl.Select(qf) };&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;return Geoprocessing.MakeValueArray(g, null, @"200 Meters");// HERE CODE SHOWS ERROR&lt;BR /&gt;});&lt;BR /&gt;await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArray);&lt;BR /&gt;return true;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;If I haven't explained it enough, ask me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for the advice&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 05:49:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107411#M7226</guid>
      <dc:creator>DavidMrázek</dc:creator>
      <dc:date>2021-10-14T05:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: How can I buffer selected pros?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107480#M7227</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;MakeValueArray first parameter must be FeatureLayer, second - output path.&lt;/P&gt;&lt;P&gt;It's enough to make selection on featurelayer (fl.Select(qf)) and pass it to MakeValueArray. Geoprocessing checks is selection empty. Dependent on it geoprocessing tool calculates on all featurelayer or feature layer selection&lt;/P&gt;&lt;P&gt;Below working function code to make buffer layer:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public static bool CalculateBuffer(FeatureLayer featureLayer, string sOutputPath, double dDistance, string sUnits)
        {
            try
            {
                var parameters = Geoprocessing.MakeValueArray(featureLayer, sOutputPath,
                    string.Format("{0} {1}", Convert.ToString(dDistance, System.Globalization.CultureInfo.InvariantCulture), sUnits));
                var gpResult = Geoprocessing.ExecuteToolAsync("Buffer_analysis", parameters, null, CancelableProgressor.None,
                        GPExecuteToolFlags.None);
                gpResult.Wait();
                return !gpResult.Result.IsFailed;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString(), System.Reflection.Assembly.GetExecutingAssembly().FullName);
                throw;
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;After layer selection you can call that function. And specify full path for output. For example full path to shapefile (c:\Temp\buffers.shp)&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 13:16:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107480#M7227</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-10-14T13:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: How can I buffer selected pros?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107798#M7231</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I tried to redo it according to your advice and the whole code will work, but nothing in ARCGIS PRO did it.&lt;BR /&gt;I'm probably making an obvious mistake somewhere, but I don't know where ...&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override async void OnClick()
{
var polygonFeatureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault(lyr =&amp;gt; lyr.ShapeType == esriGeometryType.esriGeometryPolygon);
if (polygonFeatureLayer == null)
return;
var rozsah = 200;
CalculateBuffer(polygonFeatureLayer, @"C:\Users\mrazekd\Desktop\ukoly\ProAppModule1\buffers.shp", rozsah,"meteres");
await OnSketchCompleteAsync();
}
protected async Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync()
{
var valueArray = await QueuedTask.Run(() =&amp;gt;
{
FeatureLayer fl = MapView.Active.Map.FindLayers("O_Klad_ZTM10").First() as FeatureLayer;
QueryFilter qf = new QueryFilter();
string whereClause = "ZTM10_nom LIKE '0602%'";
qf.WhereClause = whereClause;
var g = new List&amp;lt;object&amp;gt;();
using (RowCursor rowCursor = fl.Search(qf))
{
while (rowCursor.MoveNext())
{
Feature feature = rowCursor.Current as Feature;
Polygon polygon = feature.GetShape() as Polygon;
g = new List&amp;lt;object&amp;gt;() {polygon};
}
}
return Geoprocessing.MakeValueArray(g, null, @"C:\Users\mrazekd\Desktop\ukoly\ProAppModule1\buffers.shp");
});
await Geoprocessing.ExecuteToolAsync("PomocnaVrstva", valueArray);
return true;
}
public static bool CalculateBuffer(FeatureLayer featureLayer, string sOutputPath, double dDistance, string sUnits)
{
try
{
var parameters = Geoprocessing.MakeValueArray(featureLayer, sOutputPath,
string.Format("{0} {1}", Convert.ToString(dDistance, System.Globalization.CultureInfo.InvariantCulture), sUnits));
var gpResult = Geoprocessing.ExecuteToolAsync("Buffer_analysis", parameters, null, CancelableProgressor.None,
GPExecuteToolFlags.None);
gpResult.Wait();
return !gpResult.Result.IsFailed;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString(), System.Reflection.Assembly.GetExecutingAssembly().FullName);
throw;
}
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 15 Oct 2021 05:50:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107798#M7231</guid>
      <dc:creator>DavidMrázek</dc:creator>
      <dc:date>2021-10-15T05:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can I buffer selected pros?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107808#M7232</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;As I understand from your first question&amp;nbsp; you need code like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override async void OnClick()
{
	FeatureLayer fl = MapView.Active.Map.FindLayers("O_Klad_ZTM10").First() as FeatureLayer;	
	if (fl == null)
		return;

	QueuedTask.Run(() = &amp;gt;
	{
		QueryFilter qf = new QueryFilter();
		string whereClause = "ZTM10_nom LIKE '0602%'";
		qf.WhereClause = whereClause;
		fl.Select(qf)
	});

	var rozsah = 200;
	CalculateBuffer(fl, @"C:\Users\mrazekd\Desktop\ukoly\ProAppModule1\buffers.shp", rozsah, "Meters");
}&lt;/LI-CODE&gt;&lt;P&gt;You need to check asynchronous things. of that code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 06:47:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107808#M7232</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-10-15T06:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I buffer selected pros?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107844#M7233</link>
      <description>&lt;P&gt;After a few modifications, I finally managed to start, but now the whole application crashes: D&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 10:24:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107844#M7233</guid>
      <dc:creator>DavidMrázek</dc:creator>
      <dc:date>2021-10-15T10:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I buffer selected pros?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107846#M7234</link>
      <description>&lt;P&gt;Share your final code please&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 10:29:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107846#M7234</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-10-15T10:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I buffer selected pros?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107847#M7235</link>
      <description>&lt;P&gt;Sorry it works, I was looking for the final shapefile elsewhere, and I didn't write await.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!!!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 10:37:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-can-i-buffer-selected-pros/m-p/1107847#M7235</guid>
      <dc:creator>DavidMrázek</dc:creator>
      <dc:date>2021-10-15T10:37:22Z</dc:date>
    </item>
  </channel>
</rss>

