89 lines
3.1 KiB
C#
89 lines
3.1 KiB
C#
|
|
using System;
|
|||
|
|
using System.Windows;
|
|||
|
|
|
|||
|
|
using Autodesk.Revit.Attributes;
|
|||
|
|
using Autodesk.Revit.DB;
|
|||
|
|
using Autodesk.Revit.DB.Mechanical;
|
|||
|
|
using Autodesk.Revit.DB.Plumbing;
|
|||
|
|
using Autodesk.Revit.UI;
|
|||
|
|
using Autodesk.Revit.UI.Selection;
|
|||
|
|
|
|||
|
|
using CommunityToolkit.Mvvm.DependencyInjection;
|
|||
|
|
|
|||
|
|
using Nice3point.Revit.Toolkit.External;
|
|||
|
|
|
|||
|
|
using Sai.Toolkit.Revit.Assist;
|
|||
|
|
using Sai.Toolkit.Revit.Helpers;
|
|||
|
|
|
|||
|
|
namespace RvAddinTest;
|
|||
|
|
[Transaction(TransactionMode.Manual)]
|
|||
|
|
[Regeneration(RegenerationOption.Manual)]
|
|||
|
|
public class TempCmd : ExternalCommand
|
|||
|
|
{
|
|||
|
|
public override void Execute()
|
|||
|
|
{
|
|||
|
|
var elemIds = Document.OfClass<Pipe>().Cast<Pipe>().Where(p => p.Diameter == 50 / 304.8 && !(p.GetLocCurve() as Line).Direction.IsParallelTo(XYZ.BasisZ)).Select(p => p.Id).ToList();
|
|||
|
|
//var elementIds = uidoc.Selection.GetElementIds();
|
|||
|
|
//var elementIds = new FilteredElementCollector(Document).OfClass(typeof(FamilyInstance)).Where(ins => ins.Name == "DN15").Select(ins => ins.Id).ToList();
|
|||
|
|
//using (var ts = new Transaction(Document, "Temp"))
|
|||
|
|
//{
|
|||
|
|
// ts.Start();
|
|||
|
|
//doc.Delete(elementIds);
|
|||
|
|
//foreach (var id in elementIds)
|
|||
|
|
//{
|
|||
|
|
// var elem = Document.GetElement(id) as FamilyInstance;
|
|||
|
|
// var p = elem.GetLocXYZ();
|
|||
|
|
// //ElementTransformUtils.MoveElement(Document,id,-elem.HandOrientation*125/304.8);
|
|||
|
|
// //Document.Regenerate();
|
|||
|
|
// //ElementTransformUtils.MoveElement(Document, id,-elem.FacingOrientation*95/304.8);
|
|||
|
|
// ElementTransformUtils.RotateElement(
|
|||
|
|
// Document,
|
|||
|
|
// id,
|
|||
|
|
// Line.CreateUnbound(p, XYZ.BasisZ),
|
|||
|
|
// Math.PI / 2);
|
|||
|
|
//}
|
|||
|
|
//内衬
|
|||
|
|
//var e = InsulationLiningBase.GetLiningIds(doc, elem.Id);
|
|||
|
|
//保温
|
|||
|
|
//var p = InsulationLiningBase.GetInsulationIds(doc, elem.Id);
|
|||
|
|
//var uidoc = UiApplication.ActiveUIDocument;
|
|||
|
|
//var doc = uidoc.Document;
|
|||
|
|
//var reference = uidoc.Selection.PickObject(ObjectType.Element);
|
|||
|
|
//var elem = doc.GetElement(reference);
|
|||
|
|
//var id = InsulationLiningBase.GetInsulationIds(Document, elem.Id).FirstOrDefault();
|
|||
|
|
// ts.Commit();
|
|||
|
|
//}
|
|||
|
|
Document.Invoke(
|
|||
|
|
ts =>
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
UiDocument.Selection.SetElementIds(elemIds);
|
|||
|
|
|
|||
|
|
//ElementTransformUtils.MoveElements(Document, elemIds, XYZ.BasisZ * 200 / 304.8);
|
|||
|
|
|
|||
|
|
//foreach (var elem in elems)
|
|||
|
|
//{
|
|||
|
|
// elem.get_Parameter(BuiltInParameter.RBS_PIPE_DIAMETER_PARAM).Set(50 / 304.8);
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
}, "CMD");
|
|||
|
|
}
|
|||
|
|
public class ArrangeElement
|
|||
|
|
{
|
|||
|
|
public XYZ Translation { get; set; }
|
|||
|
|
|
|||
|
|
public int Index { get; set; }
|
|||
|
|
|
|||
|
|
public Element ElementToMove { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 与基准元素的间距及方向向量
|
|||
|
|
/// </summary>
|
|||
|
|
public XYZ HorizonDistanceVector { get; set; }
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|