zhangyuekai
2024-08-08 caa286712423a1a4413113d31f78f515efc400be
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.UI;
using System;
 
namespace HStation.RevitDev.RevitDataExport.Entity
{
    public class PipeUpdater : IUpdater
    {
        public UpdaterId UpdaterId { get; }
        ExternalEvent_ClosePipeMonitor m_pipeMonitorEvent = null;
        ExternalEvent m_monitorHandler = null;
 
        public ElementFilter ElementFilter { get; } = new ElementClassFilter(typeof(Pipe));
 
        public ChangeType ChangeType { get; } = Element.GetChangeTypeElementAddition();
 
        public PipeUpdater(string updaterGuid)
        {
            UpdaterId = new UpdaterId(Common.GlobalResource.CurrentAddinId, new Guid(updaterGuid));
            m_pipeMonitorEvent = new ExternalEvent_ClosePipeMonitor();
            m_monitorHandler = ExternalEvent.Create(m_pipeMonitorEvent);
        }
 
        public void Execute(UpdaterData data)
        {
            m_monitorHandler.Raise();
        }
 
        public string GetAdditionalInformation()
        {
            return "PipeUpdater";
        }
 
        public ChangePriority GetChangePriority()
        {
            return ChangePriority.MEPSystems;
        }
 
        public UpdaterId GetUpdaterId()
        {
            return UpdaterId;
        }
 
        public string GetUpdaterName()
        {
            return "PipeUpdater";
        }
 
        public void Register()
        {
            if (!UpdaterRegistry.IsUpdaterRegistered(UpdaterId))
            {
                UpdaterRegistry.RegisterUpdater(this, false);
                UpdaterRegistry.AddTrigger(UpdaterId, ElementFilter, ChangeType);
                UpdaterRegistry.AddTrigger(UpdaterId, ElementFilter, ChangeType);
            }
            else if (UpdaterRegistry.IsUpdaterEnabled(UpdaterId))
            {
                UpdaterRegistry.AddTrigger(UpdaterId, ElementFilter, ChangeType);
                UpdaterRegistry.AddTrigger(UpdaterId, ElementFilter, ChangeType);
            }
        }
 
        public void RemoveRegister()
        {
            UpdaterRegistry.RemoveAllTriggers(UpdaterId);
        }
    }
}