Tests for connecting mep elements and regenerating them

Also:
- fixed bug with bim.mep_connect_elements not considering actual blender blender object's position
- moved syncing ifc position with blender object position to tools (sync_object_ifc_position)
- fixed a bug in adding a bend that occured if either any of the start/end points of the start/end segments matched - in that case one of the segments end up not connected to the bend
This commit is contained in:
Andrej730
2023-11-16 19:15:06 +05:00
parent 2557580500
commit 60f8d30fc1
7 changed files with 138 additions and 30 deletions
+12 -9
View File
@@ -529,13 +529,14 @@ Scenario: Create a door, undo and create a new door
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 the variable "segment_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.ifc_class" to "IfcDuctSegmentType"
And I set "scene.BIMModelProperties.relating_type_id" to "{segment_types}[0]"
And I press "bim.add_constr_type_instance"
And I rename the object "IfcDuctSegment/DuctSegment" to "IfcDuctSegment/RectSegment"
And I set "scene.BIMModelProperties.relating_type_id" to "{element_types}[1]"
And I set "scene.BIMModelProperties.relating_type_id" to "{segment_types}[1]"
And I press "bim.add_constr_type_instance"
And I rename the object "IfcDuctSegment/DuctSegment" to "IfcDuctSegment/CircleSegment"
@@ -557,14 +558,15 @@ Scenario: Create a MEP transition
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 the variable "segment_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.ifc_class" to "IfcDuctSegmentType"
And I set "scene.BIMModelProperties.relating_type_id" to "{segment_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 set "scene.BIMModelProperties.relating_type_id" to "{segment_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
@@ -586,14 +588,15 @@ Scenario: Create a MEP bend between intersecting with different locations
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 the variable "segment_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.ifc_class" to "IfcDuctSegmentType"
And I set "scene.BIMModelProperties.relating_type_id" to "{segment_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 set "scene.BIMModelProperties.relating_type_id" to "{segment_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
+82 -1
View File
@@ -109,20 +109,101 @@ Scenario: Assign flow controls to flow element_type
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
And I set "scene.BIMRootProperties.ifc_class" to "IfcActuator"
And I press "bim.assign_class"
And I add an empty
And the object "Empty" is selected
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
And I set "scene.BIMRootProperties.ifc_class" to "IfcActuator"
And I press "bim.assign_class"
And I add an empty
And the object "Empty" is selected
And I set "scene.BIMRootProperties.ifc_product" to "IfcElement"
And I set "scene.BIMRootProperties.ifc_class" to "IfcFlowSegment"
And I press "bim.assign_class"
And the object "IfcActuator/Empty" is selected
And additionally the object "IfcActuator/Empty.001" is selected
And additionally the object "IfcFlowSegment/Empty" is selected
When I press "bim.assign_unassign_flow_control(assign=True)"
And the variable "assigned_controls" is "set(tool.System.get_flow_element_controls({ifc}.by_type('IfcFlowSegment')[0]))"
Then the variable "assigned_controls" is "set[{ifc}.by_type('IfcActuator')]"
Then the variable "assigned_controls" is "set({ifc}.by_type('IfcActuator'))"
Scenario: Connect MEP elements
Given an empty IFC project
And I create default MEP types
And the variable "segment_types" is "[str(e.id()) for e in {ifc}.by_type('IfcDuctSegmentType')]"
And the variable "actuator_type_id" is "{ifc}.by_type('IfcActuatorType')[0].id()"
# segment 1
And I set "scene.BIMModelProperties.ifc_class" to "IfcDuctSegmentType"
And I set "scene.BIMModelProperties.relating_type_id" to "{segment_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"
# actuator
And I set "scene.BIMModelProperties.ifc_class" to "IfcActuatorType"
And I set "scene.BIMModelProperties.relating_type_id" to "{actuator_type_id}"
And I press "bim.add_constr_type_instance"
And the object "IfcActuator/Actuator" is moved to "10,0,0"
# connect actuator
And the object "IfcActuator/Actuator" is selected
And additionally the object "IfcDuctSegment/Seg1" is selected
And I press "bim.mep_connect_elements"
# final check
Then the object "IfcDuctSegment/Seg1" is at "0,0,1"
And the object "IfcDuctSegment/Seg1" dimensions are "0.4,0.2,5.0"
And the object "IfcActuator/Actuator" is at "5.5,0.0,1.0"
And the variable "connected_elements" is "set(tool.System.get_connected_elements({ifc}.by_type('IfcActuator')[0]))"
Scenario: Connect MEP elements and regenerate
Given an empty IFC project
And I create default MEP types
And the variable "segment_types" is "[str(e.id()) for e in {ifc}.by_type('IfcDuctSegmentType')]"
And the variable "actuator_type_id" is "{ifc}.by_type('IfcActuatorType')[0].id()"
# segment1
And I set "scene.BIMModelProperties.ifc_class" to "IfcDuctSegmentType"
And I set "scene.BIMModelProperties.relating_type_id" to "{segment_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"
# segment2
And I set "scene.BIMModelProperties.relating_type_id" to "{segment_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
# bend between segments 1 and 2
And the object "IfcDuctSegment/Seg1" is selected
And additionally the object "IfcDuctSegment/Seg2" is selected
And I press "bim.mep_add_bend"
# actuator
And I set "scene.BIMModelProperties.ifc_class" to "IfcActuatorType"
And I set "scene.BIMModelProperties.relating_type_id" to "{actuator_type_id}"
And I press "bim.add_constr_type_instance"
And the object "IfcActuator/Actuator" is moved to "10,0,0"
# connect actuator
And the object "IfcActuator/Actuator" is selected
And additionally the object "IfcDuctSegment/Seg1" is selected
And I press "bim.mep_connect_elements"
# move and regenerate
And the object "IfcActuator/Actuator" is moved to "0.0,5.0,10"
And the object "IfcActuator/Actuator" is selected
And I press "bim.regenerate_distribution_element"
# final check
# And I save sample test files and open in blender
Then the object "IfcActuator/Actuator" is at "0.0,5.0,10"
And the object "IfcDuctSegment/Seg1" is at "-6.0,5.0,10.0"
And the object "IfcDuctSegment/Seg1" dimensions are "0.4,0.2,5.5"
And the object "IfcDuctFitting/DuctFitting" is at "-6.5,5.5,10.0"
And the object "IfcDuctSegment/Seg2" is at "-6.5,5.5,10.0"
And the object "IfcDuctSegment/Seg2" dimensions are "0.4,0.2,5.0"
+13 -1
View File
@@ -113,15 +113,27 @@ def i_load_a_new_pset_template_file():
def i_create_default_mep_types():
model_props = bpy.context.scene.BIMModelProperties
# add couple segments types
model_props.type_class = "IfcDuctSegmentType"
model_props.type_name = "RECT1"
model_props.type_template = "FLOW_SEGMENT_RECTANGULAR"
bpy.ops.bim.add_type()
model_props.type_template = "FLOW_SEGMENT_CIRCULAR"
model_props.type_name = "RECT2"
model_props.type_name = "CIRCLE1"
bpy.ops.bim.add_type()
# add an actuator type
model_props.type_class = "IfcActuatorType"
model_props.type_template = "MESH" # cube representation
model_props.type_name = "ACTUATOR"
bpy.ops.bim.add_type()
with bpy.context.temp_override(active_object=bpy.data.objects["IfcActuatorType/ACTUATOR"]):
bpy.ops.bim.add_port()
# port at cube's left side
bpy.data.objects["IfcDistributionPort/Port"].location = (-0.5, 0, 0)
bpy.ops.bim.hide_ports()
@given("I add a cube")
@when("I add a cube")