Skip to content

Commit

Permalink
Merge pull request #238 from SergeyNefyodov/dev-phases-support
Browse files Browse the repository at this point in the history
Add phases support for Element, fix FamilyInstance phases bug
  • Loading branch information
Nice3point authored May 16, 2024
2 parents 1462626 + 31cb4d1 commit b82ebef
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public virtual Func<IVariants> Resolve(Document context, string target, Paramete
nameof(Element.GetMaterialArea) => ResolveGetMaterialArea,
nameof(Element.GetMaterialVolume) => ResolveGetMaterialVolume,
nameof(Element.GetEntity) => ResolveGetEntity,
nameof(Element.GetPhaseStatus) => ResolvePhaseStatus,
nameof(Element.IsPhaseCreatedValid) => ResolveIsPhaseCreatedValid,
nameof(Element.IsPhaseDemolishedValid) => ResolveIsPhaseDemolishedValid,
#if REVIT2022_OR_GREATER
nameof(Element.IsDemolishedPhaseOrderValid) => ResolveIsDemolishedPhaseOrderValid,
nameof(Element.IsCreatedPhaseOrderValid) => ResolveIsCreatedPhaseOrderValid,
#endif
"BoundingBox" => ResolveBoundingBox,
"Geometry" => ResolveGeometry,
_ => null
Expand Down Expand Up @@ -201,6 +208,74 @@ IVariants ResolveGetDependentElements()
{
return Variants.Single(_element.GetDependentElements(null));
}

IVariants ResolvePhaseStatus()
{
var phases = context.Phases;
var variants = new Variants<ElementOnPhaseStatus>(phases.Size);
foreach (Phase phase in phases)
{
var result = _element.GetPhaseStatus(phase.Id);
variants.Add(result, $"{phase.Name}: {result}");
}

return variants;
}

IVariants ResolveIsPhaseCreatedValid()
{
var phases = context.Phases;
var variants = new Variants<bool>(phases.Size);
foreach (Phase phase in phases)
{
var result = _element.IsPhaseCreatedValid(phase.Id);
variants.Add(result, $"{phase.Name}: {result}");
}

return variants;
}

IVariants ResolveIsPhaseDemolishedValid()
{
var phases = context.Phases;
var variants = new Variants<bool>(phases.Size);
foreach (Phase phase in phases)
{
var result = _element.IsPhaseDemolishedValid(phase.Id);
variants.Add(result, $"{phase.Name}: {result}");
}

return variants;
}

#if REVIT2022_OR_GREATER
IVariants ResolveIsCreatedPhaseOrderValid()
{
var phases = context.Phases;
var variants = new Variants<bool>(phases.Size);
foreach (Phase phase in phases)
{
var result = _element.IsCreatedPhaseOrderValid(phase.Id);
variants.Add(result, $"{phase.Name}: {result}");
}

return variants;
}

IVariants ResolveIsDemolishedPhaseOrderValid()
{
var phases = context.Phases;
var variants = new Variants<bool>(phases.Size);
foreach (Phase phase in phases)
{
var result = _element.IsDemolishedPhaseOrderValid(phase.Id);
variants.Add(result, $"{phase.Name}: {result}");
}

return variants;
}

#endif
}

public virtual void RegisterExtensions(IExtensionManager manager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ IVariants ResolveGetRoom()
var variants = new Variants<Room>(familyInstance.Document.Phases.Size);
foreach (Phase phase in familyInstance.Document.Phases)
{
if (familyInstance.GetPhaseStatus(phase.Id) == ElementOnPhaseStatus.Future) continue;
variants.Add(familyInstance.get_Room(phase), phase.Name);
}

Expand All @@ -55,6 +56,7 @@ IVariants ResolveFromRoom()
var variants = new Variants<Room>(familyInstance.Document.Phases.Size);
foreach (Phase phase in familyInstance.Document.Phases)
{
if (familyInstance.GetPhaseStatus(phase.Id) == ElementOnPhaseStatus.Future) continue;
variants.Add(familyInstance.get_FromRoom(phase), phase.Name);
}

Expand All @@ -66,6 +68,7 @@ IVariants ResolveToRoom()
var variants = new Variants<Room>(familyInstance.Document.Phases.Size);
foreach (Phase phase in familyInstance.Document.Phases)
{
if (familyInstance.GetPhaseStatus(phase.Id) == ElementOnPhaseStatus.Future) continue;
variants.Add(familyInstance.get_ToRoom(phase), phase.Name);
}

Expand Down

0 comments on commit b82ebef

Please sign in to comment.