From 0874b48001621c1112633ba656db86f32b37add7 Mon Sep 17 00:00:00 2001 From: SergeyNefyodov Date: Mon, 2 Sep 2024 22:12:11 +0200 Subject: [PATCH] Add structural settings support --- .../Core/ComponentModel/DescriptorMap.cs | 2 + .../StructuralSettingsDescriptor.cs | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 source/RevitLookup/Core/ComponentModel/Descriptors/StructuralSettingsDescriptor.cs diff --git a/source/RevitLookup/Core/ComponentModel/DescriptorMap.cs b/source/RevitLookup/Core/ComponentModel/DescriptorMap.cs index ecc531cb..f1b2f52f 100644 --- a/source/RevitLookup/Core/ComponentModel/DescriptorMap.cs +++ b/source/RevitLookup/Core/ComponentModel/DescriptorMap.cs @@ -29,6 +29,7 @@ using Autodesk.Revit.DB.Macros; using Autodesk.Revit.DB.Mechanical; using Autodesk.Revit.DB.Plumbing; +using Autodesk.Revit.DB.Structure; using Autodesk.Revit.DB.Visual; using Autodesk.Revit.UI; using Autodesk.Windows; @@ -113,6 +114,7 @@ public static Descriptor FindDescriptor(object obj, Type type) MEPSystem value when type is null || type == typeof(MEPSystem) => new MepSystemDescriptor(value), BasePoint value when type is null || type == typeof(BasePoint) => new BasePointDescriptor(value), InternalOrigin value when type is null || type == typeof(InternalOrigin) => new InternalOriginDescriptor(value), + StructuralSettings value when type is null || type == typeof(StructuralSettings) => new StructuralSettingsDescriptor(value), CurveElement value when type is null || type == typeof(CurveElement) => new CurveElementDescriptor(value), DatumPlane value when type is null || type == typeof(DatumPlane) => new DatumPlaneDescriptor(value), Part value when type is null || type == typeof(Part) => new PartDescriptor(value), diff --git a/source/RevitLookup/Core/ComponentModel/Descriptors/StructuralSettingsDescriptor.cs b/source/RevitLookup/Core/ComponentModel/Descriptors/StructuralSettingsDescriptor.cs new file mode 100644 index 00000000..c39bdd77 --- /dev/null +++ b/source/RevitLookup/Core/ComponentModel/Descriptors/StructuralSettingsDescriptor.cs @@ -0,0 +1,45 @@ +// Copyright 2003-2024 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 Autodesk.Revit.DB.Structure; + +namespace RevitLookup.Core.ComponentModel.Descriptors; + +public class StructuralSettingsDescriptor(StructuralSettings structuralSettings) : ElementDescriptor(structuralSettings) +{ + public override Func Resolve(Document context, string target, ParameterInfo[] parameters) + { + return target switch + { + nameof(StructuralSettings.GetStructuralSettings) => ResolveGet, + _ => null + }; + + IVariants ResolveGet() + { + return Variants.Single(StructuralSettings.GetStructuralSettings(structuralSettings.Document)); + } + } + + public override void RegisterExtensions(IExtensionManager manager) + { + } +} \ No newline at end of file