Skip to content

Commit

Permalink
bjorn/cnx-1133-user-facing-attributes-not-consistent-for-joints (#536)
Browse files Browse the repository at this point in the history
* style: user facing attributes for joint

* bug: using old strings
  • Loading branch information
bjoernsteinhagen authored Jan 29, 2025
1 parent e4a2908 commit f4765b9
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ private string GetObjectLevelFromObject(Base obj)
return DEFAULT_LEVEL;
}

if (properties.TryGetValue("Object ID", out var objectId) && objectId is Dictionary<string, object> parameters)
if (
properties.TryGetValue(ObjectPropertyCategory.OBJECT_ID, out var objectId)
&& objectId is Dictionary<string, object> parameters
)
{
return parameters.TryGetValue("level", out var level) ? level?.ToString() ?? DEFAULT_LEVEL : DEFAULT_LEVEL;
return parameters.TryGetValue(CommonObjectProperty.LEVEL, out var level)
? level?.ToString() ?? DEFAULT_LEVEL
: DEFAULT_LEVEL;
}

return DEFAULT_LEVEL;
Expand All @@ -72,9 +77,12 @@ private ElementCategory GetElementCategoryFromObject(Base obj)
&& obj["properties"] is Dictionary<string, object> properties
)
{
if (properties.TryGetValue("Object ID", out var objectId) && objectId is Dictionary<string, object> parameters)
if (
properties.TryGetValue(ObjectPropertyCategory.OBJECT_ID, out var objectId)
&& objectId is Dictionary<string, object> parameters
)
{
if (parameters.TryGetValue("designOrientation", out var orientation))
if (parameters.TryGetValue(CommonObjectProperty.DESIGN_ORIENTATION, out var orientation))
{
return GetCategoryFromDesignOrientation(orientation?.ToString(), type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public void ExtractProperties(CsiFrameWrapper frame, PropertyExtractionResult fr
(geometry["I-End Joint"], geometry["J-End Joint"]) = GetEndPointNames(frame);

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

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

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

return resultsDictionary;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public void ExtractProperties(CsiJointWrapper joint, PropertyExtractionResult jo
jointData.ApplicationId = joint.GetSpeckleApplicationId(_settingsStore.Current.SapModel);

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

private string[] GetGroupAssigns(CsiJointWrapper joint)
Expand All @@ -53,12 +53,12 @@ private string[] GetGroupAssigns(CsiJointWrapper joint)
_ = _settingsStore.Current.SapModel.PointObj.GetRestraint(joint.Name, ref restraints);
return new Dictionary<string, bool?>
{
["U1"] = restraints[0],
["U2"] = restraints[1],
["U3"] = restraints[2],
["R1"] = restraints[3],
["R2"] = restraints[4],
["R3"] = restraints[5],
["UX Restrained"] = restraints[0],
["UY Restrained"] = restraints[1],
["UZ Restrained"] = restraints[2],
["RX Restrained"] = restraints[3],
["RY Restrained"] = restraints[4],
["RZ Restrained"] = restraints[5],
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public void ExtractProperties(CsiShellWrapper shell, PropertyExtractionResult sh
geometry["Joints"] = GetPointNames(shell); // TODO: 🪲 Viewer shows 4 but only displays 3

var assignments = shellData.Properties.EnsureNested(ObjectPropertyCategory.ASSIGNMENTS);
assignments["Groups"] = GetGroupAssigns(shell);
assignments["Local Axis 2 Angle"] = GetLocalAxes(shell);
assignments["Material Overwrite"] = GetMaterialOverwrite(shell);
assignments["Property Modifiers"] = GetModifiers(shell);
assignments[CommonObjectProperty.GROUPS] = GetGroupAssigns(shell);
assignments[CommonObjectProperty.LOCAL_AXIS_2_ANGLE] = GetLocalAxes(shell);
assignments[CommonObjectProperty.MATERIAL_OVERWRITE] = GetMaterialOverwrite(shell);
assignments[CommonObjectProperty.PROPERTY_MODIFIERS] = GetModifiers(shell);
}

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

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

return resultsDictionary;
}
Expand Down
20 changes: 20 additions & 0 deletions Converters/CSi/Speckle.Converters.CSiShared/Utils/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,30 @@ public static class ObjectPropertyKey
public const string SECTION_ID = "Section Property";
}

/// <summary>
/// These strings are repeatedly used group properties (mimics the host app UI)
/// </summary>
public static class SectionPropertyCategory
{
public const string GENERAL_DATA = "General Data";
public const string SECTION_PROPERTIES = "Section Properties";
public const string SECTION_DIMENSIONS = "Section Dimensions";
public const string PROPERTY_DATA = "Property Data";
}

/// <summary>
/// These strings are properties repeated and common to various object types (joint, frame, shell etc.)
/// </summary>
public static class CommonObjectProperty
{
public const string LABEL = "Label";
public const string LEVEL = "Level";
public const string GROUPS = "Groups";
public const string SPRING_ASSIGNMENT = "Spring Assignment";
public const string LOCAL_AXIS_2_ANGLE = "Local Axis 2 Angle";
public const string MATERIAL_OVERWRITE = "Material Overwrite";
public const string PROPERTY_MODIFIERS = "Property Modifiers";
public const string ANGLE = "Angle";
public const string ADVANCED = "Advanced";
public const string DESIGN_ORIENTATION = "Design Orientation";
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public EtabsFramePropertiesExtractor(IConverterSettingsStore<CsiConversionSettin
public void ExtractProperties(CsiFrameWrapper frame, Dictionary<string, object?> properties)
{
var objectId = properties.EnsureNested(ObjectPropertyCategory.OBJECT_ID);
objectId["Design Orientation"] = GetDesignOrientation(frame);
(objectId["Label"], objectId["Level"]) = GetLabelAndLevel(frame);
objectId[CommonObjectProperty.DESIGN_ORIENTATION] = GetDesignOrientation(frame);
(objectId[CommonObjectProperty.LABEL], objectId[CommonObjectProperty.LEVEL]) = GetLabelAndLevel(frame);

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

var design = properties.EnsureNested(ObjectPropertyCategory.DESIGN);
design["Design Procedure"] = GetDesignProcedure(frame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ public EtabsJointPropertiesExtractor(IConverterSettingsStore<CsiConversionSettin
public void ExtractProperties(CsiJointWrapper joint, Dictionary<string, object?> properties)
{
var objectId = properties.EnsureNested(ObjectPropertyCategory.OBJECT_ID);
(objectId["label"], objectId["level"]) = GetLabelAndLevel(joint);
(objectId[CommonObjectProperty.LABEL], objectId[CommonObjectProperty.LEVEL]) = GetLabelAndLevel(joint);

var assignments = properties.EnsureNested(ObjectPropertyCategory.ASSIGNMENTS);
(assignments["diaphragmOption"], assignments["diaphragmName"]) = GetAssignedDiaphragm(joint);
assignments["springAssignment"] = GetSpringAssignmentName(joint);
(assignments["Diaphragm Option"], assignments["Diaphragm Name"]) = GetAssignedDiaphragm(joint);
assignments[CommonObjectProperty.SPRING_ASSIGNMENT] = GetSpringAssignmentName(joint);
}

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

private string GetSpringAssignmentName(CsiJointWrapper joint)
{
string springPropertyName = "None"; // Is there a better way to handle null?
string springPropertyName = string.Empty;
_ = _settingsStore.Current.SapModel.PointObj.GetSpringAssignment(joint.Name, ref springPropertyName);
return springPropertyName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ IConverterSettingsStore<CsiConversionSettings> settingsStore
public void ExtractProperties(CsiShellWrapper shell, Dictionary<string, object?> properties)
{
var objectId = properties.EnsureNested(ObjectPropertyCategory.OBJECT_ID);
objectId["Design Orientation"] = GetDesignOrientation(shell);
(objectId["Label"], objectId["Level"]) = GetLabelAndLevel(shell);
objectId[CommonObjectProperty.DESIGN_ORIENTATION] = GetDesignOrientation(shell);
(objectId[CommonObjectProperty.LABEL], objectId[CommonObjectProperty.LEVEL]) = GetLabelAndLevel(shell);

var assignments = properties.EnsureNested(ObjectPropertyCategory.ASSIGNMENTS);
assignments["Diaphragm"] = GetAssignedDiaphragmName(shell);
assignments["Opening"] = IsOpening(shell);
assignments["Pier"] = GetPierAssignmentName(shell);
assignments["Spandrel"] = GetSpandrelAssignmentName(shell);
assignments["Spring Assignment"] = GetSpringAssignmentName(shell);
assignments[CommonObjectProperty.SPRING_ASSIGNMENT] = GetSpringAssignmentName(shell);

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

0 comments on commit f4765b9

Please sign in to comment.