From 6540e248dd82810a1f2ba4277614d38863da6c59 Mon Sep 17 00:00:00 2001 From: SergeyNefyodov Date: Fri, 3 May 2024 20:05:05 +0200 Subject: [PATCH] Add IndependentTag methods support --- .../Core/ComponentModel/DescriptorMap.cs | 2 - .../Descriptors/IndependentTagDescriptor.cs | 77 +++++++++++++++++++ 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/source/RevitLookup/Core/ComponentModel/DescriptorMap.cs b/source/RevitLookup/Core/ComponentModel/DescriptorMap.cs index f2894e4b..48398e09 100644 --- a/source/RevitLookup/Core/ComponentModel/DescriptorMap.cs +++ b/source/RevitLookup/Core/ComponentModel/DescriptorMap.cs @@ -91,9 +91,7 @@ public static Descriptor FindDescriptor(object obj, Type type) FamilyInstance value when type is null || type == typeof(FamilyInstance) => new FamilyInstanceDescriptor(value), Panel value when type == typeof(Panel) => new PanelDescriptor(value), SpatialElement value when type is null || type == typeof(SpatialElement) => new SpatialElementDescriptor(value), -#if REVIT2025_OR_GREATER IndependentTag value when type is null || type == typeof(IndependentTag) => new IndependentTagDescriptor(value), -#endif MEPSystem value when type is null || type == typeof(MEPSystem) => new MepSystemDescriptor(value), Element value when type is null || type == typeof(Element) => new ElementDescriptor(value), Document value when type is null || type == typeof(Document) => new DocumentDescriptor(value), diff --git a/source/RevitLookup/Core/ComponentModel/Descriptors/IndependentTagDescriptor.cs b/source/RevitLookup/Core/ComponentModel/Descriptors/IndependentTagDescriptor.cs index 1084541a..52fafc14 100644 --- a/source/RevitLookup/Core/ComponentModel/Descriptors/IndependentTagDescriptor.cs +++ b/source/RevitLookup/Core/ComponentModel/Descriptors/IndependentTagDescriptor.cs @@ -35,8 +35,85 @@ public sealed class IndependentTagDescriptor(IndependentTag tag) : ElementDescri { #if REVIT2025_OR_GREATER nameof(IndependentTag.TagText) when RebarBendingDetail.IsBendingDetail(tag) => ResolveSet.Append(new NotSupportedException("RebarBendingDetail not supported. Revit API critical Exception")), +#endif + nameof(IndependentTag.CanLeaderEndConditionBeAssigned) => ResolveLeaderEndCondition(), +#if REVIT2022_OR_GREATER + nameof(IndependentTag.GetLeaderElbow) => ResolveLeaderElbow(), + nameof(IndependentTag.GetLeaderEnd) => ResolveLeaderEnd(), + nameof(IndependentTag.HasLeaderElbow) => ResolveHasLeaderElbow(), + nameof(IndependentTag.IsLeaderVisible) => ResolveIsLeaderVisible(), #endif _ => null }; + + ResolveSet ResolveLeaderEndCondition() + { + var conditions = Enum.GetValues(typeof(LeaderEndCondition)); + var resolveSummary = new ResolveSet(conditions.Length); + + foreach (LeaderEndCondition condition in conditions) + { + resolveSummary.AppendVariant(tag.CanLeaderEndConditionBeAssigned(condition), condition.ToString()); + } + + return resolveSummary; + } +#if REVIT2022_OR_GREATER + ResolveSet ResolveLeaderElbow() + { + var references = tag.GetTaggedReferences(); + var resolveSummary = new ResolveSet(references.Count); + + foreach (var reference in references) + { + if (tag.IsLeaderVisible(reference) && tag.HasLeaderElbow(reference)) + resolveSummary.AppendVariant(tag.GetLeaderElbow(reference)); + } + + return resolveSummary; + } + + ResolveSet ResolveLeaderEnd() + { + if (tag.LeaderEndCondition == LeaderEndCondition.Attached) + return ResolveSet.Append("The tag has attached leader end condition, it has no LeaderEnd"); + var references = tag.GetTaggedReferences(); + var resolveSummary = new ResolveSet(references.Count); + + foreach (var reference in references) + { + if (tag.IsLeaderVisible(reference)) + resolveSummary.AppendVariant(tag.GetLeaderEnd(reference)); + } + + return resolveSummary; + } + + ResolveSet ResolveHasLeaderElbow() + { + var references = tag.GetTaggedReferences(); + var resolveSummary = new ResolveSet(references.Count); + foreach (var reference in references) + { + if (tag.IsLeaderVisible(reference)) + resolveSummary.AppendVariant(tag.HasLeaderElbow(reference)); + } + + return resolveSummary; + } + + ResolveSet ResolveIsLeaderVisible() + { + var references = tag.GetTaggedReferences(); + var resolveSummary = new ResolveSet(references.Count); + + foreach (var reference in references) + { + resolveSummary.AppendVariant(tag.IsLeaderVisible(reference)); + } + + return resolveSummary; + } +#endif } } \ No newline at end of file