Skip to content

Commit

Permalink
Merge pull request #541 from specklesystems/dev
Browse files Browse the repository at this point in the history
test(etabs): installer
  • Loading branch information
JR-Morgan authored Jan 30, 2025
2 parents 87569c9 + 184c53c commit e789149
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ private SendConversionResult ConvertCsiObject(ICsiWrapper csiObject, Collection
string sourceType = csiObject.ObjectName;
string applicationId = csiObject switch
{
CsiFrameWrapper frameWrapper => frameWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
CsiJointWrapper jointWrapper => jointWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
CsiFrameWrapper frameWrapper => frameWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
CsiCableWrapper cableWrapper => cableWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
CsiTendonWrapper tendonWrapper => tendonWrapper.ObjectName, // No GetGUID method in the Csi API available
CsiShellWrapper shellWrapper => shellWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
CsiSolidWrapper solidWrapper => solidWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
CsiLinkWrapper linkWrapper => linkWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
_ => throw new ArgumentException($"Unsupported wrapper type: {csiObject.GetType()}", nameof(csiObject))
};

Expand All @@ -140,6 +144,16 @@ private SendConversionResult ConvertCsiObject(ICsiWrapper csiObject, Collection

return new(Status.SUCCESS, applicationId, sourceType, converted);
}
// Expected not implemented:
// TODO: SAP 2000: CsiCableWrapper, CsiSolidWrapper
// TODO: ETABS: CsiLinkWrapper, CsiTendonWrapper
// NOTE: CsiLinkWrapper - not important to data extraction workflow
// NOTE: CsiTendonWrapper - not typically modelled in ETABS, rather SAFE
catch (NotImplementedException ex)
{
_logger.LogError(ex, sourceType);
return new(Status.WARNING, applicationId, sourceType, null, ex);
}
catch (Exception ex) when (!ex.IsFatal())
{
_logger.LogError(ex, sourceType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ private void OnLayerTableEvent(LayerTableEventArgs args)
var layer = RhinoDoc.ActiveDoc.Layers[args.LayerIndex];

// add all objects from the changed layers and sublayers to the non-destructively changed object list.
var allLayers = args.Document.Layers.Where(l => l.FullPath.Contains(layer.Name)); // not e imperfect, but layer.GetChildren(true) is valid only in v8 and above; this filter will include the original layer.
var allLayers = args.Document.Layers.Where(l => /* NOTE: layer path may actually be null in some cases (rhino's fault, not ours) */
l.FullPath != null && l.FullPath.Contains(layer.Name)
); // not e imperfect, but layer.GetChildren(true) is valid only in v8 and above; this filter will include the original layer.
foreach (var childLayer in allLayers)
{
var sublayerObjs = RhinoDoc.ActiveDoc.Objects.FindByLayer(childLayer) ?? [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ namespace Speckle.Converters.CSiShared.Extensions;

public static class SpeckleApplicationIdExtensions
{
/// <summary>
/// Retrieves the Speckle object application id for a joint object
/// </summary>
public static string GetSpeckleApplicationId(this CsiJointWrapper wrapper, cSapModel sapModel)
{
string applicationId = string.Empty;
_ = sapModel.PointObj.GetGUID(wrapper.Name, ref applicationId);
return applicationId;
}

/// <summary>
/// Retrieves the Speckle object application id for a frame object
/// </summary>
Expand All @@ -13,12 +23,12 @@ public static string GetSpeckleApplicationId(this CsiFrameWrapper wrapper, cSapM
}

/// <summary>
/// Retrieves the Speckle object application id for a joint object
/// Retrieves the Speckle object application id for a cable object
/// </summary>
public static string GetSpeckleApplicationId(this CsiJointWrapper wrapper, cSapModel sapModel)
public static string GetSpeckleApplicationId(this CsiCableWrapper wrapper, cSapModel sapModel)
{
string applicationId = string.Empty;
_ = sapModel.PointObj.GetGUID(wrapper.Name, ref applicationId);
_ = sapModel.CableObj.GetGUID(wrapper.Name, ref applicationId);
return applicationId;
}

Expand All @@ -31,4 +41,24 @@ public static string GetSpeckleApplicationId(this CsiShellWrapper wrapper, cSapM
_ = sapModel.AreaObj.GetGUID(wrapper.Name, ref applicationId);
return applicationId;
}

/// <summary>
/// Retrieves the Speckle object application id for a solid object
/// </summary>
public static string GetSpeckleApplicationId(this CsiSolidWrapper wrapper, cSapModel sapModel)
{
string applicationId = string.Empty;
_ = sapModel.SolidObj.GetGUID(wrapper.Name, ref applicationId);
return applicationId;
}

/// <summary>
/// Retrieves the Speckle object application id for a link object
/// </summary>
public static string GetSpeckleApplicationId(this CsiLinkWrapper wrapper, cSapModel sapModel)
{
string applicationId = string.Empty;
_ = sapModel.LinkObj.GetGUID(wrapper.Name, ref applicationId);
return applicationId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,22 @@ public PropertyExtractionResult Extract(ICsiWrapper wrapper)

switch (wrapper)
{
case CsiFrameWrapper frame:
_csiFramePropertiesExtractor.ExtractProperties(frame, objectData);
break;
case CsiJointWrapper joint:
_csiJointPropertiesExtractor.ExtractProperties(joint, objectData);
break;
case CsiFrameWrapper frame:
_csiFramePropertiesExtractor.ExtractProperties(frame, objectData);
break;
case CsiShellWrapper shell:
_csiShellPropertiesExtractor.ExtractProperties(shell, objectData);
break;
case CsiTendonWrapper:
case CsiLinkWrapper:
case CsiCableWrapper:
case CsiSolidWrapper:
throw new NotImplementedException($"Data extraction for {wrapper.ObjectName} not yet supported.");
default:
throw new ArgumentException($"Unsupported wrapper type: {nameof(wrapper)}");
}

return objectData;
Expand Down
27 changes: 20 additions & 7 deletions DUI3/Speckle.Connectors.DUI/ContainerRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,27 @@ public static IServiceCollection AddEventsAsTransient(this IServiceCollection se
public static IServiceProvider UseDUI(this IServiceProvider serviceProvider, bool initializeDocumentStore = true)
{
//observe the unobserved!
TaskScheduler.UnobservedTaskException += async (_, args) =>
TaskScheduler.UnobservedTaskException += (_, args) =>
{
await serviceProvider
.GetRequiredService<IEventAggregator>()
.GetEvent<ExceptionEvent>()
.PublishAsync(args.Exception);
serviceProvider.GetRequiredService<ILogger>().LogError(args.Exception, "Unobserved task exception");
args.SetObserved();
try
{
serviceProvider
.GetRequiredService<ILoggerFactory>()
.CreateLogger("UnobservedTaskException")
.LogError(args.Exception, "Unobserved task exception");
}
#pragma warning disable CA1031
catch (Exception e)
#pragma warning restore CA1031
{
Console.WriteLine("Error logging unobserved task exception");
Console.WriteLine(args.Exception);
Console.WriteLine(e);
}
finally
{
args.SetObserved();
}
};

if (initializeDocumentStore)
Expand Down

0 comments on commit e789149

Please sign in to comment.