/*------------------------------------------------------------------------- * 功能描述:ExportDocumentToDwg * 作者:xulisong * 创建时间: 2019/7/25 10:01:03 * 版本号:v1.0 * -------------------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using FWindSoft.Revit; using FWindSoft.Revit.Menu; namespace LRH.Tool { [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] [Button(ButtonName = "导出dwg")] public class ExportDocumentToDwg : ExternalCommand { public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var paneId = DockablePanes.BuiltInDockablePanes.PropertiesPalette; //ExternalApplication.CurrentApp.UIControlApp. DockablePane pane = ExternalApplication.CurrentApp.UIControlApp.GetDockablePane(paneId); //DockablePanes.BuiltInDockablePanes. var cc = pane.GetTitle(); var cc1 = pane.IsShown(); pane.Show(); pane.Hide(); //if (cc1) //{ // pane.Hide(); //} //else //{ // pane.Show(); //} //var document = commandData.Application.ActiveUIDocument.Document; //var view = document.ActiveView; //if (view is View3D) //{ // MessageBox.Show("指定导出平面视图"); // return Result.Succeeded; //} //FileSaveDialog dialog = new FileSaveDialog(".dwg"); //var result=dialog.Show(); //if (result == ItemSelectionDialogResult.Confirmed) //{ // var path= dialog.GetSelectedModelPath(); // DwgExportUtils.ExportDwg(view, @"c:\test.dwg", null); //} //DwgExportUtils.ExportDwg(view, @"D:\test.dwg", null); //using (Transaction tran = new Transaction(RevitCore.Doc, "创建空间")) //{ // try // { // tran.Start(); // var list=RoomToSpaceUtils.RoomToSpace(view,new RoomToSpaceTransOption()); // if(list.All(r=>r.IsSuccess)) // { // MessageBox.Show("转换成功"); // } // else // { // MessageBox.Show("部分转换成功"); // } // tran.Commit(); // } // catch (Exception e) // { // tran.RollBack(); // throw; // } //} return Result.Succeeded; } } }