Skip to content

Commit

Permalink
ETABSShared
Browse files Browse the repository at this point in the history
- Implemented ETABSShared projects for Connectors and Converters to account for ETABS specific things that SAP 2000 doesn't account for  such as levels or frames being further classified as Column, Beam or Brace or shells as wall or floor
  • Loading branch information
bjoernsteinhagen committed Dec 3, 2024
1 parent 792bd93 commit b042bee
Show file tree
Hide file tree
Showing 32 changed files with 399 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void Main(ref cSapModel sapModel, ref cPluginCallback pluginCallback)

public virtual int Info(ref string text)
{
text = "Hey Speckler! This is our next-gen ETABS Connector.";
text = "Hey Speckler! This is our next-gen CSi Connector.";
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows.Forms.Integration;
using System.ComponentModel;
using System.Windows.Forms.Integration;
using Microsoft.Extensions.DependencyInjection;
using Speckle.Connectors.Common;
using Speckle.Connectors.CSiShared.HostApp;
Expand All @@ -8,6 +9,7 @@

namespace Speckle.Connectors.CSiShared;

[DesignerCategory("")]
public abstract class SpeckleFormBase : Form
{
protected ElementHost Host { get; set; }
Expand All @@ -20,9 +22,7 @@ protected SpeckleFormBase()
Text = "Speckle (Beta)";

var services = new ServiceCollection();
services.Initialize(HostApplications.ETABS, GetVersion());
services.AddCSi();
services.AddCSiConverters();
ConfigureServices(services);

Container = services.BuildServiceProvider();

Expand All @@ -32,6 +32,17 @@ protected SpeckleFormBase()
FormClosing += Form1Closing;
}

protected virtual void ConfigureServices(IServiceCollection services)
{
services.Initialize(GetHostApplication(), GetVersion());
services.AddCSi();
services.AddCSiConverters();
}

protected abstract HostApplication GetHostApplication();

protected abstract HostAppVersion GetVersion();

public void SetSapModel(ref cSapModel sapModel, ref cPluginCallback pluginCallback)
{
_sapModel = sapModel;
Expand All @@ -46,9 +57,6 @@ protected void Form1Closing(object? sender, FormClosingEventArgs e)
Host.Dispose();
_pluginCallback.Finish(0);
}

protected abstract HostAppVersion GetVersion();

public new void ShowDialog()
{
base.ShowDialog();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Speckle.Connectors.CSiShared;
using Speckle.Connectors.ETABSShared;
using Speckle.Sdk.Host;

// NOTE: Plugin entry point must match the assembly name, otherwise ETABS hits you with a "Not found" error when loading plugin
// Disabling error below to prioritize DUI3 project structure. Name of cPlugin class cannot be changed
#pragma warning disable IDE0130
namespace Speckle.Connectors.ETABS21;

public class SpeckleForm : SpeckleFormBase
public class SpeckleForm : ETABSSpeckleFormBase
{
protected override HostAppVersion GetVersion() => HostAppVersion.v2021;
protected override HostAppVersion GetVersion() => HostAppVersion.v2021; // TODO: We need a v21
}
6 changes: 3 additions & 3 deletions Connectors/CSi/Speckle.Connectors.ETABS21/Plugin/cPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Speckle.Connectors.CSiShared;
using Speckle.Connectors.ETABSShared;

// NOTE: Plugin entry point must match the assembly name, otherwise ETABS hits you with a "Not found" error when loading plugin
// Disabling error below to prioritize DUI3 project structure. Name of cPlugin class cannot be changed
#pragma warning disable IDE0130
namespace Speckle.Connectors.ETABS21;

[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
public class cPlugin : CSiPluginBase
public class cPlugin : ETABSPluginBase
{
protected override SpeckleFormBase CreateForm() => new SpeckleForm();
protected override ETABSSpeckleFormBase CreateETABSForm() => new SpeckleForm();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@

<Import Project="..\Speckle.Connectors.CSiShared\Speckle.Connectors.CSiShared.projitems" Label="Shared" />

<Import Project="..\Speckle.Connectors.ETABSShared\Speckle.Connectors.ETABSShared.projitems" Label="Shared" />

</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Speckle.Connectors.CSiShared;
using Speckle.Connectors.ETABSShared;
using Speckle.Sdk.Host;

// NOTE: Plugin entry point must match the assembly name, otherwise ETABS hits you with a "Not found" error when loading plugin
// Disabling error below to prioritize DUI3 project structure. Name of cPlugin class cannot be changed
#pragma warning disable IDE0130
namespace Speckle.Connectors.ETABS22;

public class SpeckleForm : SpeckleFormBase
public class SpeckleForm : ETABSSpeckleFormBase
{
protected override HostAppVersion GetVersion() => HostAppVersion.v2021;
protected override HostAppVersion GetVersion() => HostAppVersion.v2021; // TODO: v22
}
6 changes: 3 additions & 3 deletions Connectors/CSi/Speckle.Connectors.ETABS22/Plugin/cPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Speckle.Connectors.CSiShared;
using Speckle.Connectors.ETABSShared;

// NOTE: Plugin entry point must match the assembly name, otherwise ETABS hits you with a "Not found" error when loading plugin
// Disabling error below to prioritize DUI3 project structure. Name of cPlugin class cannot be changed
#pragma warning disable IDE0130
namespace Speckle.Connectors.ETABS22;

[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
public class cPlugin : CSiPluginBase
public class cPlugin : ETABSPluginBase
{
protected override SpeckleFormBase CreateForm() => new SpeckleForm();
protected override ETABSSpeckleFormBase CreateETABSForm() => new SpeckleForm();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@

<Import Project="..\Speckle.Connectors.CSiShared\Speckle.Connectors.CSiShared.projitems" Label="Shared" />

<Import Project="..\Speckle.Connectors.ETABSShared\Speckle.Connectors.ETABSShared.projitems" Label="Shared" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Speckle.Connectors.CSiShared;

namespace Speckle.Connectors.ETABSShared;

[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>")]
public abstract class ETABSPluginBase : CSiPluginBase
{
public override int Info(ref string text)
{
text = "Hey Speckler! This is our next-gen ETABS Connector.";
return 0;
}

protected override SpeckleFormBase CreateForm() => CreateETABSForm();

protected abstract ETABSSpeckleFormBase CreateETABSForm();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.Extensions.DependencyInjection;
using Speckle.Connectors.CSiShared;
using Speckle.Sdk.Host;

namespace Speckle.Connectors.ETABSShared;

public abstract class ETABSSpeckleFormBase : SpeckleFormBase
{
protected override HostApplication GetHostApplication() => HostApplications.ETABS;

protected override void ConfigureServices(IServiceCollection services)
{
base.ConfigureServices(services);
services.AddETABS();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.Extensions.DependencyInjection;
using Speckle.Converters.ETABSShared;

namespace Speckle.Connectors.ETABSShared;

public static class ServiceRegistration
{
public static IServiceCollection AddETABS(this IServiceCollection services)
{
services.AddETABSConverters();

return services;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>5d1e0b0d-56a7-4e13-b9a9-8633e02b8f17</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Speckle.Connectors.ETABSShared</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Plugin\ETABSPluginBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Plugin\ETABSSpeckleFormBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServiceRegistration.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>5d1e0b0d-56a7-4e13-b9a9-8633e02b8f17</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Speckle.Connectors.ETABSShared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
24 changes: 16 additions & 8 deletions Converters/CSi/Speckle.Converters.CSiShared/ServiceRegistration.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Speckle.Converters.Common;
using Speckle.Converters.Common.Objects;
using Speckle.Converters.Common.Registration;
using Speckle.Converters.CSiShared.ToSpeckle.Geometry;
using Speckle.Converters.CSiShared.ToSpeckle.Helpers;
using Speckle.Converters.CSiShared.ToSpeckle.TopLevel;
using Speckle.Objects.Geometry;
using Speckle.Sdk;

namespace Speckle.Converters.CSiShared;
Expand All @@ -13,18 +16,23 @@ public static class ServiceRegistration
public static IServiceCollection AddCSiConverters(this IServiceCollection serviceCollection)
{
var converterAssembly = Assembly.GetExecutingAssembly();


// Register top-level converters
serviceCollection.AddTransient<CSiObjectToSpeckleConverter>();
serviceCollection.AddScoped<DisplayValueExtractor>();
serviceCollection.AddRootCommon<CSiRootToSpeckleConverter>(converterAssembly);

// TODO: Property extractor
// Register extractors
serviceCollection.AddScoped<DisplayValueExtractor>();
serviceCollection.AddScoped<ClassPropertyExtractor>();

serviceCollection.AddRootCommon<CSiRootToSpeckleConverter>(converterAssembly);
// Register geometry converters
serviceCollection.AddTransient<ITypedConverter<CSiFrameWrapper, Line>, LineToSpeckleConverter>();
serviceCollection.AddTransient<ITypedConverter<CSiJointWrapper, Point>, PointToSpeckleConverter>();
serviceCollection.AddTransient<ITypedConverter<CSiShellWrapper, Mesh>, MeshToSpeckleConverter>();

// Register application-level converters
serviceCollection.AddApplicationConverters<CSiToSpeckleUnitConverter, eUnits>(converterAssembly);
serviceCollection.AddScoped<
IConverterSettingsStore<CSiConversionSettings>,
ConverterSettingsStore<CSiConversionSettings>
>();
serviceCollection.AddScoped<IConverterSettingsStore<CSiConversionSettings>, ConverterSettingsStore<CSiConversionSettings>>();

serviceCollection.AddMatchingInterfacesAsTransient(converterAssembly);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
<Compile Include="$(MSBuildThisFileDirectory)CSiWrappers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GlobalUsing.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ServiceRegistration.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Geometry\LineToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Geometry\MeshToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Geometry\PointToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Helpers\ClassPropertyExtractor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Helpers\DisplayValueExtractor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\FrameToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\JointToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\ShellToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\CSiFrameToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\CSiJointToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\Raw\CSiShellToSpeckleConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ToSpeckle\TopLevel\CSiObjectToSpeckleConverter.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,41 @@
using Speckle.Converters.Common.Objects;
using Speckle.Objects.Geometry;

namespace Speckle.Converters.CSiShared.ToSpeckle.Raw;
namespace Speckle.Converters.CSiShared.ToSpeckle.Geometry;

// NOTE: This is HORRIBLE but serves just as a poc! We need point caching and weak referencing to joint objects
public class FrameToSpeckleConverter : ITypedConverter<CSiFrameWrapper, Line>
public class LineToSpeckleConverter : ITypedConverter<CSiFrameWrapper, Line>
{
private readonly IConverterSettingsStore<CSiConversionSettings> _settingsStore;
private readonly ITypedConverter<CSiJointWrapper, Point> _pointConverter;

public FrameToSpeckleConverter(
public LineToSpeckleConverter(
IConverterSettingsStore<CSiConversionSettings> settingsStore,
ITypedConverter<CSiJointWrapper, Point> pointConverter
)
ITypedConverter<CSiJointWrapper, Point> pointConverter)
{
_settingsStore = settingsStore;
_pointConverter = pointConverter;
}

public Line Convert(CSiFrameWrapper target) // NOTE: THIS IS TEMPORARY POC
public Line Convert(CSiFrameWrapper target)
{
// frame points
string startPoint = "",
endPoint = "";
string startPoint = "", endPoint = "";
if (_settingsStore.Current.SapModel.FrameObj.GetPoints(target.Name, ref startPoint, ref endPoint) != 0)
{
throw new ArgumentException($"Failed to convert frame {target.Name}");
}

// start point coordinates
double startX = 0,
startY = 0,
startZ = 0;
double startX = 0, startY = 0, startZ = 0;
if (_settingsStore.Current.SapModel.PointObj.GetCoordCartesian(startPoint, ref startX, ref startY, ref startZ) != 0)
{
throw new ArgumentException($"Failed to convert point {startPoint}");
}

// end point coordinates
double endX = 0,
endY = 0,
endZ = 0;
double endX = 0, endY = 0, endZ = 0;
if (_settingsStore.Current.SapModel.PointObj.GetCoordCartesian(endPoint, ref endX, ref endY, ref endZ) != 0)
{
throw new ArgumentException($"Failed to convert point {endPoint}");
}

// Create and return the line
return new()
{
start = new Point(startX, startY, startZ, _settingsStore.Current.SpeckleUnits),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using Speckle.Converters.Common.Objects;
using Speckle.Objects.Geometry;

namespace Speckle.Converters.CSiShared.ToSpeckle.Raw;
namespace Speckle.Converters.CSiShared.ToSpeckle.Geometry;

// NOTE: This is HORRIBLE but serves just as a poc! We need point caching and weak referencing to joint objects
public class ShellToSpeckleConverter : ITypedConverter<CSiShellWrapper, Mesh>
public class MeshToSpeckleConverter : ITypedConverter<CSiShellWrapper, Mesh>
{
private readonly IConverterSettingsStore<CSiConversionSettings> _settingsStore;

public ShellToSpeckleConverter(IConverterSettingsStore<CSiConversionSettings> settingsStore)
public MeshToSpeckleConverter(IConverterSettingsStore<CSiConversionSettings> settingsStore)
{
_settingsStore = settingsStore;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using Speckle.Converters.Common.Objects;
using Speckle.Objects.Geometry;

namespace Speckle.Converters.CSiShared.ToSpeckle.Raw;
namespace Speckle.Converters.CSiShared.ToSpeckle.Geometry;

// NOTE: This is HORRIBLE but serves just as a poc!
public class JointToSpeckleConverter : ITypedConverter<CSiJointWrapper, Point>
public class PointToSpeckleConverter : ITypedConverter<CSiJointWrapper, Point>
{
private readonly IConverterSettingsStore<CSiConversionSettings> _settingStore;

public JointToSpeckleConverter(IConverterSettingsStore<CSiConversionSettings> settingStore)
public PointToSpeckleConverter(IConverterSettingsStore<CSiConversionSettings> settingStore)
{
_settingStore = settingStore;
}
Expand Down
Loading

0 comments on commit b042bee

Please sign in to comment.