ExportDocumentToDwg.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:ExportDocumentToDwg
  3. * 作者:xulisong
  4. * 创建时间: 2019/7/25 10:01:03
  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 System.Windows;
  13. using Autodesk.Revit.Attributes;
  14. using Autodesk.Revit.DB;
  15. using Autodesk.Revit.UI;
  16. using FWindSoft.Revit;
  17. using FWindSoft.Revit.Menu;
  18. namespace LRH.Tool
  19. {
  20. [Transaction(TransactionMode.Manual)]
  21. [Regeneration(RegenerationOption.Manual)]
  22. [Button(ButtonName = "导出dwg")]
  23. public class ExportDocumentToDwg : ExternalCommand
  24. {
  25. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  26. {
  27. var paneId = DockablePanes.BuiltInDockablePanes.PropertiesPalette;
  28. //ExternalApplication.CurrentApp.UIControlApp.
  29. DockablePane pane = ExternalApplication.CurrentApp.UIControlApp.GetDockablePane(paneId);
  30. //DockablePanes.BuiltInDockablePanes.
  31. var cc = pane.GetTitle();
  32. var cc1 = pane.IsShown();
  33. pane.Show();
  34. pane.Hide();
  35. //if (cc1)
  36. //{
  37. // pane.Hide();
  38. //}
  39. //else
  40. //{
  41. // pane.Show();
  42. //}
  43. //var document = commandData.Application.ActiveUIDocument.Document;
  44. //var view = document.ActiveView;
  45. //if (view is View3D)
  46. //{
  47. // MessageBox.Show("指定导出平面视图");
  48. // return Result.Succeeded;
  49. //}
  50. //FileSaveDialog dialog = new FileSaveDialog(".dwg");
  51. //var result=dialog.Show();
  52. //if (result == ItemSelectionDialogResult.Confirmed)
  53. //{
  54. // var path= dialog.GetSelectedModelPath();
  55. // DwgExportUtils.ExportDwg(view, @"c:\test.dwg", null);
  56. //}
  57. //DwgExportUtils.ExportDwg(view, @"D:\test.dwg", null);
  58. //using (Transaction tran = new Transaction(RevitCore.Doc, "创建空间"))
  59. //{
  60. // try
  61. // {
  62. // tran.Start();
  63. // var list=RoomToSpaceUtils.RoomToSpace(view,new RoomToSpaceTransOption());
  64. // if(list.All(r=>r.IsSuccess))
  65. // {
  66. // MessageBox.Show("转换成功");
  67. // }
  68. // else
  69. // {
  70. // MessageBox.Show("部分转换成功");
  71. // }
  72. // tran.Commit();
  73. // }
  74. // catch (Exception e)
  75. // {
  76. // tran.RollBack();
  77. // throw;
  78. // }
  79. //}
  80. return Result.Succeeded;
  81. }
  82. }
  83. }