-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CNX-755: Create Collections by Category (#387)
* sendCollectionManager * path Builder Removing iteration where path (currently) only contains 1 item --------- Co-authored-by: Oğuzhan Koral <[email protected]>
- Loading branch information
1 parent
c8ac385
commit 4215f90
Showing
4 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Connectors/Tekla/Speckle.Connector.TeklaShared/HostApp/SendCollectionManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Speckle.Converter.Tekla2024; | ||
using Speckle.Converters.Common; | ||
using Speckle.Sdk.Models.Collections; | ||
|
||
namespace Speckle.Connector.Tekla2024.HostApp; | ||
|
||
public class SendCollectionManager | ||
{ | ||
private readonly IConverterSettingsStore<TeklaConversionSettings> _converterSettings; | ||
private readonly Dictionary<string, Collection> _collectionCache = new(); | ||
|
||
public SendCollectionManager(IConverterSettingsStore<TeklaConversionSettings> converterSettings) | ||
{ | ||
_converterSettings = converterSettings; | ||
} | ||
|
||
public Collection GetAndCreateObjectHostCollection(TSM.ModelObject teklaObject, Collection rootObject) | ||
{ | ||
// Tekla Data Structure: rootObject > objectType > name | ||
// Very high-level, would be good to have sub-groups in future releases | ||
// TODO: Refine further according to section types (for beams), constituent elements (for components) etc. at later stage | ||
var path = teklaObject.GetType().ToString().Split('.').Last(); | ||
|
||
// NOTE: First pass at seeing if a collection key already exists | ||
if (_collectionCache.TryGetValue(path, out Collection? value)) | ||
{ | ||
return value; | ||
} | ||
|
||
// NOTE: As this point, we need to create a suitable collection | ||
// This would be done using a recursive approach to see where to add collection | ||
// However, since data structure is flat, this returns quick (Ref: Revit ;) ) | ||
Collection childCollection = new(path); | ||
rootObject.elements.Add(childCollection); | ||
_collectionCache[path] = childCollection; | ||
|
||
rootObject = childCollection; | ||
|
||
return rootObject; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters