mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Fix error assigning product to non-text annotations (e.g. dimension)
Error: Python: Traceback (most recent call last):
File "\bonsai\bim\ifc.py", line 443, in execute_ifc_operator
result = getattr(operator, "_execute")(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\bonsai\bim\module\drawing\operator.py", line 2960, in _execute
core.edit_assigned_product(tool.Ifc, tool.Drawing, obj=context.active_object, product=product)
File "\bonsai\core\drawing.py", line 66, in edit_assigned_product
drawing.update_text_value(obj)
File "\bonsai\tool\drawing.py", line 983, in update_text_value
cls.import_text_attributes(obj)
File "\bonsai\tool\drawing.py", line 904, in import_text_attributes
props.font_size = str(text_data["FontSize"])
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user