Project Browser incorrect after posted error cancels rename of family type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Run the macro to register this updater that will post an error when an OST_Walls element is changed
Rename a wall type
The error is posted and the wall type is not renamed, but the project browser incorrectly shows the new name
/* * Created by SharpDevelop. * User: harry_000 * Date: 11/20/2019 * Time: 12:51 PM * * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; using Autodesk.Revit.UI; using Autodesk.Revit.DB; using Autodesk.Revit.UI.Selection; using System.Collections.Generic; using System.Linq; namespace FailureTest { [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] [Autodesk.Revit.DB.Macros.AddInId("1844902F-824D-4CCD-B7D1-FB8C8ECC04EA")] public partial class ThisApplication { public static UpdaterId modificationId; public static FailureDefinitionId modificationFailureId; public static Autodesk.Revit.ApplicationServices.Application app; private void Module_Startup(object sender, EventArgs e) { ThisApplication thisApp = sender as ThisApplication; app = thisApp.Application; modificationFailureId = new FailureDefinitionId(Guid.NewGuid()); try { FailureDefinition.CreateFailureDefinition(modificationFailureId, FailureSeverity.Error, "ERROR!!!"); } catch (Exception ex) { TaskDialog.Show("Exception3", ex.Message); } } public void registerUpdater() { try { modificationId = new UpdaterId(app.ActiveAddInId, new Guid("7f453eba-4b9a-40df-b637-eb62a9ebf008")); ModificationUpdater modificationUpdater = new ModificationUpdater(); UpdaterRegistry.RegisterUpdater(modificationUpdater); UpdaterRegistry.AddTrigger(modificationUpdater.GetUpdaterId(), new ElementCategoryFilter(BuiltInCategory.OST_Walls), Element.GetChangeTypeAny()); } catch (Exception ex) { TaskDialog.Show("Exception2", ex.Message); } } public class ModificationUpdater : IUpdater { public void Execute(UpdaterData data) { Document doc = data.GetDocument(); List<ElementId> modifiedIds = data.GetModifiedElementIds().ToList(); foreach (ElementId id in modifiedIds) { FailureMessage failureMessage = new FailureMessage(modificationFailureId); failureMessage.SetFailingElement(id); doc.PostFailure(failureMessage); } } public string GetAdditionalInformation() { return "ModificationUpdater"; } public ChangePriority GetChangePriority() { return ChangePriority.FloorsRoofsStructuralWalls; } public UpdaterId GetUpdaterId() { return modificationId; } public string GetUpdaterName() { return "ModificationUpdater"; } } private void Module_Shutdown(object sender, EventArgs e) { } #region Revit Macros generated code private void InternalStartup() { this.Startup += new System.EventHandler(Module_Startup); this.Shutdown += new System.EventHandler(Module_Shutdown); } #endregion } }
Link copied