...
zhangyuekai
2024-08-15 4f89840b0c95ebd0ed79dff1ff1973d030a6c17d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Autodesk.Revit.DB;
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));
            GlobalResource.CurrentUIDocument.Selection.SetElementIds(
                new List<ElementId> { elemId });
            GlobalResource.CurrentUIDocument.ShowElements(elemId);
        }
    }
}