mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 10:33:20 +00:00
Fixes to PR7607 (Linked IFC Projects): Wireframe toggle. More permisive to get has_transformation = False. Show enable_editing_link if link is loaded
This commit is contained in:
@@ -1664,12 +1664,16 @@ class ToggleLinkVisibility(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
def toggle_wireframe(self, link: "Link") -> None:
|
||||
linked_collections = self.get_linked_collections()
|
||||
|
||||
link.is_wireframe = not link.is_wireframe
|
||||
display_type = "WIRE" if link.is_wireframe else "TEXTURED"
|
||||
for collection in self.get_linked_collections():
|
||||
for collection in linked_collections:
|
||||
objs = filter(lambda obj: "IfcOpeningElement" not in obj.name, collection.all_objects)
|
||||
for obj in objs:
|
||||
obj.display_type = display_type
|
||||
if handle := tool.Project.get_link_empty_handle(link):
|
||||
handle.display_type = display_type
|
||||
|
||||
def toggle_visibility(self, link: "Link") -> None:
|
||||
linked_collections = self.get_linked_collections()
|
||||
@@ -1746,15 +1750,14 @@ class EditLink(bpy.types.Operator, tool.Ifc.Operator):
|
||||
|
||||
# obj_matrix is typically calculated as:
|
||||
# obj_matrix = np.linalg.inv(local_matrix) @ transformation @ global_matrix
|
||||
# So let's calculate the transformation
|
||||
|
||||
transformed_global_matrix = local_matrix @ np.array(new_obj_matrix)
|
||||
transformation = transformed_global_matrix @ np.linalg.inv(global_matrix)
|
||||
if np.allclose(transformation, np.eye(4)):
|
||||
link.has_transformation = True
|
||||
identity_blender_matrix = np.linalg.inv(local_matrix) @ global_matrix
|
||||
if np.allclose(np.array(new_obj_matrix), identity_blender_matrix, atol=1e-5):
|
||||
link.has_transformation = False
|
||||
transformation = ",".join(map(str, np.eye(4).reshape(-1)))
|
||||
else:
|
||||
link.has_transformation = False
|
||||
transformed_global_matrix = local_matrix @ np.array(new_obj_matrix)
|
||||
transformation = transformed_global_matrix @ np.linalg.inv(global_matrix)
|
||||
link.has_transformation = True
|
||||
transformation = ",".join(map(str, transformation.reshape(-1)))
|
||||
|
||||
if tool.Ifc.get():
|
||||
|
||||
@@ -487,12 +487,12 @@ class BIM_PT_links(Panel):
|
||||
row = self.layout.row(align=True)
|
||||
row.alignment = "RIGHT"
|
||||
index = self.props.active_link_index
|
||||
if self.props.active_link.is_editing:
|
||||
row.operator("bim.edit_link", text="", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_link", text="", icon="CANCEL")
|
||||
else:
|
||||
row.operator("bim.enable_editing_link", text="", icon="GREASEPENCIL")
|
||||
if self.props.active_link.is_loaded:
|
||||
if self.props.active_link.is_editing:
|
||||
row.operator("bim.edit_link", text="", icon="CHECKMARK")
|
||||
row.operator("bim.disable_editing_link", text="", icon="CANCEL")
|
||||
else:
|
||||
row.operator("bim.enable_editing_link", text="", icon="GREASEPENCIL")
|
||||
row.operator("bim.select_link_handle", text="", icon="OBJECT_DATA").link_index = index
|
||||
row.operator("bim.unload_link", text="", icon="UNLINKED").link_index = index
|
||||
row.operator("bim.reload_link", text="", icon="FILE_REFRESH").link_index = index
|
||||
|
||||
Reference in New Issue
Block a user