The interface used to create an updater capable of reacting to changes in the Revit model.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since: 2011
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Remarks
Implement this interface and register an instance of the derived class with the UpdaterRegistry.
Examples

public class WallUpdaterApplication : Autodesk.Revit.UI.IExternalApplication
{
public Result OnStartup(UIControlledApplication application)
{
// Register wall updater with Revit
WallUpdater updater = new WallUpdater(application.ActiveAddInId);
UpdaterRegistry.RegisterUpdater(updater);
// Change Scope = any Wall element
ElementClassFilter wallFilter = new ElementClassFilter(typeof(Wall));
// Change type = element addition
UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), wallFilter,
Element.GetChangeTypeElementAddition());
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication application)
{
WallUpdater updater = new WallUpdater(application.ActiveAddInId);
UpdaterRegistry.UnregisterUpdater(updater.GetUpdaterId());
return Result.Succeeded;
}
}
public class WallUpdater : IUpdater
{
static AddInId m_appId;
static UpdaterId m_updaterId;
WallType m_wallType = null;
// constructor takes the AddInId for the add-in associated with this updater
public WallUpdater(AddInId id)
{
m_appId = id;
m_updaterId = new UpdaterId(m_appId, new Guid("FBFBF6B2-4C06-42d4-97C1-D1B4EB593EFF"));
}
public void Execute(UpdaterData data)
{
Document doc = data.GetDocument();
// Cache the wall type
if (m_wallType == null)
{
FilteredElementCollector collector = new FilteredElementCollector(doc);
collector.OfClass(typeof(WallType));
var wallTypes = from element in collector
where
element.Name == "Exterior - Brick on CMU"
select element;
if (wallTypes.Count<Element>() > 0)
{
m_wallType = wallTypes.Cast<WallType>().ElementAt<WallType>(0);
}
}
if (m_wallType != null)
{
// Change the wall to the cached wall type.
foreach (ElementId addedElemId in data.GetAddedElementIds())
{
Wall wall = doc.GetElement(addedElemId) as Wall;
if (wall != null)
{
wall.WallType = m_wallType;
}
}
}
}
public string GetAdditionalInformation()
{
return "Wall type updater example: updates all newly created walls to a special wall";
}
public ChangePriority GetChangePriority()
{
return ChangePriority.FloorsRoofsStructuralWalls;
}
public UpdaterId GetUpdaterId()
{
return m_updaterId;
}
public string GetUpdaterName()
{
return "Wall Type Updater";
}
}

Public Class WallUpdaterApplication
Implements Autodesk.Revit.UI.IExternalApplication
Public Function OnStartup(application As UIControlledApplication) As Autodesk.Revit.UI.Result Implements IExternalApplication.OnStartup
' Register wall updater with Revit
Dim updater As New WallUpdater(application.ActiveAddInId)
UpdaterRegistry.RegisterUpdater(updater)
' Change Scope = any Wall element
Dim wallFilter As New ElementClassFilter(GetType(Wall))
' Change type = element addition
UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), wallFilter, Element.GetChangeTypeElementAddition())
Return Result.Succeeded
End Function
Public Function OnShutdown(application As UIControlledApplication) As Autodesk.Revit.UI.Result Implements IExternalApplication.OnShutdown
Dim updater As New WallUpdater(application.ActiveAddInId)
UpdaterRegistry.UnregisterUpdater(updater.GetUpdaterId())
Return Result.Succeeded
End Function
End Class
Public Class WallUpdater
Implements IUpdater
Shared m_appId As AddInId
Shared m_updaterId As UpdaterId
Private m_wallType As WallType = Nothing
' constructor takes the AddInId for the add-in associated with this updater
Public Sub New(id As AddInId)
m_appId = id
m_updaterId = New UpdaterId(m_appId, New Guid("FBFBF6B2-4C06-42d4-97C1-D1B4EB593EFF"))
End Sub
Public Sub Execute(data As UpdaterData) Implements IUpdater.Execute
Dim doc As Document = data.GetDocument()
' Cache the wall type
If m_wallType Is Nothing Then
Dim collector As New FilteredElementCollector(doc)
collector.OfClass(GetType(WallType))
Dim wallTypes As System.Collections.Generic.IEnumerable(Of Autodesk.Revit.DB.Element)
wallTypes = From element In collector _
Where element.Name = "Exterior - Brick on CMU" _
Select element
If wallTypes.Count() > 0 Then
m_wallType = wallTypes.Cast(Of WallType)().ElementAt(0)
End If
End If
If m_wallType IsNot Nothing Then
' Change the wall to the cached wall type.
For Each addedElemId As ElementId In data.GetAddedElementIds()
Dim wall As Wall = TryCast(doc.GetElement(addedElemId), Wall)
If wall IsNot Nothing Then
wall.WallType = m_wallType
End If
Next
End If
End Sub
Public Function GetAdditionalInformation() As String Implements IUpdater.GetAdditionalInformation
Return "Wall type updater example: updates all newly created walls to a special wall"
End Function
Public Function GetChangePriority() As ChangePriority Implements IUpdater.GetChangePriority
Return ChangePriority.FloorsRoofsStructuralWalls
End Function
Public Function GetUpdaterId() As UpdaterId Implements IUpdater.GetUpdaterId
Return m_updaterId
End Function
Public Function GetUpdaterName() As String Implements IUpdater.GetUpdaterName
Return "Wall Type Updater"
End Function
End Class