mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Fix cost and drawing feature tests
This commit is contained in:
@@ -248,9 +248,7 @@ class Cost(bonsai.core.tool.Cost):
|
|||||||
cls, cost_item: ifcopenshell.entity_instance, related_object_type: RELATED_OBJECT_TYPE
|
cls, cost_item: ifcopenshell.entity_instance, related_object_type: RELATED_OBJECT_TYPE
|
||||||
) -> None:
|
) -> None:
|
||||||
def create_list_items(
|
def create_list_items(
|
||||||
collection: bpy.types.bpy_prop_collection_idprop[bonsai.bim.helper.Attribute],
|
collection: bpy.types.CollectionProperty, cost_item: ifcopenshell.entity_instance, is_deep: bool
|
||||||
cost_item: ifcopenshell.entity_instance,
|
|
||||||
is_deep: bool,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
products = cls.get_cost_item_assignments(cost_item, filter_by_type=related_object_type, is_deep=False)
|
products = cls.get_cost_item_assignments(cost_item, filter_by_type=related_object_type, is_deep=False)
|
||||||
for product in products:
|
for product in products:
|
||||||
|
|||||||
@@ -8,8 +8,12 @@ Scenario: Duplicate drawing
|
|||||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
||||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||||
And I press "bim.assign_class"
|
And I press "bim.assign_class"
|
||||||
And the variable "wall1" is "IfcStore.get_file().by_type('IfcWall')[-1].id()"
|
And I save sample test files
|
||||||
And I press "bim.add_drawing"
|
And I look at the "Drawings" panel
|
||||||
|
And I click "IMPORT"
|
||||||
|
And I click "ADD"
|
||||||
|
And I press "bim.expand_target_view(target_view='PLAN_VIEW')"
|
||||||
|
When I select the "PLAN_VIEW" item in the "BIM_UL_drawinglist" list
|
||||||
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
||||||
When I press "bim.duplicate_drawing(drawing={drawing})"
|
When I press "bim.duplicate_drawing(drawing={drawing})"
|
||||||
Then nothing happens
|
Then nothing happens
|
||||||
@@ -21,12 +25,14 @@ Scenario: Create drawing
|
|||||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
||||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||||
And I press "bim.assign_class"
|
And I press "bim.assign_class"
|
||||||
And the variable "wall1" is "IfcStore.get_file().by_type('IfcWall')[-1].id()"
|
And I save sample test files
|
||||||
And I press "bim.add_drawing"
|
And I look at the "Drawings" panel
|
||||||
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
And I click "IMPORT"
|
||||||
And I set "scene.DocProperties.active_drawing_index" to "0"
|
And I click "ADD"
|
||||||
And I press "bim.activate_drawing(drawing={drawing})"
|
And I press "bim.expand_target_view(target_view='PLAN_VIEW')"
|
||||||
When I press "bim.create_drawing"
|
When I select the "PLAN_VIEW" item in the "BIM_UL_drawinglist" list
|
||||||
|
And I click "OUTLINER_OB_CAMERA"
|
||||||
|
And I click "OUTPUT"
|
||||||
Then nothing happens
|
Then nothing happens
|
||||||
|
|
||||||
Scenario: Create drawing after deleting a duplicated object
|
Scenario: Create drawing after deleting a duplicated object
|
||||||
@@ -36,19 +42,18 @@ Scenario: Create drawing after deleting a duplicated object
|
|||||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
||||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||||
And I press "bim.assign_class"
|
And I press "bim.assign_class"
|
||||||
And the variable "wall1" is "IfcStore.get_file().by_type('IfcWall')[-1].id()"
|
And I duplicate the selected objects
|
||||||
And I press "bim.copy_class(obj='IfcWall/Cube')"
|
And I save sample test files
|
||||||
And the variable "wall2" is "IfcStore.get_file().by_type('IfcWall')[-1].id()"
|
And I look at the "Drawings" panel
|
||||||
And I press "bim.load_drawings"
|
And I click "IMPORT"
|
||||||
# And I set "scene.DocProperties.location_hint" to "('My Storey', 'My Storey', '')"
|
And I click "ADD"
|
||||||
And I press "bim.add_drawing"
|
And I press "bim.expand_target_view(target_view='PLAN_VIEW')"
|
||||||
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
And I select the "PLAN_VIEW" item in the "BIM_UL_drawinglist" list
|
||||||
And I set "scene.DocProperties.active_drawing_index" to "0"
|
And I click "OUTLINER_OB_CAMERA"
|
||||||
And I press "bim.activate_drawing(drawing={drawing})"
|
And I click "OUTPUT"
|
||||||
And I press "bim.create_drawing"
|
|
||||||
And the object "IfcWall/Cube" is selected
|
And the object "IfcWall/Cube" is selected
|
||||||
And I press "object.delete(use_global=False)"
|
And I delete the selected objects
|
||||||
When I press "bim.create_drawing"
|
When I click "OUTPUT"
|
||||||
Then nothing happens
|
Then nothing happens
|
||||||
|
|
||||||
Scenario: Activate drawing preserves visibility for non-ifc objects
|
Scenario: Activate drawing preserves visibility for non-ifc objects
|
||||||
@@ -57,10 +62,13 @@ Scenario: Activate drawing preserves visibility for non-ifc objects
|
|||||||
And I add a cube
|
And I add a cube
|
||||||
And the object "Cube" is visible
|
And the object "Cube" is visible
|
||||||
And the object "Cube.001" is not visible
|
And the object "Cube.001" is not visible
|
||||||
And I press "bim.add_drawing"
|
And I save sample test files
|
||||||
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
And I look at the "Drawings" panel
|
||||||
And I set "scene.DocProperties.active_drawing_index" to "0"
|
And I click "IMPORT"
|
||||||
When I press "bim.activate_drawing(drawing={drawing})"
|
And I click "ADD"
|
||||||
|
And I press "bim.expand_target_view(target_view='PLAN_VIEW')"
|
||||||
|
And I select the "PLAN_VIEW" item in the "BIM_UL_drawinglist" list
|
||||||
|
And I click "OUTLINER_OB_CAMERA"
|
||||||
Then the object "Cube" is visible
|
Then the object "Cube" is visible
|
||||||
And the object "Cube.001" is not visible
|
And the object "Cube.001" is not visible
|
||||||
|
|
||||||
@@ -68,10 +76,13 @@ Scenario: Activate drawing preserves selection
|
|||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
And I add a cube
|
And I add a cube
|
||||||
And the object "Cube" is selected
|
And the object "Cube" is selected
|
||||||
And I press "bim.add_drawing"
|
And I save sample test files
|
||||||
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
And I look at the "Drawings" panel
|
||||||
And I set "scene.DocProperties.active_drawing_index" to "0"
|
And I click "IMPORT"
|
||||||
When I press "bim.activate_drawing(drawing={drawing})"
|
And I click "ADD"
|
||||||
|
And I press "bim.expand_target_view(target_view='PLAN_VIEW')"
|
||||||
|
And I select the "PLAN_VIEW" item in the "BIM_UL_drawinglist" list
|
||||||
|
When I click "OUTLINER_OB_CAMERA"
|
||||||
Then the object "Cube" is selected
|
Then the object "Cube" is selected
|
||||||
|
|
||||||
Scenario: Remove drawing
|
Scenario: Remove drawing
|
||||||
@@ -81,10 +92,14 @@ Scenario: Remove drawing
|
|||||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
||||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||||
And I press "bim.assign_class"
|
And I press "bim.assign_class"
|
||||||
And the variable "wall1" is "IfcStore.get_file().by_type('IfcWall')[-1].id()"
|
And I save sample test files
|
||||||
And I press "bim.add_drawing"
|
And I look at the "Drawings" panel
|
||||||
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
And I click "IMPORT"
|
||||||
And the collection "IfcAnnotation/PLAN_VIEW" exists
|
And I click "ADD"
|
||||||
|
And I press "bim.expand_target_view(target_view='PLAN_VIEW')"
|
||||||
|
And I select the "PLAN_VIEW" item in the "BIM_UL_drawinglist" list
|
||||||
|
When I click "OUTLINER_OB_CAMERA"
|
||||||
|
Then the collection "IfcAnnotation/PLAN_VIEW" exists
|
||||||
When I press "bim.remove_drawing(drawing={drawing})"
|
When I press "bim.remove_drawing(drawing={drawing})"
|
||||||
Then the collection "IfcAnnotation/PLAN_VIEW" does not exist
|
Then the collection "IfcAnnotation/PLAN_VIEW" does not exist
|
||||||
|
|
||||||
@@ -95,7 +110,6 @@ Scenario: Remove drawing - via object deletion
|
|||||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
||||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||||
And I press "bim.assign_class"
|
And I press "bim.assign_class"
|
||||||
And the variable "wall1" is "IfcStore.get_file().by_type('IfcWall')[-1].id()"
|
|
||||||
And I press "bim.add_drawing"
|
And I press "bim.add_drawing"
|
||||||
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
||||||
And the collection "IfcAnnotation/PLAN_VIEW" exists
|
And the collection "IfcAnnotation/PLAN_VIEW" exists
|
||||||
@@ -110,12 +124,13 @@ Scenario: Remove drawing - deleting active drawing
|
|||||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
|
||||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||||
And I press "bim.assign_class"
|
And I press "bim.assign_class"
|
||||||
And the variable "wall1" is "IfcStore.get_file().by_type('IfcWall')[-1].id()"
|
And I save sample test files
|
||||||
And I press "bim.add_drawing"
|
And I look at the "Drawings" panel
|
||||||
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
|
And I click "IMPORT"
|
||||||
And the collection "IfcAnnotation/PLAN_VIEW" exists
|
And I click "ADD"
|
||||||
And I set "scene.DocProperties.active_drawing_index" to "0"
|
And I press "bim.expand_target_view(target_view='PLAN_VIEW')"
|
||||||
And I press "bim.activate_drawing(drawing={drawing})"
|
And I select the "PLAN_VIEW" item in the "BIM_UL_drawinglist" list
|
||||||
|
And I click "OUTLINER_OB_CAMERA"
|
||||||
When the object "IfcAnnotation/PLAN_VIEW" is selected
|
When the object "IfcAnnotation/PLAN_VIEW" is selected
|
||||||
And I press "bim.override_object_delete"
|
And I delete the selected objects
|
||||||
Then the collection "IfcAnnotation/PLAN_VIEW" does not exist
|
Then the collection "IfcAnnotation/PLAN_VIEW" does not exist
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class PanelSpy:
|
|||||||
return self
|
return self
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
if self.spied_attr in ("row", "column", "box"):
|
if self.spied_attr in ("row", "column", "box", "separator"):
|
||||||
return self
|
return self
|
||||||
elif self.spied_attr == "template_list":
|
elif self.spied_attr == "template_list":
|
||||||
listtype_name, list_id, dataptr, propname, active_dataptr, active_propname = args
|
listtype_name, list_id, dataptr, propname, active_dataptr, active_propname = args
|
||||||
@@ -334,6 +334,7 @@ def the_name_list_has_total_items(name, total):
|
|||||||
assert False, f"List {name} not found in {panel_spy.spied_lists}"
|
assert False, f"List {name} not found in {panel_spy.spied_lists}"
|
||||||
|
|
||||||
|
|
||||||
|
@given(parsers.parse('I select the "{item_name}" item in the "{list_name}" list'))
|
||||||
@when(parsers.parse('I select the "{item_name}" item in the "{list_name}" list'))
|
@when(parsers.parse('I select the "{item_name}" item in the "{list_name}" list'))
|
||||||
def i_select_the_item_name_item_in_the_list_name_list(item_name, list_name):
|
def i_select_the_item_name_item_in_the_list_name_list(item_name, list_name):
|
||||||
panel_spy.refresh_spy()
|
panel_spy.refresh_spy()
|
||||||
@@ -511,6 +512,7 @@ def i_evaluate_expression(expression):
|
|||||||
exec(expression)
|
exec(expression)
|
||||||
|
|
||||||
|
|
||||||
|
@given("I duplicate the selected objects")
|
||||||
@when("I duplicate the selected objects")
|
@when("I duplicate the selected objects")
|
||||||
def i_duplicate_the_selected_objects():
|
def i_duplicate_the_selected_objects():
|
||||||
bpy.ops.bim.override_object_duplicate_move()
|
bpy.ops.bim.override_object_duplicate_move()
|
||||||
@@ -635,6 +637,7 @@ def i_am_on_frame_number(number):
|
|||||||
bpy.context.scene.frame_set(int(number))
|
bpy.context.scene.frame_set(int(number))
|
||||||
|
|
||||||
|
|
||||||
|
@given("I delete the selected objects")
|
||||||
@when("I delete the selected objects")
|
@when("I delete the selected objects")
|
||||||
def i_delete_the_selected_objects():
|
def i_delete_the_selected_objects():
|
||||||
bpy.ops.bim.override_object_delete()
|
bpy.ops.bim.override_object_delete()
|
||||||
@@ -1349,7 +1352,6 @@ def run_test_code():
|
|||||||
@then(parsers.parse("I save sample test files"))
|
@then(parsers.parse("I save sample test files"))
|
||||||
def saving_sample_test_files(and_open_in_blender=None):
|
def saving_sample_test_files(and_open_in_blender=None):
|
||||||
filepath = f"{variables['cwd']}/test/files/temp/sample_test_file"
|
filepath = f"{variables['cwd']}/test/files/temp/sample_test_file"
|
||||||
blend_filepath = f"{filepath}.blend"
|
|
||||||
bpy.ops.bim.save_project(filepath=f"{filepath}.ifc", should_save_as=True)
|
bpy.ops.bim.save_project(filepath=f"{filepath}.ifc", should_save_as=True)
|
||||||
bpy.ops.wm.save_as_mainfile(filepath=f"{filepath}.blend")
|
bpy.ops.wm.save_as_mainfile(filepath=f"{filepath}.blend")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user