Skip to content

Commit

Permalink
Add IndependentTag methods support
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyNefyodov committed May 3, 2024
1 parent 9a00fdb commit 6540e24
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
2 changes: 0 additions & 2 deletions source/RevitLookup/Core/ComponentModel/DescriptorMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 6540e24

Please sign in to comment.