Skip to content

Commit a91d10f

Browse files
committed
cherry pick lookup-foundation/RevitLookup#192 - Mep section methods support added
1 parent 4a9ff14 commit a91d10f

File tree

4 files changed

+128
-0
lines changed

4 files changed

+128
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections.Generic;
2+
using System.Linq.Expressions;
3+
using Autodesk.Revit.DB;
4+
using Autodesk.Revit.DB.Mechanical;
5+
6+
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
7+
8+
namespace RevitDBExplorer.Domain.DataModel.MemberAccessors
9+
{
10+
internal class MepSection_GetCoefficient : MemberAccessorByType<MEPSection>, ICanCreateMemberAccessor
11+
{
12+
public IEnumerable<LambdaExpression> GetHandledMembers() { yield return (MEPSection x) => x.GetCoefficient(null); }
13+
14+
15+
protected override bool CanBeSnoooped(Document document, MEPSection value) => value.GetElementIds().Count > 0;
16+
17+
protected override string GetLabel(Document document, MEPSection value)
18+
{
19+
return Labeler.GetLabelForCollection("double", value.GetElementIds().Count);
20+
}
21+
22+
protected override IEnumerable<SnoopableObject> Snooop(Document document, MEPSection value)
23+
{
24+
foreach (var id in value.GetElementIds())
25+
{
26+
yield return SnoopableObject.CreateKeyValuePair(document, id, value.GetCoefficient(id));
27+
}
28+
}
29+
}
30+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Collections.Generic;
2+
using System.Linq.Expressions;
3+
using Autodesk.Revit.DB;
4+
using Autodesk.Revit.DB.Mechanical;
5+
6+
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
7+
8+
namespace RevitDBExplorer.Domain.DataModel.MemberAccessors.MepSection
9+
{
10+
11+
internal class MepSection_GetPressureDrop : MemberAccessorByType<MEPSection>, ICanCreateMemberAccessor
12+
{
13+
public IEnumerable<LambdaExpression> GetHandledMembers() { yield return (MEPSection x) => x.GetPressureDrop(null); }
14+
15+
16+
protected override bool CanBeSnoooped(Document document, MEPSection value) => value.GetElementIds().Count > 0;
17+
18+
protected override string GetLabel(Document document, MEPSection value)
19+
{
20+
return Labeler.GetLabelForCollection("double", value.GetElementIds().Count);
21+
}
22+
23+
protected override IEnumerable<SnoopableObject> Snooop(Document document, MEPSection value)
24+
{
25+
foreach (var id in value.GetElementIds())
26+
{
27+
yield return SnoopableObject.CreateKeyValuePair(document, id, value.GetPressureDrop(id));
28+
}
29+
}
30+
}
31+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Collections.Generic;
2+
using System.Linq.Expressions;
3+
using Autodesk.Revit.DB;
4+
using Autodesk.Revit.DB.Mechanical;
5+
6+
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
7+
8+
namespace RevitDBExplorer.Domain.DataModel.MemberAccessors.MepSection
9+
{
10+
11+
internal class MepSection_GetSegmentLength : MemberAccessorByType<MEPSection>, ICanCreateMemberAccessor
12+
{
13+
public IEnumerable<LambdaExpression> GetHandledMembers() { yield return (MEPSection x) => x.GetSegmentLength(null); }
14+
15+
16+
protected override bool CanBeSnoooped(Document document, MEPSection value) => value.GetElementIds().Count > 0;
17+
18+
protected override string GetLabel(Document document, MEPSection value)
19+
{
20+
return Labeler.GetLabelForCollection("double", null);
21+
}
22+
23+
protected override IEnumerable<SnoopableObject> Snooop(Document document, MEPSection value)
24+
{
25+
foreach (var id in value.GetElementIds())
26+
{
27+
var element = document.GetElement(id);
28+
if (element is FamilyInstance) continue;
29+
yield return SnoopableObject.CreateKeyValuePair(document, id, value.GetSegmentLength(id));
30+
}
31+
}
32+
}
33+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Collections.Generic;
2+
using System.Linq.Expressions;
3+
using Autodesk.Revit.DB;
4+
using Autodesk.Revit.DB.Mechanical;
5+
using Autodesk.Revit.DB.Plumbing;
6+
7+
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
8+
9+
namespace RevitDBExplorer.Domain.DataModel.MemberAccessors.MepSection
10+
{
11+
12+
internal class MepSection_IsMain : MemberAccessorByType<MEPSection>, ICanCreateMemberAccessor
13+
{
14+
public IEnumerable<LambdaExpression> GetHandledMembers() { yield return (MEPSection x) => x.IsMain(null); }
15+
16+
17+
protected override bool CanBeSnoooped(Document document, MEPSection value) => value.GetElementIds().Count > 0;
18+
19+
protected override string GetLabel(Document document, MEPSection value)
20+
{
21+
return Labeler.GetLabelForCollection("bool", null);
22+
}
23+
24+
protected override IEnumerable<SnoopableObject> Snooop(Document document, MEPSection value)
25+
{
26+
foreach (var id in value.GetElementIds())
27+
{
28+
var element = document.GetElement(id);
29+
if (element is not FamilyInstance) continue;
30+
yield return SnoopableObject.CreateKeyValuePair(document, id, value.IsMain(id));
31+
}
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)