using Autodesk.Revit.DB; using Autodesk.Revit.UI; using HStation.RevitDev.RevitDataExport.Common; using System.Collections.Generic; using System.Linq; namespace HStation.RevitDev.RevitDataExport.Utility { public class UIDocumentUtils { public static void ShowLinkedElements(string ids) { if (string.IsNullOrEmpty(ids)) { return; } var idArray = ids.Split(','); var idList = idArray.Select(x => new ElementId(int.Parse(x)))?.ToList(); GlobalResource.CurrentUIDocument.Selection.SetElementIds(idList); GlobalResource.CurrentUIDocument.ShowElements(idList); } public static void ShowElement(string id) { if (string.IsNullOrEmpty(id)) { return; } var elemId = new ElementId(int.Parse(id)); var elem = GlobalResource.CurrentDocument.GetElement(elemId); if (elem == null) { GlobalResource.RevitModels.Remove(id); TaskDialog.Show("错误", "无效ID,已删除!"); GlobalResource.InstancePanel.UpdateForm(); return; } GlobalResource.CurrentUIDocument.Selection.SetElementIds( new List { elemId }); GlobalResource.CurrentUIDocument.ShowElements(elemId); } } }