/* ==============================================================================
* 功能描述:OtherCommand
* 创 建 者:Garrett
* 创建日期:2019/11/26 9:49:59
* ==============================================================================*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using FWindSoft.Data;
using FWindSoft.Revit;
using FWindSoft.Revit.Menu;
using Saga.PlugIn.ModelCheck;
using Saga.PlugIn.Other;
using SAGA.DotNetUtils.Geometry;
using SAGA.DotNetUtils.Others;
using SAGA.RevitUtils;
using SAGA.RevitUtils.Extends;
using ExternalCommand = FWindSoft.Revit.ExternalCommand;
namespace LRH.Tool
{
///
/// 查询设备所在空间
///
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
[Button(ButtonName = "查询设备所在空间", Index = 1, TabName = "禹数建模工具", PanelName = "工具", ImageName = "pack://application:,,,/Saga.PlugIn;component/Image/查询设备所在空间")]
public class ReportEquipInSpaceCommand : ExternalCommand
{
public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{
var fi = commandData.Application.PickElement("请选择图元") as FamilyInstance;
if (fi == null) return Result.Succeeded;
var space = fi.GetReferenceSpace();
string str = "", str2 = "";
do
{
if (space != null)
{
List spaceVertex = space.GetBoundaryVertexes().FirstOrDefault();
if (spaceVertex == null)
{
str = "Boundary 为Null";
break;
}
}
} while (false);
MessageShowBase.Infomation($"设备所在空间Id为{space?.Id}");
}
catch (Exception e)
{
MessageShow.Show(e);
return Result.Cancelled;
}
return Result.Succeeded;
}
}
///
/// 复制指定参数A的值到指定参数B中
///
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
[Button(ButtonName = "复制指定参数A的值到指定参数B中", Index = 2, TabName = "禹数建模工具", PanelName = "工具", ImageName = "pack://application:,,,/Saga.PlugIn;component/Image/复制指定参数A的值到指定参数B中")]
public class CopyParameterValueCommand : ExternalCommand
{
public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{
var tip = MessageShowBase.Question("确定要复制参数?");
if (tip)
{
WinParameterDic win = new WinParameterDic();
if (win.ShowDialog() == true)
{
if (!SingleInstance.Instance.SetCopyParameterDic(win.ParameterDic,
win.CopyRange)) return Result.Cancelled;
var doc = RevitCore.Doc;
SingleInstance.Instance.Execute(doc);
MessageShowBase.Infomation("信息点的值复制完成");
}
}
}
catch (Exception e)
{
MessageShow.Show(e);
return Result.Cancelled;
}
return Result.Succeeded;
}
public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
///
/// 重命名系统名称
///
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
[Button(ButtonName = "重命名系统名称", Index = 3, TabName = "禹数建模工具", PanelName = "工具", ImageName = "pack://application:,,,/Saga.PlugIn;component/Image/重命名系统名称")]
public class RenameSystemNameCommand : ExternalCommand
{
public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{
var iDataCorrect = new RenameSystemName();
if (true)
{
WinRenameConfig win = new WinRenameConfig();
if (win.ShowDialog() == true)
{
iDataCorrect.Operate(win.ReferenceFilePath, win.RevitDirs);
MessageShowBase.Infomation("系统名称已修改,请检查");
}
}
}
catch (Exception e)
{
MessageShow.Show(e);
return Result.Cancelled;
}
return Result.Succeeded;
}
public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
}