TransactionExtension.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Autodesk.Revit.DB;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace FWindSoft.Revit
  8. {
  9. /// <summary>
  10. /// 事务扩展相关
  11. /// </summary>
  12. public static class TransactionExtension
  13. {
  14. /// <summary>
  15. /// 开始事务并设定预处理
  16. /// </summary>
  17. /// <param name="tran"></param>
  18. /// <param name="preprocessor"></param>
  19. /// <returns></returns>
  20. public static TransactionStatus StartWidthPreprocessor(this Transaction tran,IFailuresPreprocessor preprocessor)
  21. {
  22. FailureHandlingOptions failureOptions = tran.GetFailureHandlingOptions();
  23. failureOptions.SetFailuresPreprocessor(preprocessor);
  24. tran.SetFailureHandlingOptions(failureOptions);
  25. return tran.Start();
  26. }
  27. /// <summary>
  28. /// 以默认预处理开始事务
  29. /// </summary>
  30. /// <param name="tran"></param>
  31. /// <returns></returns>
  32. public static TransactionStatus StartWidthPreprocessor(this Transaction tran)
  33. {
  34. return StartWidthPreprocessor(tran, new ErrorWarningPreprocessor(false));
  35. }
  36. }
  37. }