mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
fix linked ifc wireframe mode toggle
This commit is contained in:
@@ -1034,15 +1034,15 @@ class ToggleLinkVisibility(bpy.types.Operator):
|
|||||||
bl_label = "Toggle Link Visibility"
|
bl_label = "Toggle Link Visibility"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
bl_description = "Toggle visibility between SOLID and WIREFRAME"
|
bl_description = "Toggle visibility between SOLID and WIREFRAME"
|
||||||
link: bpy.props.StringProperty()
|
link: bpy.props.StringProperty(name="Linked IFC Filepath")
|
||||||
mode: bpy.props.StringProperty()
|
mode: bpy.props.EnumProperty(name="Visibility Mode", items=((i, i, "") for i in ("WIREFRAME", "VISIBLE")))
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
props = context.scene.BIMProjectProperties
|
props = context.scene.BIMProjectProperties
|
||||||
link = props.links.get(self.link)
|
link = props.links.get(self.link)
|
||||||
self.filepath = self.link
|
if not os.path.isabs(self.link):
|
||||||
if not os.path.isabs(self.filepath):
|
self.link = os.path.abspath(os.path.join(bpy.path.abspath("//"), self.link))
|
||||||
self.filepath = os.path.abspath(os.path.join(bpy.path.abspath("//"), self.filepath)).replace("\\", "/")
|
self.library_filepath = Path(self.link).with_suffix(".ifc.cache.blend")
|
||||||
if self.mode == "WIREFRAME":
|
if self.mode == "WIREFRAME":
|
||||||
self.toggle_wireframe(link)
|
self.toggle_wireframe(link)
|
||||||
elif self.mode == "VISIBLE":
|
elif self.mode == "VISIBLE":
|
||||||
@@ -1077,11 +1077,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):
|
def get_linked_collections(self) -> list[bpy.types.Collection]:
|
||||||
return [
|
return [
|
||||||
c
|
c
|
||||||
for c in bpy.data.collections
|
for c in bpy.data.collections
|
||||||
if "IfcProject" in c.name and c.library and c.library.filepath.replace("\\", "/") == self.filepath
|
if "IfcProject" in c.name and c.library and Path(c.library.filepath) == self.library_filepath
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -322,8 +322,12 @@ Scenario: Link IFC
|
|||||||
Scenario: Toggle link visibility - wireframe mode
|
Scenario: Toggle link visibility - wireframe mode
|
||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.ifc')"
|
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')"
|
When I press "bim.toggle_link_visibility(link='{cwd}/test/files/basic.ifc', mode='WIREFRAME')"
|
||||||
Then nothing happens
|
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_wireframe" is "True"
|
||||||
|
And the object "Chunk" should display as "WIRE"
|
||||||
|
When I press "bim.toggle_link_visibility(link='{cwd}/test/files/basic.ifc', mode='WIREFRAME')"
|
||||||
|
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_wireframe" is "False"
|
||||||
|
And the object "Chunk" should display as "TEXTURED"
|
||||||
|
|
||||||
Scenario: Toggle link visibility - visible mode
|
Scenario: Toggle link visibility - visible mode
|
||||||
Given an empty IFC project
|
Given an empty IFC project
|
||||||
|
|||||||
Reference in New Issue
Block a user