Revit 2014 can schedule detail items, but some people still aren’t satisfied because out-of-the-box Revit doesn’t schedule the detail item’s view. Here’s an API solution for that.
// typically this would be done during OnStartup
public void registerUpdater()
{
MyUpdater updater = new MyUpdater(this.Application.ActiveAddInId);
UpdaterRegistry.RegisterUpdater(updater);
LogicalOrFilter orFilter = new LogicalOrFilter
(new ElementClassFilter(typeof(View)),
new ElementClassFilter(typeof(FamilyInstance)));
UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), orFilter, Element.GetChangeTypeAny());
UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), orFilter, Element.GetChangeTypeElementAddition());
}
public class MyUpdater : IUpdater
{
static AddInId m_appId;
static UpdaterId m_updaterId;
public MyUpdater(AddInId id)
{
m_appId = id;
m_updaterId = new UpdaterId(m_appId, new Guid("F2FBF6B2-4C06-42d4-97C1-D1B4EB593EFF"));
}
public void Execute(UpdaterData data)
{
Document doc = data.GetDocument();
foreach (Element e in new FilteredElementCollector(doc).OfClass(typeof(FamilyInstance)).OfCategory(BuiltInCategory.OST_DetailComponents))
{
Element v = doc.GetElement(e.OwnerViewId);
e.get_Parameter("View").Set(v.Name);
}
}
public string GetAdditionalInformation() { return "Detail View Parameter"; }
public ChangePriority GetChangePriority() { return ChangePriority.FloorsRoofsStructuralWalls; }
public UpdaterId GetUpdaterId() { return m_updaterId; }
public string GetUpdaterName() { return "Detail View Parameter"; }
}
Can this same logic be used to keep two parameters in an element constantly in sync? Thanks.
Yes
[…] few months ago I posted the source code showing how a “View” field could be added to a Detail Item schedule, even though […]