Skip to content

Commit

Permalink
Merge pull request #307 from SergeyNefyodov/dev-wall
Browse files Browse the repository at this point in the history
Add wall support
  • Loading branch information
Nice3point authored Feb 22, 2025
2 parents bc29892 + 8e21326 commit 54a783e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2003-2025 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 LookupEngine.Abstractions.Configuration;
using LookupEngine.Abstractions.Decomposition;

namespace RevitLookup.Core.Decomposition.Descriptors;

public class WallDescriptor(Wall wall) : ElementDescriptor(wall)
{
public override Func<IVariant>? Resolve(string target, ParameterInfo[] parameters)
{
return target switch
{
#if REVIT2022_OR_GREATER
nameof(Wall.IsWallCrossSectionValid) => ResolveIsWallCrossSectionValid,
#endif
_ => null
};
#if REVIT2022_OR_GREATER
IVariant ResolveIsWallCrossSectionValid()
{
var values = Enum.GetValues(typeof(WallCrossSection));
var variants = Variants.Values<bool>(values.Length);

foreach (WallCrossSection crossSection in values)
{
var result = wall.IsWallCrossSectionValid(crossSection);
variants.Add(result, $"{crossSection}: {result}");
}

return variants.Consume();
}
#endif
}

public override void RegisterExtensions(IExtensionManager manager)
{
manager.Register(nameof(WallUtils.IsWallJoinAllowedAtEnd), ResolveIsWallJoinAllowedAtEnd);
}

private IVariant ResolveIsWallJoinAllowedAtEnd()
{
var variants = Variants.Values<bool>(2);
var startResult = WallUtils.IsWallJoinAllowedAtEnd(wall, 0);
var endResult = WallUtils.IsWallJoinAllowedAtEnd(wall, 1);
variants.Add(startResult, $"Start: {startResult}");
variants.Add(endResult, $"End: {endResult}");

return variants.Consume();
}
}
1 change: 1 addition & 0 deletions source/RevitLookup/Core/Decomposition/DescriptorsMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public static Descriptor FindDescriptor(object? obj, Type? type)
View value when type is null || type == typeof(View) => new ViewDescriptor(value),
Wire value when type is null || type == typeof(Wire) => new WireDescriptor(value),
Pipe value when type is null || type == typeof(Pipe) => new PipeDescriptor(value),
Wall value when type is null || type == typeof(Wall) => new WallDescriptor(value),
HostObject value when type is null || type == typeof(HostObject) => new HostObjectDescriptor(value),
ElevationMarker value when type is null || type == typeof(ElevationMarker) => new ElevationMarkerDescriptor(value),
RevitLinkType value when type is null || type == typeof(RevitLinkType) => new RevitLinkTypeDescriptor(value),
Expand Down

0 comments on commit 54a783e

Please sign in to comment.