mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 03:33:48 +00:00
Fix bug resetting rotations after editing profile axis
Before - https://imgur.com/a/czjAoSb After - https://imgur.com/a/ajiNcdK
This commit is contained in:
@@ -1013,17 +1013,30 @@ class EditExtrusionAxis(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
obj = context.active_object
|
obj = context.active_object
|
||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
|
||||||
start = obj.matrix_world @ obj.data.vertices[0].co.copy()
|
matrix = obj.matrix_world
|
||||||
end = obj.matrix_world @ obj.data.vertices[1].co.copy()
|
previous_z_axis = matrix.col[2].to_3d().normalized()
|
||||||
|
|
||||||
|
start = matrix @ obj.data.vertices[0].co
|
||||||
|
end = matrix @ obj.data.vertices[1].co
|
||||||
depth = (end - start).length
|
depth = (end - start).length
|
||||||
z_axis = (end - start).normalized()
|
z_axis = (end - start).normalized()
|
||||||
y_axis = Vector((0, 0, 1))
|
|
||||||
# making sure z_axis != y_axis
|
|
||||||
if z_axis == y_axis:
|
|
||||||
y_axis = Vector((0, 1, 0))
|
|
||||||
|
|
||||||
x_axis = y_axis.cross(z_axis).normalized()
|
# if z-axis didn't changed we can just reuse the previous rotation
|
||||||
y_axis = z_axis.cross(x_axis).normalized()
|
if not tool.Cad.are_vectors_equal(previous_z_axis, z_axis):
|
||||||
|
y_axis = Vector((0, 0, 1))
|
||||||
|
# making sure z_axis != y_axis
|
||||||
|
if z_axis == y_axis:
|
||||||
|
y_axis = Vector((0, 1, 0))
|
||||||
|
|
||||||
|
x_axis = y_axis.cross(z_axis).normalized()
|
||||||
|
y_axis = z_axis.cross(x_axis).normalized()
|
||||||
|
|
||||||
|
# update basises
|
||||||
|
matrix.col[0].xyz = x_axis
|
||||||
|
matrix.col[1].xyz = y_axis
|
||||||
|
matrix.col[2].xyz = z_axis
|
||||||
|
|
||||||
|
matrix.translation = start
|
||||||
|
|
||||||
body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
body = ifcopenshell.util.representation.get_representation(element, "Model", "Body", "MODEL_VIEW")
|
||||||
blenderbim.core.geometry.switch_representation(
|
blenderbim.core.geometry.switch_representation(
|
||||||
@@ -1036,16 +1049,6 @@ class EditExtrusionAxis(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
should_sync_changes_first=False,
|
should_sync_changes_first=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
matrix = Matrix(
|
|
||||||
(
|
|
||||||
[x_axis[0], y_axis[0], z_axis[0], start.x],
|
|
||||||
[x_axis[1], y_axis[1], z_axis[1], start.y],
|
|
||||||
[x_axis[2], y_axis[2], z_axis[2], start.z],
|
|
||||||
[0, 0, 0, 1],
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
obj.matrix_world = matrix
|
|
||||||
bpy.context.view_layer.update()
|
bpy.context.view_layer.update()
|
||||||
|
|
||||||
joiner = DumbProfileJoiner()
|
joiner = DumbProfileJoiner()
|
||||||
|
|||||||
Reference in New Issue
Block a user