Skip to content

Commit f4765b9

Browse files
bjorn/cnx-1133-user-facing-attributes-not-consistent-for-joints (#536)
* style: user facing attributes for joint * bug: using old strings
1 parent e4a2908 commit f4765b9

File tree

8 files changed

+63
-35
lines changed

8 files changed

+63
-35
lines changed

Connectors/CSi/Speckle.Connectors.ETABSShared/HostApp/EtabsSendCollectionManager.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ private string GetObjectLevelFromObject(Base obj)
4848
return DEFAULT_LEVEL;
4949
}
5050

51-
if (properties.TryGetValue("Object ID", out var objectId) && objectId is Dictionary<string, object> parameters)
51+
if (
52+
properties.TryGetValue(ObjectPropertyCategory.OBJECT_ID, out var objectId)
53+
&& objectId is Dictionary<string, object> parameters
54+
)
5255
{
53-
return parameters.TryGetValue("level", out var level) ? level?.ToString() ?? DEFAULT_LEVEL : DEFAULT_LEVEL;
56+
return parameters.TryGetValue(CommonObjectProperty.LEVEL, out var level)
57+
? level?.ToString() ?? DEFAULT_LEVEL
58+
: DEFAULT_LEVEL;
5459
}
5560

5661
return DEFAULT_LEVEL;
@@ -72,9 +77,12 @@ private ElementCategory GetElementCategoryFromObject(Base obj)
7277
&& obj["properties"] is Dictionary<string, object> properties
7378
)
7479
{
75-
if (properties.TryGetValue("Object ID", out var objectId) && objectId is Dictionary<string, object> parameters)
80+
if (
81+
properties.TryGetValue(ObjectPropertyCategory.OBJECT_ID, out var objectId)
82+
&& objectId is Dictionary<string, object> parameters
83+
)
7684
{
77-
if (parameters.TryGetValue("designOrientation", out var orientation))
85+
if (parameters.TryGetValue(CommonObjectProperty.DESIGN_ORIENTATION, out var orientation))
7886
{
7987
return GetCategoryFromDesignOrientation(orientation?.ToString(), type);
8088
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public void ExtractProperties(CsiFrameWrapper frame, PropertyExtractionResult fr
5151
(geometry["I-End Joint"], geometry["J-End Joint"]) = GetEndPointNames(frame);
5252

5353
var assignments = frameData.Properties.EnsureNested(ObjectPropertyCategory.ASSIGNMENTS);
54-
assignments["Groups"] = GetGroupAssigns(frame);
55-
assignments["Material Overwrite"] = GetMaterialOverwrite(frame);
56-
assignments["Local Axis 2 Angle"] = GetLocalAxes(frame);
57-
assignments["Property Modifiers"] = GetModifiers(frame);
54+
assignments[CommonObjectProperty.GROUPS] = GetGroupAssigns(frame);
55+
assignments[CommonObjectProperty.MATERIAL_OVERWRITE] = GetMaterialOverwrite(frame);
56+
assignments[CommonObjectProperty.LOCAL_AXIS_2_ANGLE] = GetLocalAxes(frame);
57+
assignments[CommonObjectProperty.PROPERTY_MODIFIERS] = GetModifiers(frame);
5858
assignments["End Releases"] = GetReleases(frame);
5959

6060
// NOTE: sectionId and materialId a "quick-fix" to enable filtering in the viewer etc.
@@ -110,8 +110,8 @@ private string[] GetGroupAssigns(CsiFrameWrapper frame)
110110
_ = _settingsStore.Current.SapModel.FrameObj.GetLocalAxes(frame.Name, ref angle, ref advanced);
111111

112112
Dictionary<string, object?> resultsDictionary = [];
113-
resultsDictionary.AddWithUnits("Angle", angle, "Degrees");
114-
resultsDictionary["Advanced"] = advanced.ToString();
113+
resultsDictionary.AddWithUnits(CommonObjectProperty.ANGLE, angle, "Degrees");
114+
resultsDictionary[CommonObjectProperty.ADVANCED] = advanced.ToString();
115115

116116
return resultsDictionary;
117117
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public void ExtractProperties(CsiJointWrapper joint, PropertyExtractionResult jo
3535
jointData.ApplicationId = joint.GetSpeckleApplicationId(_settingsStore.Current.SapModel);
3636

3737
var assignments = jointData.Properties.EnsureNested(ObjectPropertyCategory.ASSIGNMENTS);
38-
assignments["groups"] = new List<string>(GetGroupAssigns(joint));
39-
assignments["restraints"] = GetRestraints(joint);
38+
assignments[CommonObjectProperty.GROUPS] = new List<string>(GetGroupAssigns(joint));
39+
assignments["Restraints"] = GetRestraints(joint);
4040
}
4141

4242
private string[] GetGroupAssigns(CsiJointWrapper joint)
@@ -53,12 +53,12 @@ private string[] GetGroupAssigns(CsiJointWrapper joint)
5353
_ = _settingsStore.Current.SapModel.PointObj.GetRestraint(joint.Name, ref restraints);
5454
return new Dictionary<string, bool?>
5555
{
56-
["U1"] = restraints[0],
57-
["U2"] = restraints[1],
58-
["U3"] = restraints[2],
59-
["R1"] = restraints[3],
60-
["R2"] = restraints[4],
61-
["R3"] = restraints[5],
56+
["UX Restrained"] = restraints[0],
57+
["UY Restrained"] = restraints[1],
58+
["UZ Restrained"] = restraints[2],
59+
["RX Restrained"] = restraints[3],
60+
["RY Restrained"] = restraints[4],
61+
["RZ Restrained"] = restraints[5],
6262
};
6363
}
6464
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public void ExtractProperties(CsiShellWrapper shell, PropertyExtractionResult sh
3535
geometry["Joints"] = GetPointNames(shell); // TODO: 🪲 Viewer shows 4 but only displays 3
3636

3737
var assignments = shellData.Properties.EnsureNested(ObjectPropertyCategory.ASSIGNMENTS);
38-
assignments["Groups"] = GetGroupAssigns(shell);
39-
assignments["Local Axis 2 Angle"] = GetLocalAxes(shell);
40-
assignments["Material Overwrite"] = GetMaterialOverwrite(shell);
41-
assignments["Property Modifiers"] = GetModifiers(shell);
38+
assignments[CommonObjectProperty.GROUPS] = GetGroupAssigns(shell);
39+
assignments[CommonObjectProperty.LOCAL_AXIS_2_ANGLE] = GetLocalAxes(shell);
40+
assignments[CommonObjectProperty.MATERIAL_OVERWRITE] = GetMaterialOverwrite(shell);
41+
assignments[CommonObjectProperty.PROPERTY_MODIFIERS] = GetModifiers(shell);
4242
}
4343

4444
private string[] GetGroupAssigns(CsiShellWrapper shell)
@@ -56,8 +56,8 @@ private string[] GetGroupAssigns(CsiShellWrapper shell)
5656
_ = _settingsStore.Current.SapModel.AreaObj.GetLocalAxes(shell.Name, ref angle, ref advanced);
5757

5858
Dictionary<string, object?> resultsDictionary = [];
59-
resultsDictionary.AddWithUnits("Angle", angle, "Degrees");
60-
resultsDictionary["Advanced"] = advanced.ToString();
59+
resultsDictionary.AddWithUnits(CommonObjectProperty.ANGLE, angle, "Degrees");
60+
resultsDictionary[CommonObjectProperty.ADVANCED] = advanced.ToString();
6161

6262
return resultsDictionary;
6363
}

Converters/CSi/Speckle.Converters.CSiShared/Utils/Constants.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,30 @@ public static class ObjectPropertyKey
2525
public const string SECTION_ID = "Section Property";
2626
}
2727

28+
/// <summary>
29+
/// These strings are repeatedly used group properties (mimics the host app UI)
30+
/// </summary>
2831
public static class SectionPropertyCategory
2932
{
3033
public const string GENERAL_DATA = "General Data";
3134
public const string SECTION_PROPERTIES = "Section Properties";
3235
public const string SECTION_DIMENSIONS = "Section Dimensions";
3336
public const string PROPERTY_DATA = "Property Data";
3437
}
38+
39+
/// <summary>
40+
/// These strings are properties repeated and common to various object types (joint, frame, shell etc.)
41+
/// </summary>
42+
public static class CommonObjectProperty
43+
{
44+
public const string LABEL = "Label";
45+
public const string LEVEL = "Level";
46+
public const string GROUPS = "Groups";
47+
public const string SPRING_ASSIGNMENT = "Spring Assignment";
48+
public const string LOCAL_AXIS_2_ANGLE = "Local Axis 2 Angle";
49+
public const string MATERIAL_OVERWRITE = "Material Overwrite";
50+
public const string PROPERTY_MODIFIERS = "Property Modifiers";
51+
public const string ANGLE = "Angle";
52+
public const string ADVANCED = "Advanced";
53+
public const string DESIGN_ORIENTATION = "Design Orientation";
54+
}

Converters/CSi/Speckle.Converters.ETABSShared/ToSpeckle/Helpers/EtabsFramePropertiesExtractor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public EtabsFramePropertiesExtractor(IConverterSettingsStore<CsiConversionSettin
3434
public void ExtractProperties(CsiFrameWrapper frame, Dictionary<string, object?> properties)
3535
{
3636
var objectId = properties.EnsureNested(ObjectPropertyCategory.OBJECT_ID);
37-
objectId["Design Orientation"] = GetDesignOrientation(frame);
38-
(objectId["Label"], objectId["Level"]) = GetLabelAndLevel(frame);
37+
objectId[CommonObjectProperty.DESIGN_ORIENTATION] = GetDesignOrientation(frame);
38+
(objectId[CommonObjectProperty.LABEL], objectId[CommonObjectProperty.LEVEL]) = GetLabelAndLevel(frame);
3939

4040
var assignments = properties.EnsureNested(ObjectPropertyCategory.ASSIGNMENTS);
41-
assignments["Spring Assignment"] = GetSpringAssignmentName(frame);
41+
assignments[CommonObjectProperty.SPRING_ASSIGNMENT] = GetSpringAssignmentName(frame);
4242

4343
var design = properties.EnsureNested(ObjectPropertyCategory.DESIGN);
4444
design["Design Procedure"] = GetDesignProcedure(frame);

Converters/CSi/Speckle.Converters.ETABSShared/ToSpeckle/Helpers/EtabsJointPropertiesExtractor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ public EtabsJointPropertiesExtractor(IConverterSettingsStore<CsiConversionSettin
3434
public void ExtractProperties(CsiJointWrapper joint, Dictionary<string, object?> properties)
3535
{
3636
var objectId = properties.EnsureNested(ObjectPropertyCategory.OBJECT_ID);
37-
(objectId["label"], objectId["level"]) = GetLabelAndLevel(joint);
37+
(objectId[CommonObjectProperty.LABEL], objectId[CommonObjectProperty.LEVEL]) = GetLabelAndLevel(joint);
3838

3939
var assignments = properties.EnsureNested(ObjectPropertyCategory.ASSIGNMENTS);
40-
(assignments["diaphragmOption"], assignments["diaphragmName"]) = GetAssignedDiaphragm(joint);
41-
assignments["springAssignment"] = GetSpringAssignmentName(joint);
40+
(assignments["Diaphragm Option"], assignments["Diaphragm Name"]) = GetAssignedDiaphragm(joint);
41+
assignments[CommonObjectProperty.SPRING_ASSIGNMENT] = GetSpringAssignmentName(joint);
4242
}
4343

4444
private (string diaphramOption, string diaphragmName) GetAssignedDiaphragm(CsiJointWrapper joint)
4545
{
4646
eDiaphragmOption diaphragmOption = eDiaphragmOption.Disconnect;
47-
string diaphragmName = "None"; // Is there a better way to handle null?
47+
string diaphragmName = string.Empty;
4848
_ = _settingsStore.Current.SapModel.PointObj.GetDiaphragm(joint.Name, ref diaphragmOption, ref diaphragmName);
4949
return (diaphragmOption.ToString(), diaphragmName);
5050
}
@@ -59,7 +59,7 @@ public void ExtractProperties(CsiJointWrapper joint, Dictionary<string, object?>
5959

6060
private string GetSpringAssignmentName(CsiJointWrapper joint)
6161
{
62-
string springPropertyName = "None"; // Is there a better way to handle null?
62+
string springPropertyName = string.Empty;
6363
_ = _settingsStore.Current.SapModel.PointObj.GetSpringAssignment(joint.Name, ref springPropertyName);
6464
return springPropertyName;
6565
}

Converters/CSi/Speckle.Converters.ETABSShared/ToSpeckle/Helpers/EtabsShellPropertiesExtractor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ IConverterSettingsStore<CsiConversionSettings> settingsStore
4343
public void ExtractProperties(CsiShellWrapper shell, Dictionary<string, object?> properties)
4444
{
4545
var objectId = properties.EnsureNested(ObjectPropertyCategory.OBJECT_ID);
46-
objectId["Design Orientation"] = GetDesignOrientation(shell);
47-
(objectId["Label"], objectId["Level"]) = GetLabelAndLevel(shell);
46+
objectId[CommonObjectProperty.DESIGN_ORIENTATION] = GetDesignOrientation(shell);
47+
(objectId[CommonObjectProperty.LABEL], objectId[CommonObjectProperty.LEVEL]) = GetLabelAndLevel(shell);
4848

4949
var assignments = properties.EnsureNested(ObjectPropertyCategory.ASSIGNMENTS);
5050
assignments["Diaphragm"] = GetAssignedDiaphragmName(shell);
5151
assignments["Opening"] = IsOpening(shell);
5252
assignments["Pier"] = GetPierAssignmentName(shell);
5353
assignments["Spandrel"] = GetSpandrelAssignmentName(shell);
54-
assignments["Spring Assignment"] = GetSpringAssignmentName(shell);
54+
assignments[CommonObjectProperty.SPRING_ASSIGNMENT] = GetSpringAssignmentName(shell);
5555

5656
// NOTE: Section Property and Material are a "quick-fix" to enable filtering in the viewer etc.
5757
// Assign Section Property to variable as this will be an argument for the GetMaterialName method

0 commit comments

Comments
 (0)