C# .NET Revit 2019.1 SDK StairsAutomation sample.
- Remove warning messages for full on-line automation – Detailed blog post on swallowing StairsAutomation warnings
- Remove user interface references and automatically run – Detailed blog post on auto-run an add-in for design automation
- Stair #3 generates 8 warnings about overlapping handrail model line elements.
- Stair #4 generates 1 warning about a missing riser.
Happily, Revit warnings can easily be handled automatically making use of the Failure API.
Specifically, we presented a generic warning swallower that can handle just about any warning message that crops up.
For the StairsAutomation sample, nothing much is required.
The code generating the stairs obviously runs inside a Transaction
, and that, in turn, is enclosed in a StairsEditScope
.
The call to Commit
the stair editing scope is called with a custom failures preprocessor instance:
editScope.Commit( new StairsEditScopeFailuresPreprocessor() );
In the original sample, the failures preprocessor does next to nothing:
class StairsEditScopeFailuresPreprocessor : IFailuresPreprocessor { public FailureProcessingResult PreprocessFailures( FailuresAccessor a ) { return FailureProcessingResult.Continue; } }
I simply added the following lines of code to it, to delete all warnings before returning:
IList<FailureMessageAccessor> failures = a.GetFailureMessages(); foreach( FailureMessageAccessor f in failures ) { FailureSeverity fseverity = a.GetSeverity(); if( fseverity == FailureSeverity.Warning ) { a.DeleteWarning( f ); } }
Now, all five stair variations are created without any warning messages being displayed.
For more deails, please refer to The Building Coder discussion on swallowing StairsAutomation warnings.
- Remove all references to
RevitAPIUI.dll
- Replace the external command derived from
IExternalCommand
by an external DB application derived fromIExternalDBApplication
- Run automatically, e.g., hooking into
ApplicationInitialized
- Open model file
For more deails, please refer to The Building Coder discussion on auto-running an add-in for design automation.
Jeremy Tammik, The Building Coder, Forge Platform Development, ADN Open, Autodesk Inc. modified the original SDK sample.
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.