Skip to content

Commit

Permalink
MEPSection IsMain support
Browse files Browse the repository at this point in the history
  • Loading branch information
Nice3point committed Nov 23, 2023
1 parent c3d879e commit fca1e76
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 21 deletions.
58 changes: 38 additions & 20 deletions RevitLookup/Core/ComponentModel/Descriptors/MepSectionDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@

namespace RevitLookup.Core.ComponentModel.Descriptors;

public class MepSectionDescriptor : Descriptor, IDescriptorResolver
public sealed class MepSectionDescriptor(MEPSection mepSection) : Descriptor, IDescriptorResolver
{
private MEPSection _mepSection;
public MepSectionDescriptor(MEPSection mepSection)
{
_mepSection = mepSection;
}
public ResolveSet Resolve(Document context, string target, ParameterInfo[] parameters)
{
return target switch
Expand All @@ -42,61 +37,84 @@ public ResolveSet Resolve(Document context, string target, ParameterInfo[] param
nameof(MEPSection.GetCoefficient) => ResolveCoefficient(),
nameof(MEPSection.GetPressureDrop) => ResolvePressureDrop(),
nameof(MEPSection.GetSegmentLength) => ResolveSegmentLength(),
nameof(MEPSection.IsMain) => ResolveIsMain(),
_ => null
};

ResolveSet ResolveSectionIds()
{
var elementIds = _mepSection.GetElementIds();
var elementIds = mepSection.GetElementIds();
var resolveSummary = new ResolveSet(elementIds.Count);
foreach (var id in elementIds)
{
resolveSummary.AppendVariant(id);
}

return resolveSummary;
}

ResolveSet ResolveCoefficient()
{
var elementIds = _mepSection.GetElementIds();
var elementIds = mepSection.GetElementIds();
var resolveSummary = new ResolveSet(elementIds.Count);
foreach (var id in elementIds)
{
resolveSummary.AppendVariant(_mepSection.GetCoefficient(id), $"{id}");
resolveSummary.AppendVariant(mepSection.GetCoefficient(id), $"ID{id}");
}

return resolveSummary;
}

ResolveSet ResolvePressureDrop()
{
var elementIds = _mepSection.GetElementIds();
var elementIds = mepSection.GetElementIds();
var resolveSummary = new ResolveSet(elementIds.Count);
foreach (var id in elementIds)
{
resolveSummary.AppendVariant(_mepSection.GetPressureDrop(id), $"{id}");
resolveSummary.AppendVariant(mepSection.GetPressureDrop(id), $"ID{id}");
}

return resolveSummary;
}

ResolveSet ResolveSegmentLength()
{
var elementIds = _mepSection.GetElementIds();
var elementIds = mepSection.GetElementIds();
var resolveSummary = new ResolveSet(elementIds.Count);
foreach (var id in elementIds)
{
var length = 0.0d;
try
{
length = _mepSection.GetSegmentLength(id);
var length = mepSection.GetSegmentLength(id);
resolveSummary.AppendVariant(length, $"ID{id}");
}
catch (ArgumentException)
{
// ignored
}
if (length != 0.0d) resolveSummary.AppendVariant(length, $"{id}");
}

return resolveSummary;
}
}


ResolveSet ResolveIsMain()
{
var elementIds = mepSection.GetElementIds();
var resolveSummary = new ResolveSet(elementIds.Count);
foreach (var id in elementIds)
{
try
{
var isMain = mepSection.IsMain(id);
resolveSummary.AppendVariant(isMain, $"ID{id}");
}
catch (ArgumentException)
{
// ignored
}
}

return resolveSummary;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace RevitLookup.Core.ComponentModel.Descriptors;

public class MepSystemDescriptor(MEPSystem mepSystem) : ElementDescriptor(mepSystem), IDescriptorResolver
public sealed class MepSystemDescriptor(MEPSystem mepSystem) : ElementDescriptor(mepSystem), IDescriptorResolver
{
public new ResolveSet Resolve(Document context, string target, ParameterInfo[] parameters)
{
Expand Down

0 comments on commit fca1e76

Please sign in to comment.