Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bjorn/cnx-880-add-sections-and-materials-as-proxies #499

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Notes and documentation
bjoernsteinhagen committed Jan 15, 2025
commit 79c502ec88927932d694bc87c178fb40cbde0ea5
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ namespace Speckle.Connectors.CSiShared.HostApp.Helpers;
/// Base frame section property extractor for CSi products.
/// </summary>
/// <remarks>
/// Handles common frame section properties using CSi API.
/// Handles common Csi API calls for frame section properties
/// Provides foundation for application-specific extractors.
/// </remarks>
public class CsiFrameSectionPropertyExtractor : IFrameSectionPropertyExtractor
@@ -27,7 +27,7 @@ public void ExtractProperties(string sectionName, SectionPropertyExtractionResul
dataExtractionResult.MaterialName = GetMaterialName(sectionName);
}

public string GetMaterialName(string sectionName)
private string GetMaterialName(string sectionName)
{
string materialName = string.Empty;
_settingsStore.Current.SapModel.PropFrame.GetMaterial(sectionName, ref materialName);
Original file line number Diff line number Diff line change
@@ -4,6 +4,13 @@

namespace Speckle.Connectors.CSiShared.HostApp.Helpers;

/// <summary>
/// Base material property extractor for CSi products.
/// </summary>
/// <remarks>
/// Currently, all material property extraction can happen on a CsiShared level which simplifies things a lot.
/// Properties depend on the directional symmetry of the material, hence the switch statements.
/// </remarks>
public class CsiMaterialPropertyExtractor
{
private readonly IConverterSettingsStore<CsiConversionSettings> _settingsStore;
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ namespace Speckle.Connectors.CSiShared.HostApp.Helpers;
/// Base shell section property extractor for CSi products.
/// </summary>
/// <remarks>
/// Handles common shell section properties using CSi API.
/// Handles common Csi API calls for shell section properties.
/// Provides foundation for application-specific extractors.
/// </remarks>
public class CsiShellSectionPropertyExtractor : IShellSectionPropertyExtractor
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ public interface IApplicationSectionPropertyExtractor
void ExtractProperties(string sectionName, SectionPropertyExtractionResult dataExtractionResult);
}

// NOTE: Seemingly silly, but allows us to register the correct extractor for the correct type.
public interface IApplicationFrameSectionPropertyExtractor : IApplicationSectionPropertyExtractor { }

public interface IApplicationShellSectionPropertyExtractor : IApplicationSectionPropertyExtractor { }
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
namespace Speckle.Connectors.CSiShared.HostApp.Helpers;

/// <summary>
/// Formalising required extracted results for ensuing operations
/// </summary>
public class SectionPropertyExtractionResult
{
public string MaterialName { get; set; }
public string MaterialName { get; set; } // NOTE: Doubled up and nested in Properties, but we want quick access for relations
public Dictionary<string, object?> Properties { get; set; } = [];
}

@@ -14,6 +17,7 @@ public interface ISectionPropertyExtractor
void ExtractProperties(string sectionName, SectionPropertyExtractionResult dataExtractionResult);
}

// NOTE: Seemingly silly, but allows us to register the correct extractor for the correct type.
public interface IFrameSectionPropertyExtractor : ISectionPropertyExtractor { }

public interface IShellSectionPropertyExtractor : ISectionPropertyExtractor { }
Original file line number Diff line number Diff line change
@@ -9,11 +9,12 @@
namespace Speckle.Connectors.CSiShared.HostApp;

