fixed issue adding bend between segments located at the same point

also added some tests
This commit is contained in:
Andrej730
2023-11-14 17:18:57 +05:00
parent e8aa8c44e5
commit c6454803ee
4 changed files with 106 additions and 31 deletions
+62 -2
View File
@@ -530,6 +530,7 @@ Scenario: Create a MEP transition
Given an empty IFC project
And I create default MEP types
And the variable "element_types" is "[str(e.id()) for e in {ifc}.by_type('IfcDuctSegmentType')]"
And I set "scene.BIMModelProperties.relating_type_id" to "{element_types}[0]"
And I press "bim.add_constr_type_instance"
And I rename the object "IfcDuctSegment/DuctSegment" to "IfcDuctSegment/RectSegment"
@@ -542,11 +543,70 @@ Scenario: Create a MEP transition
And the object "IfcDuctSegment/CircleSegment" is moved to "2.5,0,0"
And the object "IfcDuctSegment/CircleSegment" is selected
And additionally the object "IfcDuctSegment/RectSegment" is selected
And I press "bim.mep_add_transition()"
And I press "bim.mep_add_transition"
Then the object "IfcDuctSegment/RectSegment" is at "0,0,0"
Then the object "IfcDuctFitting/DuctFitting" exists
And the object "IfcDuctFittingType/Transition" exists
And the object "IfcDuctSegment/RectSegment" is at "0,0,0"
And the object "IfcDuctSegment/RectSegment" dimensions are "0.4,0.2,2.370096"
And the object "IfcDuctSegment/CircleSegment" is at "3.1299,0,0"
And the object "IfcDuctSegment/CircleSegment" dimensions are "0.1000, 0.09927, 2.370096"
And the object "IfcDuctFitting/DuctFitting" is at "2.370096, 0.0000, 0.0000"
And the object "IfcDuctFitting/DuctFitting" dimensions are "0.4000, 0.2000, 0.759807"
Scenario: Create a MEP bend between intersecting with different locations
Given an empty IFC project
And I create default MEP types
And the variable "element_types" is "[str(e.id()) for e in {ifc}.by_type('IfcDuctSegmentType')]"
And I set "scene.BIMModelProperties.relating_type_id" to "{element_types}[0]"
And I set "scene.BIMModelProperties.extrusion_depth" to "5.0"
And I press "bim.add_constr_type_instance"
And I rename the object "IfcDuctSegment/DuctSegment" to "IfcDuctSegment/Seg1"
And I set "scene.BIMModelProperties.relating_type_id" to "{element_types}[0]"
And I press "bim.add_constr_type_instance"
And I rename the object "IfcDuctSegment/DuctSegment" to "IfcDuctSegment/Seg2"
And the object "IfcDuctSegment/Seg2" is rotated by "0,0,90" deg
And the object "IfcDuctSegment/Seg2" is moved to "6,1,1"
And the object "IfcDuctSegment/Seg1" is selected
And additionally the object "IfcDuctSegment/Seg2" is selected
And I press "bim.mep_add_bend"
Then the object "IfcDuctFitting/DuctFitting" exists
And the object "IfcDuctFittingType/Bend" exists
And the object "IfcDuctSegment/Seg1" is at "0,0,1.0"
And the object "IfcDuctSegment/Seg1" dimensions are "0.4,0.2,5.5"
And the object "IfcDuctSegment/Seg2" is at "6.0,0.5,1.0"
And the object "IfcDuctSegment/Seg2" dimensions are "0.4,0.2,5.5"
And the object "IfcDuctFitting/DuctFitting" is at "6.0, 0.5, 1.0"
And the object "IfcDuctFitting/DuctFitting" dimensions are "0.7, 0.2, 0.7"
Scenario: Create a MEP bend between intersecting segments at the same location
Given an empty IFC project
And I create default MEP types
And the variable "element_types" is "[str(e.id()) for e in {ifc}.by_type('IfcDuctSegmentType')]"
And I set "scene.BIMModelProperties.relating_type_id" to "{element_types}[0]"
And I set "scene.BIMModelProperties.extrusion_depth" to "5.0"
And I press "bim.add_constr_type_instance"
And I rename the object "IfcDuctSegment/DuctSegment" to "IfcDuctSegment/Seg1"
And I set "scene.BIMModelProperties.relating_type_id" to "{element_types}[0]"
And I press "bim.add_constr_type_instance"
And I rename the object "IfcDuctSegment/DuctSegment" to "IfcDuctSegment/Seg2"
And the object "IfcDuctSegment/Seg2" is rotated by "0,0,90" deg
And the object "IfcDuctSegment/Seg1" is selected
And additionally the object "IfcDuctSegment/Seg2" is selected
And I press "bim.mep_add_bend"
Then the object "IfcDuctFitting/DuctFitting" exists
And the object "IfcDuctFittingType/Bend" exists
And the object "IfcDuctSegment/Seg1" is at "0.5,0,1.0"
And the object "IfcDuctSegment/Seg1" dimensions are "0.4,0.2,4.5"
And the object "IfcDuctSegment/Seg2" is at "0.0,0.5,1.0"
And the object "IfcDuctSegment/Seg2" dimensions are "0.4,0.2,4.5"
And the object "IfcDuctFitting/DuctFitting" is at "0.0, 0.5, 1.0"
And the object "IfcDuctFitting/DuctFitting" dimensions are "0.7, 0.2, 0.7"
+14 -3
View File
@@ -28,6 +28,7 @@ from blenderbim.tool.brick import BrickStore
from blenderbim.bim.module.model.data import AuthoringData
from pytest_bdd import scenarios, given, when, then, parsers
from mathutils import Vector
from math import radians
scenarios("feature")
@@ -241,13 +242,23 @@ def then_the_object_name_is_selected(name):
assert obj in bpy.context.selected_objects
@given(parsers.parse('the object "{name}" is rotated by "{rotation_deg}" deg'))
@when(parsers.parse('the object "{name}" is rotated by "{rotation_deg}" deg'))
def the_object_name_is_rotated_by(name, rotation_deg):
rotation_deg = [radians(float(rot)) for rot in rotation_deg.split(",")]
obj = the_object_name_exists(name)
obj.rotation_euler[0] += rotation_deg[0]
obj.rotation_euler[1] += rotation_deg[1]
obj.rotation_euler[2] += rotation_deg[2]
bpy.context.view_layer.update() # make sure matrix is updated
@given(parsers.parse('the object "{name}" is moved to "{location}"'))
@when(parsers.parse('the object "{name}" is moved to "{location}"'))
def the_object_name_is_moved_to_location(name, location):
location = [float(co) for co in location.split(",")]
the_object_name_exists(name).matrix_world[0][3] = location[0]
the_object_name_exists(name).matrix_world[1][3] = location[1]
the_object_name_exists(name).matrix_world[2][3] = location[2]
obj = the_object_name_exists(name)
obj.matrix_world.translation = location
@given(parsers.parse('the object "{name}" is scaled to "{scale}"'))