Files
MsAddIns/MSDevTool/Views/SelectByElementId.xaml.cs
2026-02-28 21:01:57 +08:00

56 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Windows;
using Bentley.DgnPlatformNET;
using Bentley.MstnPlatformNET;
namespace MSDevTool.Views
{
/// <summary>
/// SelectByElementId.xaml 的交互逻辑
/// </summary>
public partial class SelectByElementId : Window
{
public SelectByElementId()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var dgnModel = Session.Instance.GetActiveDgnModel();
var splitStrs = TbElementId.Text.Split(',', ' ', '', ';', '');
if (splitStrs.Length == 0)
{
return;
}
//ElementAgenda agenda = new ElementAgenda();//声明元素容器
//agenda.Empty(true);
SelectionSetManager.EmptyAll();
foreach (var item in splitStrs)
{
if (string.IsNullOrEmpty(item))
{
continue;
}
try
{
var elementId = long.Parse(item);
var element = dgnModel.FindElementById(new ElementId(ref elementId));
//if (element != null)
//{
// agenda.Insert(element, true);//将元素插入容器
//}
SelectionSetManager.AddElement(element, dgnModel);//将元素容器添加到选择集
}
catch (Exception)
{
}
}
//SelectionSetManager.BuildAgenda(ref agenda);//从当前选择集中获得元素
}
}
}