mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Add ALT+Click unhide to select_by_material
ALT+Click now unhides hidden objects (viewport and local hide) before selecting, matching the behavior added to other select operators. Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -61,13 +61,18 @@ class DisableEditingMaterials(bpy.types.Operator):
|
||||
class SelectByMaterial(bpy.types.Operator):
|
||||
bl_idname = "bim.select_by_material"
|
||||
bl_label = "Select By Material"
|
||||
bl_description = "Select objects using the provided material"
|
||||
bl_description = "Select objects using the provided material\n\nALT+Click to also unhide hidden objects (viewport and local hide)"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
material: bpy.props.IntProperty()
|
||||
should_unhide: bpy.props.BoolProperty(default=False, options={"SKIP_SAVE"})
|
||||
|
||||
def invoke(self, context, event):
|
||||
self.should_unhide = event.alt
|
||||
return self.execute(context)
|
||||
|
||||
def execute(self, context):
|
||||
material = tool.Ifc.get().by_id(self.material)
|
||||
core.select_by_material(tool.Material, tool.Spatial, material=material)
|
||||
core.select_by_material(tool.Material, tool.Spatial, material=material, should_unhide=self.should_unhide)
|
||||
|
||||
# copy selection query to clipboard
|
||||
if material.is_a("IfcMaterialLayerSet"):
|
||||
|
||||
@@ -82,9 +82,12 @@ def disable_editing_materials(material: type[tool.Material]) -> None:
|
||||
|
||||
|
||||
def select_by_material(
|
||||
material_tool: type[tool.Material], spatial: type[tool.Spatial], material: ifcopenshell.entity_instance
|
||||
material_tool: type[tool.Material],
|
||||
spatial: type[tool.Spatial],
|
||||
material: ifcopenshell.entity_instance,
|
||||
should_unhide: bool = False,
|
||||
) -> None:
|
||||
spatial.select_products(material_tool.get_elements_by_material(material))
|
||||
spatial.select_products(material_tool.get_elements_by_material(material), unhide=should_unhide)
|
||||
|
||||
|
||||
def enable_editing_material(material_tool: type[tool.Material], material: ifcopenshell.entity_instance) -> None:
|
||||
|
||||
Reference in New Issue
Block a user