mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
Fix ifc linking tests
This commit is contained in:
@@ -81,6 +81,9 @@ src/blenderbim/blenderbim/translations.py
|
||||
|
||||
# blenderbim test temp files
|
||||
src/blenderbim/test/files/temp
|
||||
src/blenderbim/test/files/basic.ifc.cache.blend
|
||||
src/blenderbim/test/files/basic.ifc.cache.sqlite
|
||||
|
||||
src/blenderbim/drawings
|
||||
src/blenderbim/layouts
|
||||
|
||||
|
||||
@@ -899,11 +899,11 @@ class UnloadLink(bpy.types.Operator):
|
||||
if filepath.suffix.lower() == ".ifc":
|
||||
filepath = filepath.with_suffix(".ifc.cache.blend")
|
||||
|
||||
for collection in context.scene.collection.children:
|
||||
for collection in context.scene.collection.children[:]:
|
||||
if collection.library and Path(collection.library.filepath) == filepath:
|
||||
context.scene.collection.children.unlink(collection)
|
||||
bpy.data.collections.remove(collection)
|
||||
|
||||
for scene in bpy.data.scenes:
|
||||
for scene in bpy.data.scenes[:]:
|
||||
if scene.library and Path(scene.library.filepath) == filepath:
|
||||
bpy.data.scenes.remove(scene)
|
||||
|
||||
|
||||
@@ -313,18 +313,15 @@ Scenario: Unload project
|
||||
|
||||
Scenario: Link IFC
|
||||
Given an empty IFC project
|
||||
When I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
|
||||
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.blend'].is_loaded" is "True"
|
||||
And the object "IfcWall/Wall" exists
|
||||
And the object "IfcSlab/Slab" exists
|
||||
And the object "IfcElementAssembly/Empty" exists
|
||||
And the object "IfcBeam/Beam" exists
|
||||
And the object "IfcBuildingStorey/Ground Floor" exists
|
||||
And the object "IfcBuildingStorey/Level 1" exists
|
||||
When I press "bim.link_ifc(filepath='{cwd}/test/files/basic.ifc')"
|
||||
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_loaded" is "True"
|
||||
And the collection "IfcProject/basic.ifc" exists
|
||||
And the object "Chunk" exists
|
||||
And the object "Chunk" is placed in the collection "IfcProject/basic.ifc"
|
||||
|
||||
Scenario: Toggle link visibility - wireframe mode
|
||||
Given an empty IFC project
|
||||
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
|
||||
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.ifc')"
|
||||
When I press "bim.toggle_link_visibility(link='{cwd}/test/files/basic.blend', mode='WIREFRAME')"
|
||||
Then nothing happens
|
||||
|
||||
@@ -351,11 +348,12 @@ Scenario: Load link
|
||||
|
||||
Scenario: Unlink IFC
|
||||
Given an empty Blender session
|
||||
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
|
||||
And I press "bim.unload_link(filepath='{cwd}/test/files/basic.blend')"
|
||||
When I press "bim.unlink_ifc(filepath='{cwd}/test/files/basic.blend')"
|
||||
Then "scene.BIMProjectProperties.links.get('{cwd}/test/files/basic.blend')" is "None"
|
||||
And "scene.collection.children.get('IfcProject/My Project')" is "None"
|
||||
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.ifc')"
|
||||
And I press "bim.unload_link(filepath='{cwd}/test/files/basic.ifc')"
|
||||
When I press "bim.unlink_ifc(filepath='{cwd}/test/files/basic.ifc')"
|
||||
Then "scene.BIMProjectProperties.links.get('{cwd}/test/files/basic.ifc')" is "None"
|
||||
And "scene.collection.children.get('IfcProject/basic.ifc')" is "None"
|
||||
And the object "Chunk" does not exist
|
||||
|
||||
Scenario: Export IFC - blank project
|
||||
Given an empty IFC project
|
||||
|
||||
@@ -29,11 +29,12 @@ 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
|
||||
from pathlib import Path
|
||||
|
||||
scenarios("feature")
|
||||
|
||||
variables = {
|
||||
"cwd": os.getcwd(),
|
||||
"cwd": Path.cwd().as_posix(),
|
||||
"ifc": "IfcStore.get_file()",
|
||||
"pset_ifc": "IfcStore.pset_template_file",
|
||||
"classification_ifc": "IfcStore.classification_file",
|
||||
@@ -44,8 +45,6 @@ webbrowser.open = lambda x: True
|
||||
|
||||
|
||||
def replace_variables(value):
|
||||
if "{cwd}" in value and os.name == "nt":
|
||||
value = value.replace("/", "\\").replace("{cwd}", os.getcwd()).replace("\\", "\\\\")
|
||||
for key, new_value in variables.items():
|
||||
value = value.replace("{" + key + "}", str(new_value))
|
||||
return value
|
||||
@@ -291,12 +290,18 @@ def the_object_name_is_scaled_to_scale(name, scale):
|
||||
|
||||
@given(parsers.parse('the object "{name}" is placed in the collection "{collection}"'))
|
||||
@when(parsers.parse('the object "{name}" is placed in the collection "{collection}"'))
|
||||
def the_object_name_is_placed_in_the_collection_collection(name, collection):
|
||||
def the_object_name_is_placed_in_the_collection_collection(name: str, collection: str) -> None:
|
||||
obj = the_object_name_exists(name)
|
||||
[c.objects.unlink(obj) for c in obj.users_collection]
|
||||
bpy.data.collections.get(collection).objects.link(obj)
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name}" is placed in the collection "{collection}"'))
|
||||
def then_the_object_name_is_placed_in_the_collection_collection(name: str, collection: str) -> None:
|
||||
obj = the_object_name_exists(name)
|
||||
assert obj in bpy.data.collections.get(collection).objects[:]
|
||||
|
||||
|
||||
@given(parsers.parse('additionally the object "{name}" is selected'))
|
||||
@when(parsers.parse('additionally the object "{name}" is selected'))
|
||||
def additionally_the_object_name_is_selected(name):
|
||||
@@ -363,7 +368,7 @@ def nothing_happens():
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name}" exists'))
|
||||
def the_object_name_exists(name) -> bpy.types.Object:
|
||||
def the_object_name_exists(name: str) -> bpy.types.Object:
|
||||
obj = bpy.data.objects.get(name)
|
||||
if not obj:
|
||||
assert False, f'The object "{name}" does not exist'
|
||||
@@ -953,5 +958,3 @@ def run_pdb():
|
||||
import pdb
|
||||
|
||||
pdb.set_trace()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user