Skip to content

Commit

Permalink
Merge pull request #268
Browse files Browse the repository at this point in the history
Dev macro manager
  • Loading branch information
Nice3point authored Jul 18, 2024
2 parents 07dd382 + 558a898 commit fe1ce3e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/RevitLookup/Core/ComponentModel/DescriptorMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Autodesk.Revit.DB.ExtensibleStorage;
using Autodesk.Revit.DB.ExternalService;
using Autodesk.Revit.DB.Lighting;
using Autodesk.Revit.DB.Macros;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Plumbing;
using Autodesk.Revit.DB.Visual;
Expand Down Expand Up @@ -58,6 +59,7 @@ public static Descriptor FindDescriptor(object obj, Type type)
//System
string value when type is null || type == typeof(string) => new StringDescriptor(value),
bool value when type is null || type == typeof(bool) => new BoolDescriptor(value),
MacroManager when type is null || type == typeof(MacroManager) => new MacroManagerDescriptor(),
IEnumerable value => new EnumerableDescriptor(value),
Exception value when type is null || type == typeof(Exception) => new ExceptionDescriptor(value),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.

using Autodesk.Revit.DB.Macros;

namespace RevitLookup.Core.ComponentModel.Descriptors;

public sealed class ApplicationDescriptor : Descriptor, IDescriptorExtension
{
private readonly Autodesk.Revit.ApplicationServices.Application _application;
public ApplicationDescriptor(Autodesk.Revit.ApplicationServices.Application application)
{
Name = application.VersionName;
_application = application;
}

public void RegisterExtensions(IExtensionManager manager)
{
manager.Register("GetFormulaFunctions", _ => FormulaManager.GetFunctions());
manager.Register("GetFormulaOperators", _ => FormulaManager.GetOperators());
manager.Register(nameof(MacroManager.GetMacroManager), _ => MacroManager.GetMacroManager(_application));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#if REVIT2023_OR_GREATER
using Autodesk.Revit.DB.Structure;
#endif
#if !REVIT2025_OR_GREATER
using Autodesk.Revit.DB.Macros;
#endif

namespace RevitLookup.Core.ComponentModel.Descriptors;

Expand Down Expand Up @@ -78,6 +81,9 @@ public void RegisterExtensions(IExtensionManager manager)
{
manager.Register(nameof(GlobalParametersManager.GetAllGlobalParameters), GlobalParametersManager.GetAllGlobalParameters);
manager.Register(nameof(LightGroupManager.GetLightGroupManager), LightGroupManager.GetLightGroupManager);
#if !REVIT2025_OR_GREATER
manager.Register(nameof(MacroManager.GetMacroManager), MacroManager.GetMacroManager);
#endif
#if REVIT2022_OR_GREATER
manager.Register(nameof(TemporaryGraphicsManager.GetTemporaryGraphicsManager), TemporaryGraphicsManager.GetTemporaryGraphicsManager);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Collections;
using System.Reflection;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Revit.DB.Macros;

namespace RevitLookup.Core.ComponentModel.Descriptors;

Expand Down Expand Up @@ -57,6 +58,7 @@ public EnumerableDescriptor(IEnumerable value)
VoltageTypeSet enumerable => enumerable.IsEmpty,
InsulationTypeSet enumerable => enumerable.IsEmpty,
TemperatureRatingTypeSet enumerable => enumerable.IsEmpty,
MacroManager enumerable => enumerable.Count == 0,
_ => !Enumerator.MoveNext()
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// 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.Macros;

namespace RevitLookup.Core.ComponentModel.Descriptors;

public class MacroManagerDescriptor: Descriptor, IDescriptorResolver
{
public Func<IVariants> Resolve(Document context, string target, ParameterInfo[] parameters)
{
return target switch
{
#if !REVIT2025_OR_GREATER
nameof(MacroManager.GetDocumentMacroSecurityOptions) => ResolveDocumentMacroSecurityOptions,
#endif
nameof(MacroManager.GetApplicationMacroSecurityOptions) => ResolveApplicationMacroSecurityOptions,
_ => null
};

IVariants ResolveApplicationMacroSecurityOptions()
{
return Variants.Single(MacroManager.GetApplicationMacroSecurityOptions(Context.Application));
}
#if !REVIT2025_OR_GREATER
IVariants ResolveDocumentMacroSecurityOptions()
{
return Variants.Single(MacroManager.GetDocumentMacroSecurityOptions(Context.Application));
}
#endif
}
}
1 change: 1 addition & 0 deletions source/RevitLookup/RevitLookup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<PackageReference Include="Nice3point.Revit.Api.RevitAPI" Version="$(RevitVersion).*"/>
<PackageReference Include="Nice3point.Revit.Api.AdWindows" Version="$(RevitVersion).*"/>
<PackageReference Include="Nice3point.Revit.Api.RevitAPIUI" Version="$(RevitVersion).*"/>
<PackageReference Include="Nice3point.Revit.Api.RevitAPIMacros" Version="$(RevitVersion).*"/>
<PackageReference Include="Nice3point.Revit.Api.UIFramework" Version="$(RevitVersion).*"/>
<PackageReference Include="Nice3point.Revit.Api.UIFrameworkServices" Version="$(RevitVersion).*"/>

Expand Down

0 comments on commit fe1ce3e

Please sign in to comment.