MbiExportCommand.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:MbiExportCommand
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/28 10:52:24
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using Autodesk.Revit.Attributes;
  13. using Autodesk.Revit.DB;
  14. using Autodesk.Revit.UI;
  15. namespace RevitToJBim
  16. {
  17. /// <summary>
  18. /// 提取数据
  19. /// </summary>
  20. [Transaction(TransactionMode.Manual)]
  21. [Regeneration(RegenerationOption.Manual)]
  22. public class MbiExportCommand : IExternalCommand, IExternalCommandAvailability
  23. {
  24. public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  25. {
  26. try
  27. {
  28. var document = commandData.Application.ActiveUIDocument.Document;
  29. MbiExport.Export(document);
  30. TaskDialog dialog = new TaskDialog("导出");
  31. dialog.MainInstruction = "导出成功";
  32. dialog.Show();
  33. }
  34. catch (Exception e)
  35. {
  36. TaskDialog dialog = new TaskDialog("导出");
  37. dialog.MainInstruction = e.Message + "\n\t" + e.StackTrace.ToString();
  38. dialog.Show();
  39. return Result.Cancelled;
  40. }
  41. return Result.Succeeded;
  42. }
  43. /// <summary>
  44. /// Onlys show the dialog when a document is open, as Dockable dialogs are only available
  45. /// when a document is open.
  46. /// </summary>
  47. public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  48. {
  49. return false;
  50. }
  51. }
  52. }