mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Add direction sense and offset support for slabs
This commit is contained in:
@@ -27,6 +27,8 @@ def add_slab_representation(
|
||||
file: ifcopenshell.file,
|
||||
context: ifcopenshell.entity_instance,
|
||||
depth: float = 0.2,
|
||||
direction_sense: str = "POSITIVE",
|
||||
offset: float = 0.0,
|
||||
x_angle: float = 0.0,
|
||||
clippings: Optional[list[Union[Clipping, dict[str, Any]]]] = None,
|
||||
polyline: Optional[list[tuple[float, float]]] = None,
|
||||
@@ -56,6 +58,8 @@ def add_slab_representation(
|
||||
usecase.settings = {
|
||||
"context": context,
|
||||
"depth": depth,
|
||||
"direction_sense": direction_sense,
|
||||
"offset": offset,
|
||||
"x_angle": x_angle,
|
||||
"clippings": clippings if clippings is not None else [],
|
||||
"polyline": polyline,
|
||||
@@ -80,7 +84,7 @@ class Usecase:
|
||||
size = self.convert_si_to_unit(1)
|
||||
points = ((0.0, 0.0), (size, 0.0), (size, size), (0.0, size), (0.0, 0.0))
|
||||
if self.settings["polyline"]:
|
||||
points = [(self.convert_si_to_unit(p[0]), self.convert_si_to_unit(p[1])) for p in self.settings["polyline"]]
|
||||
points = [(self.convert_si_to_unit(p[0]), self.convert_si_to_unit(p[1] * (1 / cos(self.settings["x_angle"])))) for p in self.settings["polyline"]]
|
||||
if self.file.schema == "IFC2X3":
|
||||
curve = self.file.createIfcPolyline([self.file.createIfcCartesianPoint(p) for p in points])
|
||||
else:
|
||||
@@ -94,9 +98,9 @@ class Usecase:
|
||||
|
||||
position = None
|
||||
# default position for IFC2X3 where .Position is not optional
|
||||
if self.file.schema == "IFC2X3":
|
||||
if self.file.schema == "IFC2X3" or self.settings["offset"] != 0:
|
||||
position = self.file.createIfcAxis2Placement3D(
|
||||
self.file.createIfcCartesianPoint((0.0, 0.0, 0.0)),
|
||||
self.file.createIfcCartesianPoint((0.0, 0.0, self.convert_si_to_unit(self.settings["offset"]))),
|
||||
self.file.createIfcDirection((0.0, 0.0, 1.0)),
|
||||
self.file.createIfcDirection((1.0, 0.0, 0.0)),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user