Deprecate auto detection of vendor workarounds as no longer necessary.

This commit is contained in:
Dion Moult
2021-09-12 19:19:53 +10:00
parent 92adeca837
commit 2a07f7082a
9 changed files with 166 additions and 100 deletions
+7
View File
@@ -26,6 +26,7 @@ import blenderbim
import ifcopenshell
import ifcopenshell.util.representation
from blenderbim.bim.ifc import IfcStore
from mathutils import Vector
# Monkey-patch webbrowser opening since we want to test headlessly
webbrowser.open = lambda x: True
@@ -245,6 +246,11 @@ def the_object_name_has_number_vertices(name, number):
assert total == int(number), f"We found {total} vertices"
def the_object_name_is_at_location(name, location):
obj_location = the_object_name_exists(name).location
assert (obj_location - Vector([float(co) for co in location.split(",")])).length < 0.1, f"Object is at {obj_location}"
definitions = {
"an empty IFC project": an_empty_ifc_project,
"I add a cube": i_add_a_cube,
@@ -275,6 +281,7 @@ definitions = {
'the object "(.*)" is not voided by "(.*)"': the_object_name_is_not_voided_by_void,
'the object "(.*)" should display as "(.*)"': the_object_name_should_display_as_mode,
'the object "(.*)" has "([0-9]+)" vertices': the_object_name_has_number_vertices,
'the object "(.*)" is at "(.*)"': the_object_name_is_at_location,
}
@@ -42,7 +42,33 @@ class TestLoadProject(test.bim.bootstrap.NewFile):
return """
When I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
Then an IFC file exists
And the object "IfcProject/My Project" is an "IfcProject"
And the object "IfcSite/My Site" is an "IfcSite"
And the object "IfcBuilding/My Building" is an "IfcBuilding"
And the object "IfcBuildingStorey/Ground Floor" is an "IfcBuildingStorey"
And the object "IfcBuildingStorey/Level 1" is an "IfcBuildingStorey"
And the object "IfcSlab/Slab" is an "IfcSlab"
And the object "IfcWall/Wall" is an "IfcWall"
And the object "IfcElementAssembly/Empty" is an "IfcElementAssembly"
And the object "IfcBeam/Beam" is an "IfcBeam"
And the object "IfcSite/My Site" is in the collection "IfcSite/My Site"
And the object "IfcBuilding/My Building" is in the collection "IfcBuilding/My Building"
And the object "IfcBuildingStorey/Ground Floor" is in the collection "IfcBuildingStorey/Ground Floor"
And the object "IfcBuildingStorey/Level 1" is in the collection "IfcBuildingStorey/Level 1"
And the object "IfcElementAssembly/Empty" is in the collection "IfcElementAssembly/Empty"
And the object "IfcBeam/Beam" is in the collection "IfcElementAssembly/Empty"
And the object "IfcSlab/Slab" is in the collection "IfcBuildingStorey/Ground Floor"
And the object "IfcWall/Wall" is in the collection "IfcBuildingStorey/Level 1"
And "scene.BIMProjectProperties.is_loading" is "False"
"""
@test.bim.bootstrap.scenario
def test_loading_a_project_in_advanced_mode(self):
return """
When I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
Then an IFC file exists
And "scene.BIMProjectProperties.is_loading" is "True"
And the object "IfcProject/My Project" does not exist
"""
@@ -50,7 +76,7 @@ class TestLoadProjectElements(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
def test_loading_all_project_elements(self):
return """
Given I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
Given I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
And I set "scene.BIMProjectProperties.filter_mode" to "NONE"
And I press "bim.load_project_elements"
@@ -77,7 +103,7 @@ class TestLoadProjectElements(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
def test_loading_objects_filtered_by_decomposition(self):
return """
Given I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
Given I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
And I set "scene.BIMProjectProperties.filter_mode" to "DECOMPOSITION"
Then "scene.BIMProjectProperties.filter_categories['IfcSite/My Site'].total_elements" is "0"
@@ -106,7 +132,7 @@ class TestLoadProjectElements(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
def test_loading_objects_filtered_by_ifc_class(self):
return """
Given I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
Given I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
And I set "scene.BIMProjectProperties.filter_mode" to "IFC_CLASS"
Then "scene.BIMProjectProperties.filter_categories['IfcWall'].total_elements" is "1"
@@ -126,10 +152,56 @@ class TestLoadProjectElements(test.bim.bootstrap.NewFile):
And the object "IfcWall/Wall" does not exist
"""
@test.bim.bootstrap.scenario
def test_loading_objects_filtered_by_whitelist(self):
return """
Given I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
And I set "scene.BIMProjectProperties.filter_mode" to "WHITELIST"
And I set "scene.BIMProjectProperties.filter_query" to ".IfcSlab"
And I press "bim.load_project_elements"
Then the object "IfcProject/My Project" is an "IfcProject"
And the object "IfcSite/My Site" is an "IfcSite"
And the object "IfcBuilding/My Building" is an "IfcBuilding"
And the object "IfcBuildingStorey/Ground Floor" is an "IfcBuildingStorey"
And the object "IfcSlab/Slab" is an "IfcSlab"
And the object "IfcSite/My Site" is in the collection "IfcSite/My Site"
And the object "IfcBuilding/My Building" is in the collection "IfcBuilding/My Building"
And the object "IfcBuildingStorey/Ground Floor" is in the collection "IfcBuildingStorey/Ground Floor"
And the object "IfcSlab/Slab" is in the collection "IfcBuildingStorey/Ground Floor"
And the object "IfcBuildingStorey/Level 1" does not exist
And the object "IfcWall/Wall" does not exist
"""
@test.bim.bootstrap.scenario
def test_loading_objects_filtered_by_blacklist(self):
return """
Given I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
And I set "scene.BIMProjectProperties.filter_mode" to "BLACKLIST"
And I set "scene.BIMProjectProperties.filter_query" to ".IfcSlab"
And I press "bim.load_project_elements"
Then the object "IfcProject/My Project" is an "IfcProject"
And the object "IfcSite/My Site" is an "IfcSite"
And the object "IfcBuilding/My Building" is an "IfcBuilding"
And the object "IfcBuildingStorey/Level 1" is an "IfcBuildingStorey"
And the object "IfcWall/Wall" is an "IfcWall"
And the object "IfcElementAssembly/Empty" is an "IfcElementAssembly"
And the object "IfcBeam/Beam" is an "IfcBeam"
And the object "IfcSite/My Site" is in the collection "IfcSite/My Site"
And the object "IfcBuilding/My Building" is in the collection "IfcBuilding/My Building"
And the object "IfcBuildingStorey/Level 1" is in the collection "IfcBuildingStorey/Level 1"
And the object "IfcWall/Wall" is in the collection "IfcBuildingStorey/Level 1"
And the object "IfcElementAssembly/Empty" is in the collection "IfcElementAssembly/Empty"
And the object "IfcBeam/Beam" is in the collection "IfcElementAssembly/Empty"
And the object "IfcBuildingStorey/Ground Floor" does not exist
And the object "IfcSlab/Slab" does not exist
"""
@test.bim.bootstrap.scenario
def test_loading_no_objects_due_to_filter(self):
return """
Given I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
Given I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
When I set "scene.BIMProjectProperties.collection_mode" to "DECOMPOSITION"
And I set "scene.BIMProjectProperties.filter_mode" to "IFC_CLASS"
And I press "bim.load_project_elements"
@@ -142,12 +214,22 @@ class TestLoadProjectElements(test.bim.bootstrap.NewFile):
And the object "IfcWall/Wall" does not exist
"""
@test.bim.bootstrap.scenario
def test_manual_offset_of_object_placements(self):
return """
Given I press "bim.load_project(filepath='{cwd}/test/files/manual-geolocation.ifc', is_advanced=True)"
When I set "scene.BIMProjectProperties.should_offset_model" to "True"
And I set "scene.BIMProjectProperties.model_offset_coordinates" to "-268388.5, -5774506.0, -21.899999618530273"
And I press "bim.load_project_elements"
Then the object "IfcPlate/1780 x 270 PRECAST WALL" is at "0,0,0"
"""
class TestUnloadProject(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
def test_unloading_a_project(self):
return """
When I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
When I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
And I press "bim.unload_project"
Then an IFC file does not exist
And "scene.BIMProjectProperties.is_loading" is "False"
-31
View File
@@ -1,31 +0,0 @@
# BlenderBIM Add-on - OpenBIM Blender Add-on
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
#
# This file is part of BlenderBIM Add-on.
#
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BlenderBIM Add-on is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import bpy
import test.bim.bootstrap
from blenderbim.bim.ifc import IfcStore
class TestImportIFC(test.bim.bootstrap.NewFile):
def test_manual_offset_of_object_placements(self):
bpy.ops.import_ifc.bim(
filepath="./test/files/manual-geolocation.ifc",
should_offset_model=True,
model_offset_coordinates="-268388.5, -5774506.0, -21.899999618530273",
)
assert IfcStore.id_map[63].location.length < 1