/// <summary>
/// Unpacks materials and creates material proxies.
/// Extracts material proxies from the root object collection.
/// </summary>
/// <remarks>
/// Handles listing of materials and proxy creation.
/// Property extraction delegated to material property extractor.
/// Decouples material extraction from conversion processes. Supports complex material
/// property retrieval (dependent on material type) while maintaining a clean separation of concerns.
/// Enables extensible material proxy creation across different material types.
/// </remarks>
public class MaterialUnpacker
{
bjoernsteinhagen marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -47,7 +47,8 @@ public void EstablishRelationships(List<Base> convertedObjectsByType, List<IProx

private string? GetObjectSectionName(Base baseObject)
{
// 🙍‍♂️ This below is horrible! I know. We need to refine the accessibility of sectionProperty in a more robust manner
// TODO: We need to refine the accessibility of sectionProperty in a more robust manner
// 🙍‍♂️ This below is horrible! I know. But both SHELL and FRAME have the same nested property structure (unformalised)
try
{
if (baseObject["properties"] is not Dictionary<string, object?> properties)
Original file line number Diff line number Diff line change
@@ -5,12 +5,10 @@
namespace Speckle.Connectors.CSiShared.HostApp.Relationships;

/// <summary>
/// Manages relationships between sections and their assigned materials.
/// Manages relationships between sections and materials.
/// </summary>
/// <remarks>
/// Handles only section-material relationships for clear separation of concerns.
/// Uses material names from section properties to establish links.
/// Performs null checks and logging to maintain relationship integrity.
/// Establishes clear links between sections and materials with minimal coupling.
/// </remarks>
public class SectionMaterialRelationshipManager : ISectionMaterialRelationshipManager
{
Original file line number Diff line number Diff line change
@@ -9,6 +9,14 @@

namespace Speckle.Connectors.ETABSShared.HostApp;

/// <summary>
/// Unpacks and creates proxies for frame and shell sections from the model.
/// </summary>
/// <remarks>
/// Provides a unified approach to section extraction across different section types.
/// Leverages specialized extractors to handle complex property retrieval. Centralizes
/// section proxy creation with robust error handling and logging mechanisms.
/// </remarks>
public class EtabsSectionUnpacker : ISectionUnpacker
{
private readonly ICsiApplicationService _csiApplicationService;
Original file line number Diff line number Diff line change
@@ -23,6 +23,14 @@ ILogger<EtabsFrameSectionPropertyExtractor> logger
_logger = logger;
}

/// <summary>
/// Gets generalised frame section properties
/// </summary>
/// <remarks>
/// Sap2000 doesn't support this method, unfortunately
/// Alternative is to account for extraction according to section type - we're talking over 40 section types!
/// This way, we get basic information with minimal computational costs.
/// </remarks>
public void ExtractProperties(string sectionName, SectionPropertyExtractionResult dataExtractionResult)
{
// Get all frame properties
Original file line number Diff line number Diff line change
@@ -29,6 +29,16 @@ IApplicationShellSectionPropertyExtractor etabsShellExtractor
_etabsShellExtractor = etabsShellExtractor;
}

/// <summary>
/// Extract the properties on both a Csi and app-specific level
/// </summary>
/// <remarks>
/// SectionPropertyExtractionResult formalises and enforces (somewhat) the required attributes
/// propertyExtraction gets mutated within the _csiFrameExtractor and _etabsFrameExtractor methods
/// Not ideal, BUT this way we negate specific order of operations AND it create uniformity in the approach
/// with shell sections although how obtain MaterialName (for example) differs between the two types.
/// For FRAME, the material is obtained easily on the CsiShared level
/// </remarks>
public SectionPropertyExtractionResult ExtractFrameSectionProperties(string sectionName)
{
SectionPropertyExtractionResult propertyExtraction = new();
@@ -37,6 +47,16 @@ public SectionPropertyExtractionResult ExtractFrameSectionProperties(string sect
return propertyExtraction;
}

/// <summary>
/// Extract the properties on both a Csi and app-specific level
/// </summary>
/// <remarks>
/// SectionPropertyExtractionResult formalises and enforces (somewhat) the required attributes
/// propertyExtraction gets mutated within the _csiShellExtractor and _etabsShellExtractor methods
/// Not ideal, BUT this way we negate specific order of operations AND it create uniformity in the approach
/// with frame sections although how obtain MaterialName (for example) differs between the two types.
/// Property extraction is complicated for shells, see EtabsShellSectionResolver.
/// </remarks>
public SectionPropertyExtractionResult ExtractShellSectionProperties(string sectionName)
{
SectionPropertyExtractionResult propertyExtraction = new();
Original file line number Diff line number Diff line change
@@ -26,6 +26,15 @@ EtabsShellSectionResolver etabsShellSectionResolver
_etabsShellSectionResolver = etabsShellSectionResolver;
}

/// <summary>
/// Extract shell section properties
/// </summary>
/// <remarks>
/// sectionName is unique across all types (Wall, Slab and Deck)
/// There is no general query such as PropArea.GetShell() - rather we have to be specific on the type, for example
/// PropArea.GetWall() or PropArea.GetDeck() BUT we can't get the building type given a SectionName.
/// Hence the introduction of ResolveSection.
/// </remarks>
public void ExtractProperties(string sectionName, SectionPropertyExtractionResult dataExtractionResult)
{
// Step 01: Finding the appropriate api query for the unknown section type (wall, deck or slab)
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ namespace Speckle.Connectors.ETABSShared.HostApp.Helpers;
/// This service focuses solely on determining the correct section type and returning its properties.
/// Since section names are unique across different types (Wall, Slab, Deck), it uses a try-and-fail approach
/// rather than attempting to predetermine the type. The first successful resolution is returned.
/// The merging of the returned properties with any existing property collections should be handled by the caller.
/// </remarks>
public record AreaSectionResult
{
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
using Speckle.Connectors.CSiShared.HostApp.Helpers;
using Speckle.Connectors.ETABSShared.HostApp;
using Speckle.Connectors.ETABSShared.HostApp.Helpers;
using Speckle.Connectors.ETABSShared.HostApp.Sections;
using Speckle.Converters.ETABSShared;

namespace Speckle.Connectors.ETABSShared;