Skip to content

Commit

Permalink
add Document.ResolveDefaultElementTypeId support
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyNefyodov committed Sep 20, 2024
1 parent fc1520c commit 5420d74
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public Func<IVariants> Resolve(Document context, string target, ParameterInfo[]
{
nameof(Document.Close) when parameters.Length == 0 => Variants.Disabled,
nameof(Document.PlanTopologies) when parameters.Length == 0 => ResolvePlanTopologies,
nameof(Document.GetDefaultElementTypeId) => ResolveDefaultElementTypeId,
#if REVIT2024_OR_GREATER
nameof(Document.GetUnusedElements) => ResolveGetUnusedElements,
nameof(Document.GetAllUnusedElements) => ResolveGetAllUnusedElements,
Expand All @@ -63,6 +64,26 @@ IVariants ResolvePlanTopologies()

return Variants.Single(topologies);
}
IVariants ResolveDefaultElementTypeId()
{
var values = Enum.GetValues(typeof(ElementTypeGroup));
var variants = new Variants<ElementId>(values.Length);

foreach (ElementTypeGroup value in values)
{
var result = _document.GetDefaultElementTypeId(value);
if (result is not null && result != ElementId.InvalidElementId)
{
variants.Add(result, $"{value.ToString()}: {result.ToElement(_document)!.Name}");
}
else
{
variants.Add(result, $"{value.ToString()}: {result}");
}
}

return variants;
}
#if REVIT2024_OR_GREATER

IVariants ResolveGetUnusedElements()
Expand All @@ -76,7 +97,6 @@ IVariants ResolveGetAllUnusedElements()
}
#endif
}

public void RegisterExtensions(IExtensionManager manager)
{
manager.Register(nameof(GlobalParametersManager.GetAllGlobalParameters), GlobalParametersManager.GetAllGlobalParameters);
Expand Down

0 comments on commit 5420d74

Please sign in to comment.