Skip to content

Commit 16ce6ac

Browse files
fix: catch tendon and link as warning (#538)
1 parent f379996 commit 16ce6ac

File tree

3 files changed

+58
-7
lines changed

3 files changed

+58
-7
lines changed

Connectors/CSi/Speckle.Connectors.CSiShared/Operations/Send/CsiRootObjectBuilder.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,13 @@ private SendConversionResult ConvertCsiObject(ICsiWrapper csiObject, Collection
125125
string sourceType = csiObject.ObjectName;
126126
string applicationId = csiObject switch
127127
{
128-
CsiFrameWrapper frameWrapper => frameWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
129128
CsiJointWrapper jointWrapper => jointWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
129+
CsiFrameWrapper frameWrapper => frameWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
130+
CsiCableWrapper cableWrapper => cableWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
131+
CsiTendonWrapper tendonWrapper => tendonWrapper.ObjectName, // No GetGUID method in the Csi API available
130132
CsiShellWrapper shellWrapper => shellWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
133+
CsiSolidWrapper solidWrapper => solidWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
134+
CsiLinkWrapper linkWrapper => linkWrapper.GetSpeckleApplicationId(_csiApplicationService.SapModel),
131135
_ => throw new ArgumentException($"Unsupported wrapper type: {csiObject.GetType()}", nameof(csiObject))
132136
};
133137

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

141145
return new(Status.SUCCESS, applicationId, sourceType, converted);
142146
}
147+
// Expected not implemented:
148+
// TODO: SAP 2000: CsiCableWrapper, CsiSolidWrapper
149+
// TODO: ETABS: CsiLinkWrapper, CsiTendonWrapper
150+
// NOTE: CsiLinkWrapper - not important to data extraction workflow
151+
// NOTE: CsiTendonWrapper - not typically modelled in ETABS, rather SAFE
152+
catch (NotImplementedException ex)
153+
{
154+
_logger.LogError(ex, sourceType);
155+
return new(Status.WARNING, applicationId, sourceType, null, ex);
156+
}
143157
catch (Exception ex) when (!ex.IsFatal())
144158
{
145159
_logger.LogError(ex, sourceType);

Converters/CSi/Speckle.Converters.CSiShared/Extensions/SpeckleApplicationIdExtensions.cs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ namespace Speckle.Converters.CSiShared.Extensions;
22

33
public static class SpeckleApplicationIdExtensions
44
{
5+
/// <summary>
6+
/// Retrieves the Speckle object application id for a joint object
7+
/// </summary>
8+
public static string GetSpeckleApplicationId(this CsiJointWrapper wrapper, cSapModel sapModel)
9+
{
10+
string applicationId = string.Empty;
11+
_ = sapModel.PointObj.GetGUID(wrapper.Name, ref applicationId);
12+
return applicationId;
13+
}
14+
515
/// <summary>
616
/// Retrieves the Speckle object application id for a frame object
717
/// </summary>
@@ -13,12 +23,12 @@ public static string GetSpeckleApplicationId(this CsiFrameWrapper wrapper, cSapM
1323
}
1424

1525
/// <summary>
16-
/// Retrieves the Speckle object application id for a joint object
26+
/// Retrieves the Speckle object application id for a cable object
1727
/// </summary>
18-
public static string GetSpeckleApplicationId(this CsiJointWrapper wrapper, cSapModel sapModel)
28+
public static string GetSpeckleApplicationId(this CsiCableWrapper wrapper, cSapModel sapModel)
1929
{
2030
string applicationId = string.Empty;
21-
_ = sapModel.PointObj.GetGUID(wrapper.Name, ref applicationId);
31+
_ = sapModel.CableObj.GetGUID(wrapper.Name, ref applicationId);
2232
return applicationId;
2333
}
2434

@@ -31,4 +41,24 @@ public static string GetSpeckleApplicationId(this CsiShellWrapper wrapper, cSapM
3141
_ = sapModel.AreaObj.GetGUID(wrapper.Name, ref applicationId);
3242
return applicationId;
3343
}
44+
45+
/// <summary>
46+
/// Retrieves the Speckle object application id for a solid object
47+
/// </summary>
48+
public static string GetSpeckleApplicationId(this CsiSolidWrapper wrapper, cSapModel sapModel)
49+
{
50+
string applicationId = string.Empty;
51+
_ = sapModel.SolidObj.GetGUID(wrapper.Name, ref applicationId);
52+
return applicationId;
53+
}
54+
55+
/// <summary>
56+
/// Retrieves the Speckle object application id for a link object
57+
/// </summary>
58+
public static string GetSpeckleApplicationId(this CsiLinkWrapper wrapper, cSapModel sapModel)
59+
{
60+
string applicationId = string.Empty;
61+
_ = sapModel.LinkObj.GetGUID(wrapper.Name, ref applicationId);
62+
return applicationId;
63+
}
3464
}

Converters/CSi/Speckle.Converters.CSiShared/ToSpeckle/Helpers/SharedPropertiesExtractor.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,22 @@ public PropertyExtractionResult Extract(ICsiWrapper wrapper)
5757

5858
switch (wrapper)
5959
{
60-
case CsiFrameWrapper frame:
61-
_csiFramePropertiesExtractor.ExtractProperties(frame, objectData);
62-
break;
6360
case CsiJointWrapper joint:
6461
_csiJointPropertiesExtractor.ExtractProperties(joint, objectData);
6562
break;
63+
case CsiFrameWrapper frame:
64+
_csiFramePropertiesExtractor.ExtractProperties(frame, objectData);
65+
break;
6666
case CsiShellWrapper shell:
6767
_csiShellPropertiesExtractor.ExtractProperties(shell, objectData);
6868
break;
69+
case CsiTendonWrapper:
70+
case CsiLinkWrapper:
71+
case CsiCableWrapper:
72+
case CsiSolidWrapper:
73+
throw new NotImplementedException($"Data extraction for {wrapper.ObjectName} not yet supported.");
74+
default:
75+
throw new ArgumentException($"Unsupported wrapper type: {nameof(wrapper)}");
6976
}
7077

7178
return objectData;

0 commit comments

Comments
 (0)