Compare commits

...

2 Commits

Author SHA1 Message Date
Ryan Schultz 85ae25cd3c Import BoxAlignment into alignment props on edit enable
When enabling text editing, align_vertical and
align_horizontal were not populated from the existing
IFC BoxAlignment value, causing them to revert to
their Blender property defaults.

Generated with the assistance of an AI coding tool.
2026-02-24 11:04:14 -06:00
Ryan Schultz 742debb8f1 Fix #7712: Fix text annotation alignment not saved on edit
edit_text was missing a call to edit_text_alignment,
so align_vertical/align_horizontal prop changes were
never exported to IFC.

Additionally, edit_text_alignment was called before
edit_text_literals, which deletes and recreates the
IFC literal entities — discarding the alignment change
immediately. Moved the call to after edit_text_literals.

EditText operator was also being replayed by Blender's
undo/register stack with stale prop values, overwriting
the correct alignment. Guarded _execute with is_editing
to make replayed calls no-ops.

Also fixed a ValueError in is_camera_moved where
np_frombuffer_legacy returns a flat (9,) array but the
rotation dot product requires (3,3). Fixed with reshape.

Generated with the assistance of an AI coding tool.
2026-02-24 07:51:32 -06:00
4 changed files with 17 additions and 3 deletions
@@ -1788,7 +1788,7 @@ class CutDecorator:
# Handle both old float64 and new float32 checksums for version compatibility
rot_checksum_bytes: bytes = eval(DecoratorData.camera_rotation_checksum)
rot_check = tool.Blender.np_frombuffer_legacy(rot_checksum_bytes, 9)
rot_check = tool.Blender.np_frombuffer_legacy(rot_checksum_bytes, 9).reshape(3, 3)
rot_real = tool.Blender.np_array_legacy(obj.matrix_world.to_3x3())
rot_dot = np.dot(rot_check, rot_real.T)
angle_rad = np.arccos(np.clip((np.trace(rot_dot) - 1) / 2, -1, 1))
@@ -3185,7 +3185,10 @@ class EditText(bpy.types.Operator, tool.Ifc.Operator):
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
core.edit_text(tool.Drawing, obj=tool.Blender.get_active_object())
obj = tool.Blender.get_active_object()
if not tool.Drawing.get_text_props(obj).is_editing:
return
core.edit_text(tool.Drawing, obj=obj)
tool.Blender.update_viewport()
+1
View File
@@ -44,6 +44,7 @@ def edit_text(drawing: type[tool.Drawing], obj: bpy.types.Object) -> None:
drawing.edit_text_wrap_length(obj, drawing.export_wrap_length(obj))
drawing.edit_text_symbol(obj, drawing.export_symbol(obj))
drawing.edit_text_literals(obj, literal_attributes)
drawing.edit_text_alignment(obj, drawing.export_alignment(obj))
drawing.disable_editing_text(obj)
+11 -1
View File
@@ -1185,7 +1185,7 @@ class Drawing(bonsai.core.tool.Drawing):
ifc_literals = cls.get_text_literal(obj, return_list=True)
assert isinstance(ifc_literals, list)
for ifc_literal in ifc_literals:
for i, ifc_literal in enumerate(ifc_literals):
literal_props = props.literals.add()
bonsai.bim.helper.import_attributes(ifc_literal, literal_props.attributes)
@@ -1196,6 +1196,16 @@ class Drawing(bonsai.core.tool.Drawing):
literal_props.box_alignment = box_alignment_mask # pyright: ignore[reportAttributeAccessIssue]
literal_props.ifc_definition_id = ifc_literal.id()
if i == 0:
if position_string == "center":
props.align_vertical = "middle"
props.align_horizontal = "middle"
else:
parts = position_string.split("-")
if len(parts) == 2:
props.align_vertical = parts[0]
props.align_horizontal = parts[1]
from bonsai.bim.module.drawing.data import DecoratorData
text_data = DecoratorData.get_text_data(obj)