@@ -30,12 +30,27 @@ internal static List<IfcProduct> ToIfcProducts(this Element e,
30
30
if ( e is ElementInstance )
31
31
{
32
32
// If we're using an element instance, get the transform
33
- // and the id and use those to uniquely position and
33
+ // and the id and use those to uniquely position and
34
34
// identify the element.
35
35
var instance = ( ElementInstance ) e ;
36
36
geoElement = instance . BaseDefinition ;
37
37
id = instance . Id ;
38
38
trans = instance . Transform ;
39
+
40
+ if ( geoElement is IHasOpenings geoElementWithOpenings )
41
+ {
42
+ for ( int i = 0 ; i < geoElementWithOpenings . Openings . Count ; i ++ )
43
+ {
44
+ Opening opening = geoElementWithOpenings . Openings [ i ] ;
45
+ var transform = opening . Transform . Concatenated ( trans ) ;
46
+ var newOpening = new Opening ( opening . Perimeter , opening . DepthFront , opening . DepthBack , transform ,
47
+ opening . Representation , opening . IsElementDefinition , default , opening . Name ) ;
48
+
49
+ ToIfcProducts ( newOpening , context , doc , styleAssignments , updateElementRepresentation ) ;
50
+
51
+ geoElementWithOpenings . Openings [ i ] = newOpening ;
52
+ }
53
+ }
39
54
}
40
55
else if ( e is GeometricElement )
41
56
{
@@ -75,17 +90,17 @@ internal static List<IfcProduct> ToIfcProducts(this Element e,
75
90
if ( op is Sweep sweep )
76
91
{
77
92
78
- // Neither of these entities, which are part of the
79
- // IFC4 specification, and which would allow a sweep
80
- // along a curve, are supported by many applications
93
+ // Neither of these entities, which are part of the
94
+ // IFC4 specification, and which would allow a sweep
95
+ // along a curve, are supported by many applications
81
96
// which are supposedly IFC4 compliant (Revit). For
82
97
// Those applications where these entities appear,
83
- // the rotation of the profile is often wrong or
98
+ // the rotation of the profile is often wrong or
84
99
// inconsistent.
85
100
// geom = sweep.ToIfcSurfaceCurveSweptAreaSolid(doc);
86
101
// geom = sweep.ToIfcFixedReferenceSweptAreaSolid(geoElement.Transform, doc);
87
102
88
- // Instead, we'll divide the curve and create a set of
103
+ // Instead, we'll divide the curve and create a set of
89
104
// linear extrusions instead.
90
105
Polyline pline ;
91
106
if ( sweep . Curve is Line )
@@ -169,7 +184,7 @@ internal static List<IfcProduct> ToIfcProducts(this Element e,
169
184
170
185
// If the element has openings, make opening relationships in
171
186
// the IfcElement.
172
- if ( e is IHasOpenings openings )
187
+ if ( geoElement is IHasOpenings openings )
173
188
{
174
189
if ( openings . Openings . Count > 0 )
175
190
{
@@ -232,7 +247,7 @@ private static IfcDoorTypeOperationEnum GetIfcDoorTypeOperation(this Door door)
232
247
{
233
248
if ( door . OpeningType == DoorOpeningType . SingleSwing )
234
249
{
235
- switch ( door . OpeningSide )
250
+ switch ( door . OpeningSide )
236
251
{
237
252
case DoorOpeningSide . LeftHand :
238
253
return IfcDoorTypeOperationEnum . SINGLE_SWING_LEFT ;
@@ -241,7 +256,7 @@ private static IfcDoorTypeOperationEnum GetIfcDoorTypeOperation(this Door door)
241
256
case DoorOpeningSide . DoubleDoor :
242
257
return IfcDoorTypeOperationEnum . DOUBLE_DOOR_SINGLE_SWING ;
243
258
}
244
- }
259
+ }
245
260
else if ( door . OpeningType == DoorOpeningType . DoubleSwing )
246
261
{
247
262
switch ( door . OpeningSide )
@@ -274,7 +289,9 @@ internal static IfcLocalPlacement ToIfcLocalPlacement(this Transform transform,
274
289
275
290
internal static IfcExtrudedAreaSolid ToIfcExtrudedAreaSolid ( this Extrude extrude , Document doc )
276
291
{
277
- var position = new Transform ( ) . ToIfcAxis2Placement3D ( doc ) ;
292
+ // Add local transform to the IFC placement
293
+ var transform = extrude . LocalTransform ?? new Transform ( ) ;
294
+ var position = transform . ToIfcAxis2Placement3D ( doc ) ;
278
295
279
296
var extrudeDepth = extrude . Height ;
280
297
var extrudeProfile = extrude . Profile . Perimeter . ToIfcArbitraryClosedProfileDef ( doc ) ;
@@ -301,7 +318,7 @@ private static IfcBoundedCurve ToIfcCurve(this ICurve curve, Document doc)
301
318
{
302
319
return arc . ToIfcTrimmedCurve ( doc ) ;
303
320
}
304
- // Test Polygon before Polyline to avoid
321
+ // Test Polygon before Polyline to avoid
305
322
// Polygons being treated as Polylines.
306
323
else if ( curve is Polygon polygon )
307
324
{
@@ -527,7 +544,7 @@ private static IfcSlab ToIfc(this Floor floor, Guid id,
527
544
}
528
545
529
546
// TODO: There is a lot of duplicate code used to create products.
530
- // Can we make a generic method like ToIfc<TProduct>()? There are
547
+ // Can we make a generic method like ToIfc<TProduct>()? There are
531
548
// exceptions for which this won't work like IfcSpace.
532
549
533
550
private static IfcSpace ToIfc ( this Space space , Guid id ,
0 commit comments