diff --git a/src/bonsai/bonsai/core/drawing.py b/src/bonsai/bonsai/core/drawing.py index 61e94f1705..f77f771d71 100644 --- a/src/bonsai/bonsai/core/drawing.py +++ b/src/bonsai/bonsai/core/drawing.py @@ -63,7 +63,8 @@ def edit_assigned_product( ifc.run("drawing.unassign_product", relating_product=existing_product, related_object=element) if product: ifc.run("drawing.assign_product", relating_product=product, related_object=element) - drawing.update_text_value(obj) + if drawing.is_annotation_object_type(element, ("TEXT", "TEXT_LEADER")): + drawing.update_text_value(obj) drawing.disable_editing_assigned_product(obj) diff --git a/src/bonsai/bonsai/core/tool.py b/src/bonsai/bonsai/core/tool.py index afa5cd2418..b660226e93 100644 --- a/src/bonsai/bonsai/core/tool.py +++ b/src/bonsai/bonsai/core/tool.py @@ -357,6 +357,7 @@ class Drawing: def import_sheets(cls): pass def import_text_attributes(cls, obj): pass def is_active_drawing(cls, drawing): pass + def is_annotation_object_type(cls, element, object_types): pass def is_camera_orthographic(cls): pass def is_drawing_active(cls): pass def is_editing_sheets(cls): pass diff --git a/src/bonsai/test/core/test_drawing.py b/src/bonsai/test/core/test_drawing.py index 97dfa62220..e97197eff0 100644 --- a/src/bonsai/test/core/test_drawing.py +++ b/src/bonsai/test/core/test_drawing.py @@ -56,17 +56,29 @@ class TestDisableEditingAssignedProduct: class TestEditAssignedProduct: - def test_run(self, ifc, drawing): + def test_text_annotation(self, ifc, drawing): ifc.get_entity("obj").should_be_called().will_return("element") drawing.get_assigned_product("element").should_be_called().will_return("existing_product") ifc.run( "drawing.unassign_product", relating_product="existing_product", related_object="element" ).should_be_called() ifc.run("drawing.assign_product", relating_product="product", related_object="element").should_be_called() + drawing.is_annotation_object_type("element", ("TEXT", "TEXT_LEADER")).should_be_called().will_return(True) drawing.update_text_value("obj").should_be_called() drawing.disable_editing_assigned_product("obj").should_be_called() subject.edit_assigned_product(ifc, drawing, obj="obj", product="product") + def test_non_text_annotation(self, ifc, drawing): + ifc.get_entity("obj").should_be_called().will_return("element") + drawing.get_assigned_product("element").should_be_called().will_return("existing_product") + ifc.run( + "drawing.unassign_product", relating_product="existing_product", related_object="element" + ).should_be_called() + ifc.run("drawing.assign_product", relating_product="product", related_object="element").should_be_called() + drawing.is_annotation_object_type("element", ("TEXT", "TEXT_LEADER")).should_be_called().will_return(False) + drawing.disable_editing_assigned_product("obj").should_be_called() + subject.edit_assigned_product(ifc, drawing, obj="obj", product="product") + class TestLoadSheets: def test_run(self, drawing):