Skip to content

Revit 2019.1 SDK StairsAutomation sample warning elimination and UI removal

License

Notifications You must be signed in to change notification settings

jeremytammik/StairsAutomation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StairsAutomation

Revit API Platform .NET License

C# .NET Revit 2019.1 SDK StairsAutomation sample.

  1. Remove warning messages for full on-line automation – Detailed blog post on swallowing StairsAutomation warnings
  2. Remove user interface references and automatically run – Detailed blog post on auto-run an add-in for design automation

StairsAutomation result

Step 1. Remove Warning Messages for Full On-Line Automation

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();
 
  foreachFailureMessageAccessor 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.

Step 2. Remove User Interface References and Automatically Run Add-In

  • Remove all references to RevitAPIUI.dll
  • Replace the external command derived from IExternalCommand by an external DB application derived from IExternalDBApplication
  • 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.

Author

Jeremy Tammik, The Building Coder, Forge Platform Development, ADN Open, Autodesk Inc. modified the original SDK sample.

License

This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.