Skip to content

Commit 4a9ff14

Browse files
committed
cherry pick lookup-foundation/RevitLookup#187 - GetBoundarySegments method of spatial elements support added
1 parent 1e089d5 commit 4a9ff14

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System.Collections.Generic;
2+
using System.Linq.Expressions;
3+
using Autodesk.Revit.DB;
4+
5+
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
6+
7+
namespace RevitDBExplorer.Domain.DataModel.MemberAccessors
8+
{
9+
internal class SpatialElement_GetBoundarySegments : MemberAccessorByType<SpatialElement>, ICanCreateMemberAccessor
10+
{
11+
public IEnumerable<LambdaExpression> GetHandledMembers() { yield return (SpatialElement x) => x.GetBoundarySegments(null); }
12+
13+
14+
protected override bool CanBeSnoooped(Document document, SpatialElement value) => true;
15+
16+
protected override string GetLabel(Document document, SpatialElement value)
17+
{
18+
return "[[BoundarySegment]]";
19+
}
20+
21+
protected override IEnumerable<SnoopableObject> Snooop(Document document, SpatialElement element)
22+
{
23+
var options = new[]
24+
{
25+
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center, StoreFreeBoundaryFaces = true },
26+
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreBoundary, StoreFreeBoundaryFaces = true },
27+
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish, StoreFreeBoundaryFaces = true },
28+
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreCenter, StoreFreeBoundaryFaces = true },
29+
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center, StoreFreeBoundaryFaces = false },
30+
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreBoundary, StoreFreeBoundaryFaces = false },
31+
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish, StoreFreeBoundaryFaces = false },
32+
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreCenter, StoreFreeBoundaryFaces = false },
33+
};
34+
35+
foreach (var option in options)
36+
{
37+
yield return SnoopableObject.CreateKeyValuePair(document, option, element.GetBoundarySegments(option), "options");
38+
}
39+
}
40+
}
41+
}

sources/RevitDBExplorer/Domain/DataModel/ValueContainers/Base/ValueContainerFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ internal static class ValueContainerFactory
6262
new RevitApiEventArgsHandler(),
6363
new WorksetIdHandler(),
6464
new FailureDefinitionIdHandler(),
65+
new SpatialElementBoundaryOptionsHandler(),
66+
new BoundarySegmentHandler(),
6567

6668
// generic
6769
new ElementHandler(),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Autodesk.Revit.DB;
2+
using RevitDBExplorer.Domain.DataModel.ValueContainers.Base;
3+
4+
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
5+
6+
namespace RevitDBExplorer.Domain.DataModel.ValueContainers
7+
{
8+
internal class BoundarySegmentHandler : TypeHandler<BoundarySegment>
9+
{
10+
protected override bool CanBeSnoooped(SnoopableContext context, BoundarySegment boundarySegment) => boundarySegment is not null;
11+
12+
protected override string ToLabel(SnoopableContext context, BoundarySegment boundarySegment)
13+
{
14+
return $"ID: {boundarySegment.ElementId}, {boundarySegment.GetCurve()?.Length} ft"; ;
15+
}
16+
}
17+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Autodesk.Revit.DB;
2+
using RevitDBExplorer.Domain.DataModel.ValueContainers.Base;
3+
4+
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
5+
6+
namespace RevitDBExplorer.Domain.DataModel.ValueContainers
7+
{
8+
internal class SpatialElementBoundaryOptionsHandler : TypeHandler<SpatialElementBoundaryOptions>
9+
{
10+
protected override bool CanBeSnoooped(SnoopableContext context, SpatialElementBoundaryOptions value) => true;
11+
protected override string ToLabel(SnoopableContext context, SpatialElementBoundaryOptions value)
12+
{
13+
if (value.StoreFreeBoundaryFaces == true)
14+
{
15+
return $"{value.SpatialElementBoundaryLocation}, store free boundary faces";
16+
}
17+
18+
return $"{value.SpatialElementBoundaryLocation}";
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)