mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
Fix bug where using the alignment tool broke on flipped non-LAYER2 objects
The alignment tool was initially designed specifically for LAYER2 objects. It doesn't have to be, so now LAYER2 is a special case where it may have its baselines and sidelines aligned whereas non-LAYER2 objects simply align based on bbox.
This commit is contained in:
@@ -367,17 +367,22 @@ class DumbWallAligner:
|
|||||||
self.align_rotation()
|
self.align_rotation()
|
||||||
|
|
||||||
if self.is_rotation_flipped():
|
if self.is_rotation_flipped():
|
||||||
DumbWallJoiner().flip(self.wall)
|
element = tool.Ifc.get_entity(self.wall)
|
||||||
bpy.context.view_layer.update()
|
if tool.Model.get_usage_type(element) == "LAYER2":
|
||||||
|
DumbWallJoiner().flip(self.wall)
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[3])
|
||||||
|
else:
|
||||||
|
snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[0])
|
||||||
|
else:
|
||||||
|
snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[3])
|
||||||
|
|
||||||
start = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[3])
|
start = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[3])
|
||||||
end = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[7])
|
end = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[7])
|
||||||
|
|
||||||
snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[3])
|
|
||||||
offset = snap_point - self.wall.matrix_world.translation
|
|
||||||
|
|
||||||
point, _ = mathutils.geometry.intersect_point_line(snap_point, start, end)
|
point, _ = mathutils.geometry.intersect_point_line(snap_point, start, end)
|
||||||
|
|
||||||
|
offset = snap_point - self.wall.matrix_world.translation
|
||||||
new_origin = point - offset
|
new_origin = point - offset
|
||||||
self.wall.matrix_world.translation[0], self.wall.matrix_world.translation[1] = new_origin.xy
|
self.wall.matrix_world.translation[0], self.wall.matrix_world.translation[1] = new_origin.xy
|
||||||
|
|
||||||
@@ -385,17 +390,22 @@ class DumbWallAligner:
|
|||||||
self.align_rotation()
|
self.align_rotation()
|
||||||
|
|
||||||
if self.is_rotation_flipped():
|
if self.is_rotation_flipped():
|
||||||
DumbWallJoiner().flip(self.wall)
|
element = tool.Ifc.get_entity(self.wall)
|
||||||
bpy.context.view_layer.update()
|
if tool.Model.get_usage_type(element) == "LAYER2":
|
||||||
|
DumbWallJoiner().flip(self.wall)
|
||||||
|
bpy.context.view_layer.update()
|
||||||
|
snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[0])
|
||||||
|
else:
|
||||||
|
snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[3])
|
||||||
|
else:
|
||||||
|
snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[0])
|
||||||
|
|
||||||
start = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[0])
|
start = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[0])
|
||||||
end = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[4])
|
end = self.reference_wall.matrix_world @ Vector(self.reference_wall.bound_box[4])
|
||||||
|
|
||||||
snap_point = self.wall.matrix_world @ Vector(self.wall.bound_box[0])
|
|
||||||
offset = snap_point - self.wall.matrix_world.translation
|
|
||||||
|
|
||||||
point, _ = mathutils.geometry.intersect_point_line(snap_point, start, end)
|
point, _ = mathutils.geometry.intersect_point_line(snap_point, start, end)
|
||||||
|
|
||||||
|
offset = snap_point - self.wall.matrix_world.translation
|
||||||
new_origin = point - offset
|
new_origin = point - offset
|
||||||
self.wall.matrix_world.translation[0], self.wall.matrix_world.translation[1] = new_origin.xy
|
self.wall.matrix_world.translation[0], self.wall.matrix_world.translation[1] = new_origin.xy
|
||||||
|
|
||||||
@@ -842,7 +852,7 @@ class DumbWallJoiner:
|
|||||||
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=wall1)
|
blenderbim.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=wall1)
|
||||||
|
|
||||||
element1 = tool.Ifc.get_entity(wall1)
|
element1 = tool.Ifc.get_entity(wall1)
|
||||||
if not element1:
|
if not element1 or tool.Model.get_usage_type(element1) != "LAYER2":
|
||||||
return
|
return
|
||||||
|
|
||||||
for rel in element1.ConnectedTo:
|
for rel in element1.ConnectedTo:
|
||||||
|
|||||||
Reference in New Issue
Block a user