-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cherry pick jeremytammik/RevitLookup#187 - GetBoundarySegments method…
… of spatial elements support added
- Loading branch information
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...rer/Domain/DataModel/MemberAccessors/SpatialElement/SpatialElement_GetBoundarySegments.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using Autodesk.Revit.DB; | ||
|
||
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md | ||
|
||
namespace RevitDBExplorer.Domain.DataModel.MemberAccessors | ||
{ | ||
internal class SpatialElement_GetBoundarySegments : MemberAccessorByType<SpatialElement>, ICanCreateMemberAccessor | ||
{ | ||
public IEnumerable<LambdaExpression> GetHandledMembers() { yield return (SpatialElement x) => x.GetBoundarySegments(null); } | ||
|
||
|
||
protected override bool CanBeSnoooped(Document document, SpatialElement value) => true; | ||
|
||
protected override string GetLabel(Document document, SpatialElement value) | ||
{ | ||
return "[[BoundarySegment]]"; | ||
} | ||
|
||
protected override IEnumerable<SnoopableObject> Snooop(Document document, SpatialElement element) | ||
{ | ||
var options = new[] | ||
{ | ||
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center, StoreFreeBoundaryFaces = true }, | ||
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreBoundary, StoreFreeBoundaryFaces = true }, | ||
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish, StoreFreeBoundaryFaces = true }, | ||
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreCenter, StoreFreeBoundaryFaces = true }, | ||
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center, StoreFreeBoundaryFaces = false }, | ||
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreBoundary, StoreFreeBoundaryFaces = false }, | ||
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish, StoreFreeBoundaryFaces = false }, | ||
new SpatialElementBoundaryOptions() { SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.CoreCenter, StoreFreeBoundaryFaces = false }, | ||
}; | ||
|
||
foreach (var option in options) | ||
{ | ||
yield return SnoopableObject.CreateKeyValuePair(document, option, element.GetBoundarySegments(option), "options"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
sources/RevitDBExplorer/Domain/DataModel/ValueContainers/BoundarySegmentHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Autodesk.Revit.DB; | ||
using RevitDBExplorer.Domain.DataModel.ValueContainers.Base; | ||
|
||
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md | ||
|
||
namespace RevitDBExplorer.Domain.DataModel.ValueContainers | ||
{ | ||
internal class BoundarySegmentHandler : TypeHandler<BoundarySegment> | ||
{ | ||
protected override bool CanBeSnoooped(SnoopableContext context, BoundarySegment boundarySegment) => boundarySegment is not null; | ||
|
||
protected override string ToLabel(SnoopableContext context, BoundarySegment boundarySegment) | ||
{ | ||
return $"ID: {boundarySegment.ElementId}, {boundarySegment.GetCurve()?.Length} ft"; ; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
.../RevitDBExplorer/Domain/DataModel/ValueContainers/SpatialElementBoundaryOptionsHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Autodesk.Revit.DB; | ||
using RevitDBExplorer.Domain.DataModel.ValueContainers.Base; | ||
|
||
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md | ||
|
||
namespace RevitDBExplorer.Domain.DataModel.ValueContainers | ||
{ | ||
internal class SpatialElementBoundaryOptionsHandler : TypeHandler<SpatialElementBoundaryOptions> | ||
{ | ||
protected override bool CanBeSnoooped(SnoopableContext context, SpatialElementBoundaryOptions value) => true; | ||
protected override string ToLabel(SnoopableContext context, SpatialElementBoundaryOptions value) | ||
{ | ||
if (value.StoreFreeBoundaryFaces == true) | ||
{ | ||
return $"{value.SpatialElementBoundaryLocation}, store free boundary faces"; | ||
} | ||
|
||
return $"{value.SpatialElementBoundaryLocation}"; | ||
} | ||
} | ||
} |