Skip to content

Commit

Permalink
Support of MEPSection methods of MEPSystem added
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyNefyodov committed Nov 20, 2023
1 parent 135a9a2 commit d3a2a83
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions RevitLookup/Core/ComponentModel/DescriptorMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public static Descriptor FindDescriptor(object obj, Type type)
WorksetTable when type is null || type == typeof(WorksetTable) => new WorksetTableDescriptor(),
BoundarySegment value when type is null || type == typeof(BoundarySegment) => new BoundarySegmentDescriptor(value),
SpatialElement value when type is null || type == typeof(SpatialElement) => new SpatialElementDescriptor(value),
MEPSystem value when type is null || type == typeof(MEPSystem) => new MepSystemDescriptor(value),
#if R24_OR_GREATER
EvaluatedParameter value when type is null || type == typeof(EvaluatedParameter) => new EvaluatedParameterDescriptor(value),
#endif
Expand Down
52 changes: 52 additions & 0 deletions RevitLookup/Core/ComponentModel/Descriptors/MepSystemDescriptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2003-$File.CreatedYear by Autodesk, Inc.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted,
// provided that the above copyright notice appears in all copies and
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.

using System.Reflection;
using Autodesk.Revit.DB;
using RevitLookup.Core.Contracts;
using RevitLookup.Core.Objects;

namespace RevitLookup.Core.ComponentModel.Descriptors;

public class MepSystemDescriptor(MEPSystem mepSystem) : ElementDescriptor(mepSystem), IDescriptorResolver
{
public new ResolveSet Resolve(Document context, string target, ParameterInfo[] parameters)
{
return target switch
{
nameof(MEPSystem.GetSectionByIndex) => ResolveMepSections(),
nameof(MEPSystem.GetSectionByNumber) => ResolveMepSections(),
_ => null
};

ResolveSet ResolveMepSections()
{
var capacity = mepSystem.SectionsCount;
var resolveSummary = new ResolveSet(capacity);
for (var i = 0; i < capacity; i++)
{
var section = mepSystem.GetSectionByIndex(i);
resolveSummary.AppendVariant(section, $"Index: {i}, number: {section.Number}");
}

return resolveSummary;
}
}
}

0 comments on commit d3a2a83

Please sign in to comment.