更新
This commit is contained in:
@@ -1,9 +1,51 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
|
||||
|
||||
namespace ShrlAlgoToolkit.Revit.Assists;
|
||||
|
||||
public static class ElementAssist
|
||||
{
|
||||
/// <summary>
|
||||
///获取元素的包围框
|
||||
/// </summary>
|
||||
/// <param name="elements"></param>
|
||||
/// <returns></returns>
|
||||
public static BoundingBoxXYZ GetBoundingBox(List<Element> elements)
|
||||
{
|
||||
if (elements == null || elements.Count == 0)
|
||||
{
|
||||
return new BoundingBoxXYZ();
|
||||
}
|
||||
|
||||
var gmax = XYZ.Zero;
|
||||
var gmin = XYZ.Zero;
|
||||
var elementIds = elements.Select(e => e.Id).ToList();
|
||||
var doc = elements.FirstOrDefault()?.Document;
|
||||
using (SubTransaction sub = new SubTransaction(doc))
|
||||
{
|
||||
sub.Start();
|
||||
Group g;
|
||||
if (doc.IsFamilyDocument)
|
||||
{
|
||||
g = doc.FamilyCreate.NewGroup(elementIds);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
g = doc.Create.NewGroup(elementIds);
|
||||
}
|
||||
gmax = g.get_BoundingBox(null).Max;
|
||||
gmin = g.get_BoundingBox(null).Min;
|
||||
sub.RollBack();
|
||||
}
|
||||
return new BoundingBoxXYZ
|
||||
{
|
||||
Max = gmax,
|
||||
Min = gmin
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 镜像元素
|
||||
/// </summary>
|
||||
@@ -285,7 +327,7 @@ public static class ElementAssist
|
||||
// ElementId typeId = elem.GetTypeId();
|
||||
// if (typeId != ElementId.InvalidElementId)
|
||||
// {
|
||||
// var elementFunc = elem.Document?.GetElement(typeId);
|
||||
// var elementFunc = elem.doc?.GetElement(typeId);
|
||||
// parameterName = elementFunc?.LookupParameter(paramName);
|
||||
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user