mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
extends bim.select_type by selecting multiple types from a selection of objects.
Also when the type is selected and turned on, all other types are automatically turned off. https://imgur.com/a/DQUF0ai
This commit is contained in:
@@ -1498,7 +1498,11 @@ class IfcImporter:
|
||||
# Occurs when reloading a project
|
||||
pass
|
||||
project_collection = bpy.context.view_layer.layer_collection.children[self.project["blender"].name]
|
||||
project_collection.children[self.type_collection.name].hide_viewport = True
|
||||
types_collection = project_collection.children[self.type_collection.name]
|
||||
types_collection.hide_viewport = False
|
||||
for obj in types_collection.collection.objects: #turn off all objects inside Types collection.
|
||||
obj.hide_set(True)
|
||||
|
||||
|
||||
def clean_mesh(self):
|
||||
obj = None
|
||||
|
||||
@@ -134,7 +134,6 @@ class LaunchTypeManager(bpy.types.Operator):
|
||||
op = row.operator("bim.rename_type", icon="GREASEPENCIL", text="")
|
||||
op.element = relating_type["id"]
|
||||
op = row.operator("bim.select_type", icon="OBJECT_DATA", text="")
|
||||
op.relating_type = relating_type["id"]
|
||||
op = row.operator("bim.duplicate_type", icon="DUPLICATE", text="")
|
||||
op.element = relating_type["id"]
|
||||
op = row.operator("bim.remove_type", icon="X", text="")
|
||||
|
||||
@@ -146,21 +146,39 @@ class SelectType(bpy.types.Operator):
|
||||
relating_type: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
element = tool.Ifc.get().by_id(self.relating_type)
|
||||
obj = tool.Ifc.get_object(element)
|
||||
if obj:
|
||||
try:
|
||||
tool.Blender.select_and_activate_single_object(context, obj)
|
||||
except:
|
||||
self.report({"INFO"}, "Type object is hidden.")
|
||||
# IfcTypeProducts are only used for annotations and not part of the model interface.
|
||||
if element.is_a() != "IfcTypeProduct":
|
||||
try:
|
||||
context.scene.BIMModelProperties.ifc_class = element.is_a()
|
||||
context.scene.BIMModelProperties.relating_type_id = str(self.relating_type)
|
||||
except:
|
||||
# Potentially our BIM Tool is filtered to a specific element.
|
||||
pass
|
||||
selected_objs = context.selected_objects
|
||||
active_obj = context.active_object
|
||||
selected_objs.append(active_obj) #update selected_objs so the active_obj is at the end of the list
|
||||
last_relating_type_obj = None
|
||||
types_collection = bpy.data.collections.get("Types")
|
||||
for obj in types_collection.objects:
|
||||
obj.hide_set(True)
|
||||
for obj in selected_objs:
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
relating_type = ifcopenshell.util.element.get_type(element)
|
||||
relating_type_obj = tool.Ifc.get_object(relating_type)
|
||||
obj.select_set(False)
|
||||
if relating_type_obj:
|
||||
if relating_type_obj.hide_get():
|
||||
relating_type_obj.hide_set(False)
|
||||
relating_type_obj.select_set(True)
|
||||
last_relating_type_obj = relating_type_obj
|
||||
|
||||
context.view_layer.objects.active = last_relating_type_obj #make the active_obj's type the active object
|
||||
|
||||
# if relating_type_obj:
|
||||
# try:
|
||||
# tool.Blender.select_and_activate_single_object(context, relating_type_obj)
|
||||
# except:
|
||||
# self.report({"INFO"}, "Type object is hidden.")
|
||||
# # IfcTypeProducts are only used for annotations and not part of the model interface.
|
||||
# if element.is_a() != "IfcTypeProduct":
|
||||
# try:
|
||||
# context.scene.BIMModelProperties.ifc_class = element.is_a()
|
||||
# context.scene.BIMModelProperties.relating_type_id = str(relating_type)
|
||||
# except:
|
||||
# # Potentially our BIM Tool is filtered to a specific element.
|
||||
# pass
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user