Fixed issue creating slabs in IFC2X3 #3696

Error traceback is below - it was trying to set IfcExtrudedAreaSolid.Position to None when in IFC2x3 Position wasn't optional, so now in IFC2X3 it's going to have some default position

RuntimeError: Error: Python: Traceback (most recent call last):
  File "\bim\module\model\product.py", line 123, in execute
    return IfcStore.execute_ifc_operator(self, context)
  File "\bim\ifc.py", line 336, in execute_ifc_operator
    result = getattr(operator, "_execute")(context)
  File "\bim\module\model\product.py", line 148, in _execute
    if self.generate_layered_element(ifc_class, relating_type):
  File "\bim\module\model\product.py", line 274, in generate_layered_element
    obj = slab.DumbSlabGenerator(relating_type).generate()
  File "\bim\module\model\slab.py", line 143, in generate
    return self.derive_from_cursor()
  File "\bim\module\model\slab.py", line 147, in derive_from_cursor
    return self.create_slab()
  File "\bim\module\model\slab.py", line 179, in create_slab
    representation = ifcopenshell.api.run(
  File "\libs\site\packages\ifcopenshell\api\__init__.py", line 66, in run
    result = usecase_class(ifc_file, **settings).execute()
  File "\libs\site\packages\ifcopenshell\api\geometry\add_slab_representation.py", line 42, in execute
    [self.create_item()],
  File "\libs\site\packages\ifcopenshell\api\geometry\add_slab_representation.py", line 58, in create_item
    extrusion = self.file.createIfcExtrudedAreaSolid(
  File "\libs\site\packages\ifcopenshell\file.py", line 337, in create_entity
    e[idx] = arg
  File "\libs\site\packages\ifcopenshell\entity_instance.py", line 260, in __setitem__
    self.wrapped_data.setArgumentAsNull(idx)
  File "\libs\site\packages\ifcopenshell\ifcopenshell_wrapper.py", line 4929, in setArgumentAsNull
    return _ifcopenshell_wrapper.entity_instance_setArgumentAsNull(self, i)
RuntimeError: Attribute not set
This commit is contained in:
Andrej730
2023-09-08 17:46:18 +05:00
parent fca90e9b0f
commit d4e4717857
@@ -26,7 +26,7 @@ class Usecase:
self.settings = {
"context": None, # IfcGeometricRepresentationContext
"depth": 0.2,
"x_angle": 0, # Radians
"x_angle": 0, # Radians
# Planes are defined as a matrix. The XY plane is the clipping boundary and +Z is removed.
"clippings": [], # A list of planes that define clipping half space solids
}
@@ -55,9 +55,19 @@ class Usecase:
)
else:
extrusion_direction = self.file.createIfcDirection((0.0, 0.0, 1.0))
position = None
# default position for IFC2X3 where .Position is not optional
if self.file.schema == "IFC2X3":
position = self.file.createIfcAxis2Placement3D(
self.file.createIfcCartesianPoint((0.0, 0.0, 0.0)),
self.file.createIfcDirection((0.0, 0.0, 1.0)),
self.file.createIfcDirection((1.0, 0.0, 0.0)),
)
extrusion = self.file.createIfcExtrudedAreaSolid(
self.file.createIfcArbitraryClosedProfileDef("AREA", None, curve),
None,
position,
extrusion_direction,
self.convert_si_to_unit(self.settings["depth"]) * 1 / cos(self.settings["x_angle"]),
)