12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /*-------------------------------------------------------------------------
- * 功能描述:RoomToSpaceCommand
- * 作者:xulisong
- * 创建时间: 2019/7/26 10:16:25
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- 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 = "房间转换空间")]
- public class RoomToSpaceCommand : ExternalCommand
- {
- public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
- {
- var document = commandData.Application.ActiveUIDocument.Document;
- var view = document.ActiveView;
- if (view is View3D)
- {
- MessageBox.Show("指定导出平面视图");
- return Result.Succeeded;
- }
- using (Transaction tran = new Transaction(RevitCore.Doc, "创建空间"))
- {
- try
- {
- //tran.Start();
- var list = RoomToSpaceUtils.RoomToSpace(view, new RoomToSpaceTransOption(), tran);
- if (list.Count==0||list.All(r => r.IsSuccess))
- {
- MessageBox.Show("转换成功");
- }
- else
- {
- MessageBox.Show("部分转换成功");
- var text = RoomToSpaceUtils.CreateResult(list).ToString();
- string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "result.txt");
- File.WriteAllText(path, text);
- Process.Start("notepad.exe", path);
- }
- //tran.Commit();
- }
- catch (Exception e)
- {
- //tran.RollBack();
- MessageBox.Show(e.StackTrace.ToString());
- }
- }
- return Result.Succeeded;
- }
- }
- }
|