mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
new operator - bim.select_entity_by_guid
I find myself often having element guid copied (either from other viewer or from text editor or from elsewhere) and to find it in scene I needed to create a new search group, add a filter, paste guid and then search for it. So decided to add a shortcut for this that just takes guid from the clipboard and runs the search for it. Location - https://i.imgur.com/3c5rm1N.png
This commit is contained in:
@@ -101,6 +101,7 @@ classes = [
|
||||
operator.BIM_OT_delete_object,
|
||||
operator.BIM_OT_remove_section_plane,
|
||||
operator.BIM_OT_select_entity,
|
||||
operator.BIM_OT_select_entity_by_guid,
|
||||
operator.BIM_OT_select_object,
|
||||
operator.BIM_OT_show_description,
|
||||
operator.BIM_OT_multiple_file_selector,
|
||||
|
||||
@@ -392,6 +392,7 @@ def draw_filter(
|
||||
row = layout.row(align=True)
|
||||
row.label(text=f"{len(data.data['saved_searches'])} Saved Searches")
|
||||
|
||||
row.operator("bim.select_entity_by_guid", text="", icon="CON_OBJECTSOLVER")
|
||||
if data.data["saved_searches"]:
|
||||
row.operator("bim.load_search", text="", icon="IMPORT").module = module
|
||||
row.operator("bim.save_search", text="", icon="EXPORT").module = module
|
||||
|
||||
@@ -1049,6 +1049,38 @@ class BIM_OT_select_entity(bpy.types.Operator):
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class BIM_OT_select_entity_by_guid(bpy.types.Operator):
|
||||
bl_idname = "bim.select_entity_by_guid"
|
||||
bl_label = "Select Entity by Guid"
|
||||
bl_description = "Select entity by guid currently saved to clipboard"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
@classmethod
|
||||
def description(cls, context, properties) -> str:
|
||||
assert context.window_manager
|
||||
return f"{cls.bl_description}:\n'{context.window_manager.clipboard.strip()}'"
|
||||
|
||||
def execute(self, context):
|
||||
assert context.window_manager
|
||||
|
||||
ifc_file = tool.Ifc.get()
|
||||
guid = context.window_manager.clipboard.strip()
|
||||
try:
|
||||
element = ifc_file.by_guid(guid)
|
||||
except RuntimeError:
|
||||
self.report({"ERROR"}, f"No IFC element found with guid '{guid}'.")
|
||||
return {"CANCELLED"}
|
||||
|
||||
obj = tool.Ifc.get_object(element)
|
||||
if not isinstance(obj, bpy.types.Object):
|
||||
self.report({"ERROR"}, f"The following element is not present in the scene as Blender object: '{element}'.")
|
||||
return {"CANCELLED"}
|
||||
|
||||
tool.Blender.select_and_activate_single_object(context, obj)
|
||||
self.report({"INFO"}, f"Found and selected element: '{obj.name}'.")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class BIM_OT_select_object(bpy.types.Operator):
|
||||
bl_idname = "bim.select_object"
|
||||
bl_label = "Select Object"
|
||||
|
||||
Reference in New Issue
Block a user