mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
Fix failing tests
This commit is contained in:
@@ -672,8 +672,9 @@ class LinkIfc(bpy.types.Operator):
|
|||||||
use_relative_path: bpy.props.BoolProperty(name="Use Relative Path", default=False)
|
use_relative_path: bpy.props.BoolProperty(name="Use Relative Path", default=False)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
for file in self.files:
|
files = [self.filepath] if self.filepath else [f.name for f in self.files]
|
||||||
filepath = os.path.join(self.directory, file.name)
|
for filename in files:
|
||||||
|
filepath = os.path.join(self.directory, filename)
|
||||||
new = context.scene.BIMProjectProperties.links.add()
|
new = context.scene.BIMProjectProperties.links.add()
|
||||||
if self.use_relative_path:
|
if self.use_relative_path:
|
||||||
filepath = os.path.relpath(filepath, bpy.path.abspath("//"))
|
filepath = os.path.relpath(filepath, bpy.path.abspath("//"))
|
||||||
@@ -744,7 +745,6 @@ class LoadLink(bpy.types.Operator):
|
|||||||
continue
|
continue
|
||||||
bpy.data.scenes[0].collection.children.link(child)
|
bpy.data.scenes[0].collection.children.link(child)
|
||||||
link = context.scene.BIMProjectProperties.links.get(filepath)
|
link = context.scene.BIMProjectProperties.links.get(filepath)
|
||||||
link.collection = child
|
|
||||||
link.is_loaded = True
|
link.is_loaded = True
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
@@ -767,23 +767,25 @@ class ToggleLinkVisibility(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def toggle_wireframe(self, link):
|
def toggle_wireframe(self, link):
|
||||||
objs = filter(lambda obj: "IfcOpeningElement" not in obj.name, link.collection.all_objects)
|
for collection in self.get_linked_collections():
|
||||||
for i, obj in enumerate(objs):
|
objs = filter(lambda obj: "IfcOpeningElement" not in obj.name, collection.all_objects)
|
||||||
if i == 0:
|
for i, obj in enumerate(objs):
|
||||||
if obj.display_type == "WIRE":
|
if i == 0:
|
||||||
display_type = "TEXTURED"
|
if obj.display_type == "WIRE":
|
||||||
else:
|
display_type = "TEXTURED"
|
||||||
display_type = "WIRE"
|
else:
|
||||||
obj.display_type = display_type
|
display_type = "WIRE"
|
||||||
link.is_wireframe = display_type == "WIRE"
|
obj.display_type = display_type
|
||||||
|
link.is_wireframe = display_type == "WIRE"
|
||||||
|
|
||||||
def toggle_visibility(self, link):
|
def toggle_visibility(self, link):
|
||||||
|
linked_collections = self.get_linked_collections()
|
||||||
queue = [bpy.context.view_layer.layer_collection]
|
queue = [bpy.context.view_layer.layer_collection]
|
||||||
layer_collection = None
|
layer_collection = None
|
||||||
|
|
||||||
while queue:
|
while queue:
|
||||||
layer = queue.pop()
|
layer = queue.pop()
|
||||||
if layer.collection == link.collection:
|
if layer.collection in linked_collections:
|
||||||
layer_collection = layer
|
layer_collection = layer
|
||||||
break
|
break
|
||||||
queue.extend(list(layer.children))
|
queue.extend(list(layer.children))
|
||||||
@@ -792,6 +794,11 @@ class ToggleLinkVisibility(bpy.types.Operator):
|
|||||||
layer_collection.exclude = not layer_collection.exclude
|
layer_collection.exclude = not layer_collection.exclude
|
||||||
link.is_hidden = 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):
|
class ExportIFC(bpy.types.Operator):
|
||||||
bl_idname = "export_ifc.bim"
|
bl_idname = "export_ifc.bim"
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ class FilterCategory(PropertyGroup):
|
|||||||
|
|
||||||
class Link(PropertyGroup):
|
class Link(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
collection: PointerProperty(name="Collection", type=bpy.types.Collection)
|
|
||||||
is_loaded: BoolProperty(name="Is Loaded", default=False)
|
is_loaded: BoolProperty(name="Is Loaded", default=False)
|
||||||
is_wireframe: BoolProperty(name="Is Wireframe", default=False)
|
is_wireframe: BoolProperty(name="Is Wireframe", default=False)
|
||||||
is_hidden: BoolProperty(name="Is Hidden", 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/Ground Floor" exists
|
||||||
And the object "IfcBuildingStorey/Level 1" 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
|
Scenario: Unload link
|
||||||
Given an empty Blender session
|
Given an empty Blender session
|
||||||
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
|
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ Scenario: Copy property to selected - copy property
|
|||||||
And I press "bim.assign_class"
|
And I press "bim.assign_class"
|
||||||
And the object "IfcWall/Cube" is selected
|
And the object "IfcWall/Cube" is selected
|
||||||
And additionally the object "IfcWall/Cube.001" 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 I press "bim.add_pset(obj='IfcWall/Cube.001', obj_type='Object')"
|
||||||
And the variable "pset" is "{ifc}.by_type('IfcPropertySet')[-1].id()"
|
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})"
|
And I press "bim.enable_pset_editing(obj='IfcWall/Cube.001', obj_type='Object', pset_id={pset})"
|
||||||
|
|||||||
Reference in New Issue
Block a user