mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Quick way to get search strings from selections: https://community.osarch.org/discussion/comment/23305/#Comment_23305
This commit is contained in:
@@ -61,7 +61,15 @@ class SelectByMaterial(bpy.types.Operator):
|
||||
material: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
core.select_by_material(tool.Material, tool.Spatial, material=tool.Ifc.get().by_id(self.material))
|
||||
material=tool.Ifc.get().by_id(self.material)
|
||||
core.select_by_material(tool.Material, tool.Spatial, material=material)
|
||||
|
||||
# copy selection query to clipboard
|
||||
material_name = material.Name
|
||||
result = f'material="{material_name}"'
|
||||
bpy.context.window_manager.clipboard = result
|
||||
self.report({"INFO"}, f"({result}) was copied to the clipboard.")
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
@@ -518,6 +518,7 @@ class SelectIfcClass(Operator):
|
||||
if element := tool.Ifc.get_entity(obj):
|
||||
classes.add(element.is_a())
|
||||
predefined_types.add(ifcopenshell.util.element.get_predefined_type(element))
|
||||
result = ''
|
||||
for cls in classes:
|
||||
for element in tool.Ifc.get().by_type(cls):
|
||||
if (
|
||||
@@ -527,6 +528,15 @@ class SelectIfcClass(Operator):
|
||||
continue
|
||||
if obj := tool.Ifc.get_object(element):
|
||||
tool.Blender.select_object(obj)
|
||||
|
||||
# copy selection query to clipboard
|
||||
if not result:
|
||||
result = f"{cls}"
|
||||
else:
|
||||
result += f", {cls}"
|
||||
bpy.context.window_manager.clipboard = result
|
||||
self.report({"INFO"}, f"({result}) was copied to the clipboard.")
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -748,3 +758,25 @@ class SelectSimilar(Operator, tool.Ifc.Operator):
|
||||
)
|
||||
else:
|
||||
self.report({"INFO"}, f"Selected all objects that share the same ({key}) value")
|
||||
|
||||
|
||||
# copy selection query to clipboard
|
||||
if not self.calculate_sum:
|
||||
result = ''
|
||||
if value == True:
|
||||
value = "TRUE"
|
||||
if value == False:
|
||||
value = "FALSE"
|
||||
if key == "predefined_type":
|
||||
key = "PredefinedType"
|
||||
if isinstance(value, list) and value:
|
||||
for item in value:
|
||||
sub_result = f'{key} = "{item}"'
|
||||
if not result:
|
||||
result = sub_result
|
||||
else:
|
||||
result += f", {sub_result}"
|
||||
else:
|
||||
result = f'{key} = "{value}"'
|
||||
bpy.context.window_manager.clipboard = result
|
||||
self.report({"INFO"}, f"({result}) was copied to the clipboard.")
|
||||
|
||||
@@ -198,12 +198,26 @@ class SelectSimilarType(bpy.types.Operator):
|
||||
continue
|
||||
relating_types.add(relating_type)
|
||||
|
||||
result = ''
|
||||
for relating_type in relating_types:
|
||||
related_objects = ifcopenshell.util.element.get_types(relating_type)
|
||||
|
||||
for element in related_objects:
|
||||
obj = tool.Ifc.get_object(element)
|
||||
if obj and obj in context.visible_objects:
|
||||
obj.select_set(True)
|
||||
|
||||
# copy selection query to clipboard
|
||||
related_objects_class = related_objects[0].is_a()
|
||||
relating_type_name = relating_type.Name
|
||||
if not result:
|
||||
result = f"{related_objects_class}, type=\"{relating_type_name}\""
|
||||
else:
|
||||
result += f" + {related_objects_class}, type=\"{relating_type_name}\""
|
||||
bpy.context.window_manager.clipboard = result
|
||||
self.report({"INFO"}, f"({result}) was copied to the clipboard.")
|
||||
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user