Skip to content

Commit

Permalink
🐛 CompSec with same name issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lorinczandrea committed Oct 21, 2024
1 parent db17efb commit c4420c9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions FemDesign.Core/Model/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using FemDesign.GenericClasses;
using FemDesign.LibraryItems;
using FemDesign.Loads;
using FemDesign.Composites;

namespace FemDesign
{
Expand Down Expand Up @@ -772,10 +773,13 @@ private void AddCompositeSection(Composites.ComplexComposite obj, bool overwrite
{
inModel = this.Composites.CompositeSection.Any(x => x.Guid == complexCompositePart.CompositeSectionRef);

// check section name
var names = this.Composites.CompositeSection.Select(c => c.ParameterDictionary[FemDesign.Composites.CompositeSectionParameterType.Name]).ToList();
// check section names
Dictionary<string, Guid> guidDir = this.Composites.CompositeSection.ToDictionary(cs => cs.ParameterDictionary[CompositeSectionParameterType.Name], cs => cs.Guid);
var objName = complexCompositePart.CompositeSectionObj.ParameterDictionary[FemDesign.Composites.CompositeSectionParameterType.Name];
if (names.Any(n => String.Equals(n, objName)))
var objGuid = complexCompositePart.CompositeSectionObj.Guid;

// Check if a section with the same name exists but with a different GUID
if (guidDir.TryGetValue(objName, out var existingGuid) && objGuid != existingGuid)
throw new Exception("One or more composite sections have the same name. Different composite sections must have different names!");
}
else
Expand Down

0 comments on commit c4420c9

Please sign in to comment.