Keep placement axes recalculating profiles #3879

This commit is contained in:
Andrej730
2023-10-16 12:19:18 +05:00
parent e2077c27dd
commit e1b64fba00
2 changed files with 18 additions and 6 deletions
@@ -449,6 +449,16 @@ class DumbProfileJoiner:
"geometry.assign_representation", tool.Ifc.get(), product=element, representation=new_axis "geometry.assign_representation", tool.Ifc.get(), product=element, representation=new_axis
) )
def get_placement_axes(body_representation):
if not body_representation:
return None, None
extrusion = tool.Model.get_extrusion(body_representation)
if not extrusion:
return None, None
position = extrusion.Position
return (position.Axis.DirectionRatios, position.RefDirection.DirectionRatios)
old_body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
new_body = ifcopenshell.api.run( new_body = ifcopenshell.api.run(
"geometry.add_profile_representation", "geometry.add_profile_representation",
tool.Ifc.get(), tool.Ifc.get(),
@@ -457,9 +467,9 @@ class DumbProfileJoiner:
depth=depth, depth=depth,
cardinal_point=usage.CardinalPoint if usage else None, cardinal_point=usage.CardinalPoint if usage else None,
clippings=self.clippings, clippings=self.clippings,
placement_zx_axes=get_placement_axes(old_body),
) )
old_body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
if old_body: if old_body:
for inverse in tool.Ifc.get().get_inverse(old_body): for inverse in tool.Ifc.get().get_inverse(old_body):
ifcopenshell.util.element.replace_attribute(inverse, old_body, new_body) ifcopenshell.util.element.replace_attribute(inverse, old_body, new_body)
@@ -31,6 +31,7 @@ class Usecase:
# Planes are defined as a matrix. The XY plane is the clipping boundary and +Z is removed. # Planes are defined as a matrix. The XY plane is the clipping boundary and +Z is removed.
# [{"type": "IfcBooleanClippingResult", "operand_type": "IfcHalfSpaceSolid", "matrix": [...]}, {...}] # [{"type": "IfcBooleanClippingResult", "operand_type": "IfcHalfSpaceSolid", "matrix": [...]}, {...}]
"clippings": [], # A list of planes that define clipping half space solids "clippings": [], # A list of planes that define clipping half space solids
"placement_zx_axes": (None, None),
} }
for key, value in settings.items(): for key, value in settings.items():
self.settings[key] = value self.settings[key] = value
@@ -46,13 +47,14 @@ class Usecase:
def create_item(self): def create_item(self):
point = self.get_point() point = self.get_point()
placement = self.file.createIfcAxis2Placement3D(
point,
self.file.createIfcDirection(self.settings["placement_zx_axes"][0] or (0.0, 0.0, 1.0)),
self.file.createIfcDirection(self.settings["placement_zx_axes"][1] or (1.0, 0.0, 0.0)),
)
extrusion = self.file.createIfcExtrudedAreaSolid( extrusion = self.file.createIfcExtrudedAreaSolid(
self.settings["profile"], self.settings["profile"],
self.file.createIfcAxis2Placement3D( placement,
point,
self.file.createIfcDirection((0.0, 0.0, 1.0)),
self.file.createIfcDirection((1.0, 0.0, 0.0)),
),
self.file.createIfcDirection((0.0, 0.0, 1.0)), self.file.createIfcDirection((0.0, 0.0, 1.0)),
self.convert_si_to_unit(self.settings["depth"]), self.convert_si_to_unit(self.settings["depth"]),
) )