<?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 how to set the parameters of create TIN in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-set-the-parameters-of-create-tin/m-p/1372776#M77708</link>
    <description>&lt;P&gt;Now I am developing arcgis pro Add-in. I need to call the tool to create TIN, but I don't know how to set the parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var map = MapView.Active.Map;
// 创建一个图层组
GroupLayer groupLayer = null;
await QueuedTask.Run(() =&amp;gt;
{
    // 创建图层组
    groupLayer = LayerFactory.Instance.CreateGroupLayer(map, 0, "Tin模型");
});
foreach (FeatureLayer selectedLayer in _selectedLayers)
{
    var fcName = selectedLayer.Name;
    var fieldName = comboBox2.Text;
    var gdbPath = Project.Current.DefaultGeodatabasePath;
    var outputdata = System.IO.Path.Combine(gdbPath, $"{fcName}_TIN模型");
    await QueuedTask.Run(async () =&amp;gt;
    {
        // 获取图层的坐标系
        SpatialReference spatialReference = selectedLayer.GetSpatialReference();
        try
        {
            
            // 构建工具箱工具的参数 
            var parameters = Geoprocessing.MakeValueArray(
                outputdata,
                spatialReference, //坐标系
                selectedLayer,
                fieldName,
                "Mass_Points",
                null
            );

            // 执行工具
            var progDlg = new ProgressDialog("进度条", "取消", 100, true);
            progDlg.Show();
            var results = await Geoprocessing.ExecuteToolAsync("ddd.CreateTin", parameters);
            // 工具运行完毕后关闭进度条
            progDlg.Hide();

            // 处理结果
            // 获取错误信息
            if (results.IsFailed)
            {
                await QueuedTask.Run(() =&amp;gt;
                {
                    // 将错误消息写入日志文件
                    System.IO.File.WriteAllLines(@"C:\Users\402\Desktop\test\errorlog.txt", results.Messages.Select(msg =&amp;gt; $"{msg.Type}: {msg.Text}"));
                    Geoprocessing.ShowMessageBox(results.Messages, "工具执行失败", GPMessageBoxStyle.Error);
                });
            }
            else
            {
                MessageBox.Show("工具执行成功！");
                await QueuedTask.Run(() =&amp;gt;
                {
                    var layerDoc = new LayerDocument(new Uri(outputdata).LocalPath);
                    var createParams = new LayerCreationParams(layerDoc.GetCIMLayerDocument())
                    {
                        //Set visibility
                        IsVisible = false,
                    };
                    //Layer outputLayer = LayerFactory.Instance.CreateLayer&amp;lt;Layer&amp;gt;(createParams, MapView.Active.Map);
                    LayerFactory.Instance.CreateLayer&amp;lt;GroupLayer&amp;gt;(createParams, groupLayer);
                    // 获取 GroupLayer 中的图层集合
                    var layerCollection = groupLayer.Layers;

                });
            }
        }
        catch (Exception ex)
        {
            await QueuedTask.Run(() =&amp;gt;
            {
                //System.Windows.MessageBox.Show($"发生错误：{ex.Message}");
                System.Diagnostics.Debug.WriteLine($"发生错误：{ex.Message}");
                System.Diagnostics.Debug.WriteLine($"StackTrace: {ex.StackTrace}");
            });
        }
    });&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 22 Jan 2024 02:31:04 GMT</pubDate>
    <dc:creator>YetaoYang</dc:creator>
    <dc:date>2024-01-22T02:31:04Z</dc:date>
    <item>
      <title>how to set the parameters of create TIN</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-to-set-the-parameters-of-create-tin/m-p/1372776#M77708</link>
      <description>&lt;P&gt;Now I am developing arcgis pro Add-in. I need to call the tool to create TIN, but I don't know how to set the parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var map = MapView.Active.Map;
// 创建一个图层组
GroupLayer groupLayer = null;
await QueuedTask.Run(() =&amp;gt;
{
    // 创建图层组
    groupLayer = LayerFactory.Instance.CreateGroupLayer(map, 0, "Tin模型");
});
foreach (FeatureLayer selectedLayer in _selectedLayers)
{
    var fcName = selectedLayer.Name;
    var fieldName = comboBox2.Text;
    var gdbPath = Project.Current.DefaultGeodatabasePath;
    var outputdata = System.IO.Path.Combine(gdbPath, $"{fcName}_TIN模型");
    await QueuedTask.Run(async () =&amp;gt;
    {
        // 获取图层的坐标系
        SpatialReference spatialReference = selectedLayer.GetSpatialReference();
        try
        {
            
            // 构建工具箱工具的参数 
            var parameters = Geoprocessing.MakeValueArray(
                outputdata,
                spatialReference, //坐标系
                selectedLayer,
                fieldName,
                "Mass_Points",
                null
            );

            // 执行工具
            var progDlg = new ProgressDialog("进度条", "取消", 100, true);
            progDlg.Show();
            var results = await Geoprocessing.ExecuteToolAsync("ddd.CreateTin", parameters);
            // 工具运行完毕后关闭进度条
            progDlg.Hide();

            // 处理结果
            // 获取错误信息
            if (results.IsFailed)
            {
                await QueuedTask.Run(() =&amp;gt;
                {
                    // 将错误消息写入日志文件
                    System.IO.File.WriteAllLines(@"C:\Users\402\Desktop\test\errorlog.txt", results.Messages.Select(msg =&amp;gt; $"{msg.Type}: {msg.Text}"));
                    Geoprocessing.ShowMessageBox(results.Messages, "工具执行失败", GPMessageBoxStyle.Error);
                });
            }
            else
            {
                MessageBox.Show("工具执行成功！");
                await QueuedTask.Run(() =&amp;gt;
                {
                    var layerDoc = new LayerDocument(new Uri(outputdata).LocalPath);
                    var createParams = new LayerCreationParams(layerDoc.GetCIMLayerDocument())
                    {
                        //Set visibility
                        IsVisible = false,
                    };
                    //Layer outputLayer = LayerFactory.Instance.CreateLayer&amp;lt;Layer&amp;gt;(createParams, MapView.Active.Map);
                    LayerFactory.Instance.CreateLayer&amp;lt;GroupLayer&amp;gt;(createParams, groupLayer);
                    // 获取 GroupLayer 中的图层集合
                    var layerCollection = groupLayer.Layers;

                });
            }
        }
        catch (Exception ex)
        {
            await QueuedTask.Run(() =&amp;gt;
            {
                //System.Windows.MessageBox.Show($"发生错误：{ex.Message}");
                System.Diagnostics.Debug.WriteLine($"发生错误：{ex.Message}");
                System.Diagnostics.Debug.WriteLine($"StackTrace: {ex.StackTrace}");
            });
        }
    });&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 Jan 2024 02:31:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-to-set-the-parameters-of-create-tin/m-p/1372776#M77708</guid>
      <dc:creator>YetaoYang</dc:creator>
      <dc:date>2024-01-22T02:31:04Z</dc:date>
    </item>
  </channel>
</rss>

