Skip to content

Commit

Permalink
add AddRelAssignsToGroup
Browse files Browse the repository at this point in the history
add AddRelAggregates
  • Loading branch information
WalchAndreas committed Feb 28, 2025
1 parent 6ea6d25 commit cb10c96
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/Aardvark.Data.Ifc/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 1.1.0-prerelease0010
- Extended IFC cross schema support

### 1.1.0-prerelease0009
- Fixed broken build

Expand Down
15 changes: 14 additions & 1 deletion src/Aardvark.Data.Ifc/XbimExtensions/GroupExt.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;

using System.Linq;
using Xbim.Common;
using Xbim.Ifc4.Interfaces;

Expand Down Expand Up @@ -27,5 +27,18 @@ public static IIfcGroup CreateGroup(this IModel model, string groupName, IEnumer

public static IIfcGroup CreateGroup(this IModel model, string groupName, IEnumerable<IIfcGroup> relatedObjects)
=> model.CreateGroup(groupName, relatedObjects, IfcObjectTypeEnum.GROUP);

public static void AddRelAssignsToGroup(this IIfcObjectDefinition obj, IIfcGroup group, IfcObjectTypeEnum groupEnum = IfcObjectTypeEnum.GROUP)
{
// check for existing RelAssignsToGroup for this group
var grouping = group.IsGroupedBy.FirstOrDefault();

// create relationship
grouping ??= group.Model.Factory().RelAssignsToGroup(g => g.RelatingGroup = group);

// update relationship
grouping.RelatedObjects.Add(obj);
grouping.RelatedObjectsType = groupEnum;
}
}
}
16 changes: 2 additions & 14 deletions src/Aardvark.Data.Ifc/XbimExtensions/Ifc4x3Ext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,8 @@ public static IfcElementQuantity AddQuantity(this IfcObject obj, string property

#region IfcProject

public static void AddSite(this IfcProject proj, IfcSite site)
{
var decomposition = proj.IsDecomposedBy.FirstOrDefault();
if (decomposition == null) //none defined create the relationship
{
var relSub = proj.Model.New<IfcRelAggregates>(relSub =>
{
relSub.RelatingObject = proj;
relSub.RelatedObjects.Add(site);
});
}
else
decomposition.RelatedObjects.Add(site);
}
public static void AddSite(this IfcProject proj, IfcSite site)
=> proj.AddRelAggregates(site);

#endregion
}
Expand Down
12 changes: 12 additions & 0 deletions src/Aardvark.Data.Ifc/XbimExtensions/InterfaceExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,17 @@ public static void SetOrChangeSiUnit(this IIfcUnitAssignment ua, IfcUnitEnum uni
}));
}
}

public static void AddRelAggregates(this IIfcObjectDefinition obj, IIfcObjectDefinition relatingObject)
{
// check for existing RelAggregates for this parent
var decomposition = relatingObject.IsDecomposedBy.FirstOrDefault();

// create relationship
decomposition ??= obj.Model.Factory().RelAggregates(relSub => relSub.RelatingObject = relatingObject);

// update relationship
decomposition.RelatedObjects.Add(obj);
}
}
}
3 changes: 2 additions & 1 deletion src/Aardvark.Data.Ifc/XbimExtensions/PropertiesExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ public static IIfcPropertySet CreatePropertySet(this IModel model, string setNam
p.NominalValue = x.Value switch
{
IIfcValue v => v,
decimal d => (IfcReal) (double) d,
double d => (IfcReal)d,
float r => (IfcReal)r,
int i => (IfcInteger)i,
Expand All @@ -438,7 +439,7 @@ public static IIfcProduct AttachPropertySet(this IIfcProduct o, IIfcPropertySet
return o;
}

public static IIfcPropertySet CreateAttachPropertySet(this IIfcObject o, string setName, Dictionary<string, object> parameters)
public static IIfcPropertySet CreateAttachPropertySet(this IIfcObject o, string setName, IDictionary<string, object> parameters)
{
var set = o.Model.CreatePropertySet(setName, parameters);

Expand Down

0 comments on commit cb10c96

Please sign in to comment.