Fix failing tests

This commit is contained in:
Dion Moult
2022-08-02 19:34:01 +10:00
parent 759e134e3b
commit 73124dd597
4 changed files with 33 additions and 15 deletions
@@ -672,8 +672,9 @@ class LinkIfc(bpy.types.Operator):
use_relative_path: bpy.props.BoolProperty(name="Use Relative Path", default=False)
def execute(self, context):
for file in self.files:
filepath = os.path.join(self.directory, file.name)
files = [self.filepath] if self.filepath else [f.name for f in self.files]
for filename in files:
filepath = os.path.join(self.directory, filename)
new = context.scene.BIMProjectProperties.links.add()
if self.use_relative_path:
filepath = os.path.relpath(filepath, bpy.path.abspath("//"))
@@ -744,7 +745,6 @@ class LoadLink(bpy.types.Operator):
continue
bpy.data.scenes[0].collection.children.link(child)
link = context.scene.BIMProjectProperties.links.get(filepath)
link.collection = child
link.is_loaded = True
return {"FINISHED"}
@@ -767,23 +767,25 @@ class ToggleLinkVisibility(bpy.types.Operator):
return {"FINISHED"}
def toggle_wireframe(self, link):
objs = filter(lambda obj: "IfcOpeningElement" not in obj.name, link.collection.all_objects)
for i, obj in enumerate(objs):
if i == 0:
if obj.display_type == "WIRE":
display_type = "TEXTURED"
else:
display_type = "WIRE"
obj.display_type = display_type
link.is_wireframe = display_type == "WIRE"
for collection in self.get_linked_collections():
objs = filter(lambda obj: "IfcOpeningElement" not in obj.name, collection.all_objects)
for i, obj in enumerate(objs):
if i == 0:
if obj.display_type == "WIRE":
display_type = "TEXTURED"
else:
display_type = "WIRE"
obj.display_type = display_type
link.is_wireframe = display_type == "WIRE"
def toggle_visibility(self, link):
linked_collections = self.get_linked_collections()
queue = [bpy.context.view_layer.layer_collection]
layer_collection = None
while queue:
layer = queue.pop()
if layer.collection == link.collection:
if layer.collection in linked_collections:
layer_collection = layer
break
queue.extend(list(layer.children))
@@ -792,6 +794,11 @@ class ToggleLinkVisibility(bpy.types.Operator):
layer_collection.exclude = not layer_collection.exclude
link.is_hidden = layer_collection.exclude
def get_linked_collections(self):
return [
c for c in bpy.data.collections if "IfcProject" in c.name and c.library and c.library.filepath == self.link
]
class ExportIFC(bpy.types.Operator):
bl_idname = "export_ifc.bim"
@@ -92,7 +92,6 @@ class FilterCategory(PropertyGroup):
class Link(PropertyGroup):
name: StringProperty(name="Name")
collection: PointerProperty(name="Collection", type=bpy.types.Collection)
is_loaded: BoolProperty(name="Is Loaded", default=False)
is_wireframe: BoolProperty(name="Is Wireframe", default=False)
is_hidden: BoolProperty(name="Is Hidden", default=False)
@@ -308,6 +308,18 @@ Scenario: Link IFC
And the object "IfcBuildingStorey/Ground Floor" exists
And the object "IfcBuildingStorey/Level 1" exists
Scenario: Toggle link visibility - wireframe mode
Given an empty IFC project
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
When I press "bim.toggle_link_visibility(link='{cwd}/test/files/basic.blend', mode='WIREFRAME')"
Then nothing happens
Scenario: Toggle link visibility - visible mode
Given an empty IFC project
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
When I press "bim.toggle_link_visibility(link='{cwd}/test/files/basic.blend', mode='VISIBLE')"
Then nothing happens
Scenario: Unload link
Given an empty Blender session
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
+1 -1
View File
@@ -85,7 +85,7 @@ Scenario: Copy property to selected - copy property
And I press "bim.assign_class"
And the object "IfcWall/Cube" is selected
And additionally the object "IfcWall/Cube.001" is selected
And I set "active_object.PsetProperties.pset_name" to "Pset_BuildingElementCommon"
And I set "active_object.PsetProperties.pset_name" to "Pset_WallCommon"
And I press "bim.add_pset(obj='IfcWall/Cube.001', obj_type='Object')"
And the variable "pset" is "{ifc}.by_type('IfcPropertySet')[-1].id()"
And I press "bim.enable_pset_editing(obj='IfcWall/Cube.001', obj_type='Object', pset_id={pset})"