Let’s say there is a specific list of View Scales that you want allowed in your Revit projects. Or certain naming conventions that should be used. Or something else like that where you’d like to automate the process of checking a user’s change and determining if it should be allowed, prevented, or trigger a warning.
This can be done with two pieces of Revit API functionality – Updater & Custom Failures. You can find all the code here and an explanation in the video below.
If you think lessons like there are interesting and helpful, please support Boost Your BIM at Patreon, take one of our video courses on the Revit API, or contact us to discuss how we can work together to make Revit better.
Utils.ViewScaleUpdater viewScaleUpdater = new Utils.ViewScaleUpdater(application.ActiveAddInId); UpdaterRegistry.RegisterUpdater(viewScaleUpdater, true); UpdaterRegistry.AddTrigger( viewScaleUpdater.GetUpdaterId(), new ElementClassFilter(typeof(View)), Element.GetChangeTypeParameter(new ElementId(BuiltInParameter.VIEW_SCALE))); Utils.illegalViewRangeFailureId = new FailureDefinitionId(Guid.NewGuid()); FailureDefinition.CreateFailureDefinition( Utils.illegalViewRangeFailureId, FailureSeverity.Error, "This view scale is not allowed.");