-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc70758
commit 8f181f0
Showing
106 changed files
with
2,002 additions
and
1,375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Bindings/RevitBaseBinding.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/DependencyInjection/ProxyMap.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Collections.Concurrent; | ||
using System.Diagnostics.CodeAnalysis; | ||
using Speckle.Converters.Common; | ||
using Speckle.Revit.Api; | ||
using Speckle.Revit.Interfaces; | ||
|
||
namespace Speckle.Connectors.Revit2023.Converters; | ||
|
||
[SuppressMessage("Performance", "CA1810:Initialize reference type static fields inline")] | ||
public class ProxyMap : IProxyMap | ||
{ | ||
private static readonly ConcurrentDictionary<Type, Type> s_typeMaps = new(); | ||
private static readonly ConcurrentDictionary<Type, Func<object, object>> s_proxyFactory = new(); | ||
|
||
static ProxyMap() | ||
{ | ||
Add<DB.Element, IRevitElement>(x => new ElementProxy(x)); | ||
Add<DB.FamilyInstance, IRevitFamilyInstance>(x => new FamilyInstanceProxy(x)); | ||
} | ||
|
||
private static void Add<T, TProxy>(Func<T, TProxy> f) | ||
where T : class | ||
where TProxy : notnull | ||
{ | ||
s_typeMaps.TryAdd(typeof(T), typeof(TProxy)); | ||
s_proxyFactory.TryAdd(typeof(TProxy), w => f((T)w)); | ||
} | ||
|
||
public Type? GetMappedType(Type type) | ||
{ | ||
if (s_typeMaps.TryGetValue(type, out var t)) | ||
{ | ||
return t; | ||
} | ||
return null; | ||
} | ||
|
||
public object CreateProxy(Type type, object toWrap) => s_proxyFactory[type](toWrap); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/GlobalUsings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using DB = Autodesk.Revit.DB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
DUI3-DX/Connectors/Revit/Speckle.Connectors.RevitShared/Plugin/RevitIdleManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...rters.RevitShared/Helpers/RevitContext.cs → ...t2023.DependencyInjection/RevitContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ers/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConversionContextStack.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Autodesk.Revit.DB; | ||
using Speckle.Converters.Common; | ||
using Speckle.Revit.Api; | ||
using Speckle.Revit.Interfaces; | ||
|
||
namespace Speckle.Converters.Revit2023.DependencyInjection; | ||
|
||
[System.Diagnostics.CodeAnalysis.SuppressMessage( | ||
"Naming", | ||
"CA1711:Identifiers should not have incorrect suffix", | ||
Justification = "See base class justification" | ||
)] | ||
// POC: so this should *probably* be Document and NOT UI.UIDocument, the former is Conversion centric | ||
// and the latter is more for connector | ||
public class RevitConversionContextStack | ||
: ConversionContextStack<IRevitDocument, IRevitForgeTypeId>, | ||
IConversionContextStack<IRevitDocument, IRevitForgeTypeId> | ||
{ | ||
public RevitConversionContextStack(RevitContext context, IHostToSpeckleUnitConverter<IRevitForgeTypeId> unitConverter) | ||
: base( | ||
// POC: we probably should not get here without a valid document | ||
// so should this perpetuate or do we assume this is valid? | ||
// relting on the context.UIApplication?.ActiveUIDocument is not right | ||
// this should be some IActiveDocument I suspect? | ||
new DocumentProxy( | ||
context.UIApplication?.ActiveUIDocument?.Document | ||
?? throw new SpeckleConversionException("Active UI document could not be determined") | ||
), | ||
new ForgeTypeIdProxy( | ||
context.UIApplication.ActiveUIDocument.Document.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId() | ||
), | ||
unitConverter | ||
) { } | ||
|
||
IConversionContext<IRevitDocument> IConversionContextStack<IRevitDocument, IRevitForgeTypeId>.Current => | ||
new ConversionContext<IRevitDocument>(base.Current.Document, base.Current.SpeckleUnits); | ||
|
||
ContextWrapper<IRevitDocument, IRevitForgeTypeId> IConversionContextStack<IRevitDocument, IRevitForgeTypeId>.Push( | ||
string speckleUnit | ||
) => throw new NotImplementedException(); | ||
} |
26 changes: 14 additions & 12 deletions
26
...Converters/Revit/Speckle.Converters.Revit2023.DependencyInjection/RevitConverterModule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,40 @@ | ||
using Autodesk.Revit.DB; | ||
using Speckle.Autofac.DependencyInjection; | ||
using Speckle.Converters.Common; | ||
using Speckle.Converters.Common.DependencyInjection; | ||
using Speckle.Converters.RevitShared; | ||
using Speckle.Converters.Revit2023.ToSpeckle; | ||
using Speckle.Converters.RevitShared.Helpers; | ||
using Speckle.Converters.RevitShared.Services; | ||
using Speckle.Converters.RevitShared.ToSpeckle; | ||
using Speckle.Revit.Api; | ||
using Speckle.Revit.Interfaces; | ||
|
||
namespace Speckle.Converters.Revit2023.DependencyInjection; | ||
|
||
public class RevitConverterModule : ISpeckleModule | ||
{ | ||
public void Load(SpeckleContainerBuilder builder) | ||
{ | ||
builder.AddConverterCommon<RootToSpeckleConverter, RevitToSpeckleUnitConverter, ForgeTypeId>(); | ||
builder.AddConverterCommon<RootToSpeckleConverter, RevitToSpeckleUnitConverter, IRevitForgeTypeId>(); | ||
builder.AddSingleton(new RevitContext()); | ||
|
||
// POC: do we need ToSpeckleScalingService as is, do we need to interface it out? | ||
builder.AddScoped<ScalingServiceToSpeckle>(); | ||
builder.AddScoped<IScalingServiceToSpeckle, ScalingServiceToSpeckle>(); | ||
|
||
// POC: the concrete type can come out if we remove all the reference to it | ||
builder.AddScoped<IRevitConversionContextStack, RevitConversionContextStack>(); | ||
builder.AddScoped<IConversionContextStack<IRevitDocument, IRevitForgeTypeId>, RevitConversionContextStack>(); | ||
|
||
builder.AddScoped<IReferencePointConverter, ReferencePointConverter>(); | ||
builder.AddScoped<RevitConversionSettings>(); | ||
builder.AddScoped<IRevitConversionSettings, RevitConversionSettings>(); | ||
|
||
builder.AddScoped<IRevitVersionConversionHelper, RevitVersionConversionHelper>(); | ||
|
||
builder.AddScoped<ParameterValueExtractor>(); | ||
builder.AddScoped<DisplayValueExtractor>(); | ||
builder.AddScoped<HostedElementConversionToSpeckle>(); | ||
builder.AddScoped<ParameterObjectAssigner>(); | ||
builder.AddScoped<IParameterValueExtractor, ParameterValueExtractor>(); | ||
builder.AddScoped<IDisplayValueExtractor, DisplayValueExtractor>(); | ||
builder.AddScoped<IHostedElementConversionToSpeckle, HostedElementConversionToSpeckle>(); | ||
builder.AddScoped<IParameterObjectAssigner, ParameterObjectAssigner>(); | ||
builder.AddScoped<ISlopeArrowExtractor, SlopeArrowExtractor>(); | ||
builder.AddScoped<SendSelection>(); | ||
builder.AddScoped<ToSpeckleConvertedObjectsCache>(); | ||
//builder.AddScoped<ToSpeckleConvertedObjectsCache>(); | ||
|
||
builder.ScanAssemblyOfType<RevitUnitUtils>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.