Skip to content

Commit

Permalink
Back merge dev -> main (#3611)
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-Morgan authored Aug 8, 2024
2 parents b65c3fa + 0ec1f10 commit 149d35e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "CreateCommand.hpp"
#include "LibpartImportManager.hpp"
#include "ClassificationImportManager.hpp"
#include "APIHelper.hpp"
#include "FieldNames.hpp"
#include "OnExit.hpp"
#include "ExchangeManager.hpp"
Expand Down Expand Up @@ -123,6 +124,8 @@ GS::ObjectState CreateCommand::Execute (const GS::ObjectState& parameters, GS::P
parameters.Get (GetFieldName (), objectStates);

ACAPI_CallUndoableCommand (GetUndoableCommandName (), [&] () -> GSErrCode {
LibraryHelper helper (false);

GS::Array<GS::ObjectState> applicationObjects;

AttributeManager* attributeManager = AttributeManager::GetInstance ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "RealNumber.h"
#include "DGModule.hpp"
#include "LibpartImportManager.hpp"
#include "APIHelper.hpp"
#include "FieldNames.hpp"
#include "OnExit.hpp"
#include "ExchangeManager.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "CreateGridElement.hpp"
#include "ResourceIds.hpp"
#include "ObjectState.hpp"
#include "APIHelper.hpp"
#include "Utility.hpp"
#include "Objects/Level.hpp"
#include "Objects/Point.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "CreateObject.hpp"

#include "APIMigrationHelper.hpp"
#include "APIHelper.hpp"
#include "LibpartImportManager.hpp"
#include "ResourceIds.hpp"
#include "Utility.hpp"
Expand Down Expand Up @@ -130,6 +131,8 @@ GS::ObjectState CreateObject::Execute (const GS::ObjectState& parameters, GS::Pr
parameters.Get (FieldNames::MeshModels, meshModels);

ACAPI_CallUndoableCommand (GetUndoableCommandName (), [&] () -> GSErrCode {
LibraryHelper helper (false);

AttributeManager* attributeManager = AttributeManager::GetInstance ();
LibpartImportManager* libpartImportManager = LibpartImportManager::GetInstance ();
for (ModelInfo meshModel : meshModels) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "RealNumber.h"
#include "DGModule.hpp"
#include "LibpartImportManager.hpp"
#include "APIHelper.hpp"
#include "FieldNames.hpp"
#include "OnExit.hpp"
#include "ExchangeManager.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "RealNumber.h"
#include "DGModule.hpp"
#include "LibpartImportManager.hpp"
#include "APIHelper.hpp"
#include "FieldNames.hpp"
#include "OnExit.hpp"
#include "ExchangeManager.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,12 @@ private HashSet<ModelItem> GetObjectsFromSavedSets()

// Saved Sets filter stores Guids of the selection sets. This can be converted to ModelItem pseudoIds
var selections = _filter.Selection.Select(guid => new Guid(guid)).ToList();
var savedItems = selections.Select(Application.ActiveDocument.SelectionSets.ResolveGuid).OfType<SelectionSet>();

// Resolve the saved items and extract the inner selection sets when folder items are encountered
var savedItems = selections
.Select(guid => Application.ActiveDocument.SelectionSets.ResolveGuid(guid))
.SelectMany(ExtractSelectionSets)
.ToList();

foreach (var item in savedItems)
{
Expand All @@ -308,6 +313,45 @@ private HashSet<ModelItem> GetObjectsFromSavedSets()
return _uniqueModelItems;
}

/// <summary>
/// Recursively extracts SelectionSet objects from the given item.
/// </summary>
/// <param name="selection">The object to extract SelectionSets from. Can be a SelectionSet, FolderItem, or any other object.</param>
/// <returns>An IEnumerable of SelectionSet objects extracted from the item and its children (if applicable).</returns>
/// <exception cref="ArgumentNullException">Thrown if the input item is null.</exception>
static IEnumerable<SelectionSet> ExtractSelectionSets(object selection)
{
if (selection == null)
{
throw new ArgumentNullException(nameof(selection), "Input item cannot be null.");
}

switch (selection)
{
case SelectionSet selectionSet:
yield return selectionSet;
break;
case FolderItem folderItem:
if (folderItem.Children == null)
{
yield break;
}
foreach (var childItem in folderItem.Children)
{
if (childItem == null)
{
continue;
}

foreach (var extractedSet in ExtractSelectionSets(childItem))
{
yield return extractedSet;
}
}
break;
}
}

/// <summary>
/// Populates the hierarchy by adding ancestor and descendant items to the unique model items.
/// The unique model items have already been processed to validate that they are not hidden.
Expand Down

0 comments on commit 149d35e

Please sign in to comment.