2025-04-24 20:56:44 +08:00
|
|
|
|
using Autodesk.Revit.Attributes;
|
2024-09-22 11:05:41 +08:00
|
|
|
|
using Autodesk.Revit.DB.Mechanical;
|
|
|
|
|
|
using Nice3point.Revit.Toolkit.External;
|
|
|
|
|
|
|
2025-02-10 20:53:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-04-24 20:56:44 +08:00
|
|
|
|
namespace ShrlAlgoToolkit.RevitAddins.RvMEP;
|
2024-09-22 11:05:41 +08:00
|
|
|
|
|
|
|
|
|
|
[Transaction(TransactionMode.Manual)]
|
|
|
|
|
|
[Regeneration(RegenerationOption.Manual)]
|
|
|
|
|
|
public class TerminalConnectToDuctCmd : ExternalCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
public override void Execute()
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
#if REVIT2018 || REVIT2020
|
|
|
|
|
|
var terminalId = UiDocument.Selection
|
|
|
|
|
|
.PickObject(
|
|
|
|
|
|
Autodesk.Revit.UI.Selection.ObjectType.Element,
|
|
|
|
|
|
new FuncFilter(e => e.Category.Id.IntegerValue == -2008013),
|
|
|
|
|
|
"请选择风管末端"
|
|
|
|
|
|
)
|
|
|
|
|
|
.ElementId;
|
|
|
|
|
|
#elif REVIT2025
|
|
|
|
|
|
var terminalId = UiDocument.Selection
|
|
|
|
|
|
.PickObject(
|
|
|
|
|
|
Autodesk.Revit.UI.Selection.ObjectType.Element,
|
|
|
|
|
|
new FuncFilter(e => e.Category.Id.Value == -2008013),
|
|
|
|
|
|
"请选择风管末端"
|
|
|
|
|
|
)
|
|
|
|
|
|
.ElementId;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
var ductId = UiDocument.Selection
|
|
|
|
|
|
.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, new GenericFilter<Duct>(), "请选择连接到的风管")
|
|
|
|
|
|
.ElementId;
|
|
|
|
|
|
Document.Invoke(_ =>
|
|
|
|
|
|
{
|
|
|
|
|
|
MechanicalUtils.ConnectAirTerminalOnDuct(Document, terminalId, ductId);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception) { }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|