Skip to content

Commit 7141f2c

Browse files
falken10vdlMoult
authored andcommitted
Fixes to PR7607 (Linked IFC Projects): Wireframe toggle. More permisive to get has_transformation = False. Show enable_editing_link if link is loaded
1 parent 418d410 commit 7141f2c

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

src/bonsai/bonsai/bim/module/project/operator.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,12 +1664,16 @@ def execute(self, context):
16641664
return {"FINISHED"}
16651665

16661666
def toggle_wireframe(self, link: "Link") -> None:
1667+
linked_collections = self.get_linked_collections()
1668+
16671669
link.is_wireframe = not link.is_wireframe
16681670
display_type = "WIRE" if link.is_wireframe else "TEXTURED"
1669-
for collection in self.get_linked_collections():
1671+
for collection in linked_collections:
16701672
objs = filter(lambda obj: "IfcOpeningElement" not in obj.name, collection.all_objects)
16711673
for obj in objs:
16721674
obj.display_type = display_type
1675+
if handle := tool.Project.get_link_empty_handle(link):
1676+
handle.display_type = display_type
16731677

16741678
def toggle_visibility(self, link: "Link") -> None:
16751679
linked_collections = self.get_linked_collections()
@@ -1746,15 +1750,14 @@ def _execute(self, context):
17461750

17471751
# obj_matrix is typically calculated as:
17481752
# obj_matrix = np.linalg.inv(local_matrix) @ transformation @ global_matrix
1749-
# So let's calculate the transformation
1750-
1751-
transformed_global_matrix = local_matrix @ np.array(new_obj_matrix)
1752-
transformation = transformed_global_matrix @ np.linalg.inv(global_matrix)
1753-
if np.allclose(transformation, np.eye(4)):
1754-
link.has_transformation = True
1753+
identity_blender_matrix = np.linalg.inv(local_matrix) @ global_matrix
1754+
if np.allclose(np.array(new_obj_matrix), identity_blender_matrix, atol=1e-5):
1755+
link.has_transformation = False
17551756
transformation = ",".join(map(str, np.eye(4).reshape(-1)))
17561757
else:
1757-
link.has_transformation = False
1758+
transformed_global_matrix = local_matrix @ np.array(new_obj_matrix)
1759+
transformation = transformed_global_matrix @ np.linalg.inv(global_matrix)
1760+
link.has_transformation = True
17581761
transformation = ",".join(map(str, transformation.reshape(-1)))
17591762

17601763
if tool.Ifc.get():

src/bonsai/bonsai/bim/module/project/ui.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,12 +487,12 @@ def draw(self, context):
487487
row = self.layout.row(align=True)
488488
row.alignment = "RIGHT"
489489
index = self.props.active_link_index
490-
if self.props.active_link.is_editing:
491-
row.operator("bim.edit_link", text="", icon="CHECKMARK")
492-
row.operator("bim.disable_editing_link", text="", icon="CANCEL")
493-
else:
494-
row.operator("bim.enable_editing_link", text="", icon="GREASEPENCIL")
495490
if self.props.active_link.is_loaded:
491+
if self.props.active_link.is_editing:
492+
row.operator("bim.edit_link", text="", icon="CHECKMARK")
493+
row.operator("bim.disable_editing_link", text="", icon="CANCEL")
494+
else:
495+
row.operator("bim.enable_editing_link", text="", icon="GREASEPENCIL")
496496
row.operator("bim.select_link_handle", text="", icon="OBJECT_DATA").link_index = index
497497
row.operator("bim.unload_link", text="", icon="UNLINKED").link_index = index
498498
row.operator("bim.reload_link", text="", icon="FILE_REFRESH").link_index = index

0 commit comments

Comments
 (0)