mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +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_label = "Toggle Link Selectability"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
bl_description = "Toggle selectability"
|
bl_description = "Toggle selectability"
|
||||||
link: bpy.props.StringProperty()
|
link: bpy.props.StringProperty(name="Linked IFC Filepath")
|
||||||
|
|
||||||
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")
|
||||||
for collection in self.get_linked_collections():
|
for collection in self.get_linked_collections():
|
||||||
collection.hide_select = not collection.hide_select
|
collection.hide_select = not collection.hide_select
|
||||||
link.is_selectable = not collection.hide_select
|
link.is_selectable = not collection.hide_select
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
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
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -329,6 +329,16 @@ Scenario: Toggle link visibility - wireframe mode
|
|||||||
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_wireframe" is "False"
|
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.ifc'].is_wireframe" is "False"
|
||||||
And the object "Chunk" should display as "TEXTURED"
|
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
|
Scenario: Toggle link visibility - visible 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')"
|
||||||
|
|||||||
@@ -397,6 +397,18 @@ def the_collection_name_exists(name) -> bpy.types.Collection:
|
|||||||
return obj
|
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'))
|
@then(parsers.parse('the collection "{name}" exists in viewlayer'))
|
||||||
def the_collection_exists_in_viewlayer(name: str) -> bpy.types.LayerCollection:
|
def the_collection_exists_in_viewlayer(name: str) -> bpy.types.LayerCollection:
|
||||||
col = the_collection_name_exists(name)
|
col = the_collection_name_exists(name)
|
||||||
|
|||||||
Reference in New Issue
Block a user