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

Back merge dev -> main #3611

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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