mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
fix linked ifc selectability toggle
This commit is contained in:
@@ -1008,24 +1008,24 @@ class ToggleLinkSelectability(bpy.types.Operator):
|
||||
bl_label = "Toggle Link Selectability"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
bl_description = "Toggle selectability"
|
||||
link: bpy.props.StringProperty()
|
||||
link: bpy.props.StringProperty(name="Linked IFC Filepath")
|
||||
|
||||
def execute(self, context):
|
||||
props = context.scene.BIMProjectProperties
|
||||
link = props.links.get(self.link)
|
||||
self.filepath = self.link
|
||||
if not os.path.isabs(self.filepath):
|
||||
self.filepath = os.path.abspath(os.path.join(bpy.path.abspath("//"), self.filepath)).replace("\\", "/")
|
||||
if not os.path.isabs(self.link):
|
||||
self.link = os.path.abspath(os.path.join(bpy.path.abspath("//"), self.link))
|
||||
self.library_filepath = Path(self.link).with_suffix(".ifc.cache.blend")
|
||||
for collection in self.get_linked_collections():
|
||||
collection.hide_select = not collection.hide_select
|
||||
link.is_selectable = not collection.hide_select
|
||||
return {"FINISHED"}
|
||||
|
||||
def get_linked_collections(self):
|
||||
def get_linked_collections(self) -> list[bpy.types.Collection]:
|
||||
return [
|
||||
c
|
||||
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
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -329,6 +329,16 @@ Scenario: Toggle link visibility - wireframe mode
|
||||
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_wireframe" is "False"
|
||||
And the object "Chunk" should display as "TEXTURED"
|
||||
|
||||
Scenario: Toggle link selectability
|
||||
Given an empty IFC project
|
||||
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.ifc')"
|
||||
When I press "bim.toggle_link_selectability(link='{cwd}/test/files/basic.ifc')"
|
||||
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_selectable" is "False"
|
||||
And the collection "IfcProject/basic.ifc" is unselectable
|
||||
When I press "bim.toggle_link_selectability(link='{cwd}/test/files/basic.ifc')"
|
||||
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_selectable" is "True"
|
||||
And the collection "IfcProject/basic.ifc" is selectable
|
||||
|
||||
Scenario: Toggle link visibility - visible mode
|
||||
Given an empty IFC project
|
||||
And I press "bim.link_ifc(filepath='{cwd}/test/files/basic.ifc')"
|
||||
|
||||
@@ -397,6 +397,18 @@ def the_collection_name_exists(name) -> bpy.types.Collection:
|
||||
return obj
|
||||
|
||||
|
||||
@then(parsers.parse('the collection "{name}" is selectable'))
|
||||
def the_collection_name_is_selectable(name: str) -> None:
|
||||
col = the_collection_name_exists(name)
|
||||
assert col.hide_select == False
|
||||
|
||||
|
||||
@then(parsers.parse('the collection "{name}" is unselectable'))
|
||||
def the_collection_name_is_unselectable(name: str) -> None:
|
||||
col = the_collection_name_exists(name)
|
||||
assert col.hide_select == True
|
||||
|
||||
|
||||
@then(parsers.parse('the collection "{name}" exists in viewlayer'))
|
||||
def the_collection_exists_in_viewlayer(name: str) -> bpy.types.LayerCollection:
|
||||
col = the_collection_name_exists(name)
|
||||
|
||||
Reference in New Issue
Block a user