mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 19:34:34 +00:00
New feature where you can select related objects from an actively selected type.
This commit is contained in:
@@ -7,6 +7,7 @@ classes = (
|
||||
operator.EnableEditingType,
|
||||
operator.DisableEditingType,
|
||||
operator.SelectSimilarType,
|
||||
operator.SelectTypeObjects,
|
||||
prop.BIMTypeProperties,
|
||||
prop.BIMTypeObjectProperties,
|
||||
ui.BIM_PT_type,
|
||||
|
||||
@@ -133,3 +133,20 @@ class SelectSimilarType(bpy.types.Operator):
|
||||
if obj.BIMObjectProperties.ifc_definition_id in related_objects:
|
||||
obj.select_set(True)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SelectTypeObjects(bpy.types.Operator):
|
||||
bl_idname = "bim.select_type_objects"
|
||||
bl_label = "Select Type Objects"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
relating_type: bpy.props.StringProperty()
|
||||
|
||||
def execute(self, context):
|
||||
self.file = IfcStore.get_file()
|
||||
relating_type = bpy.data.objects.get(self.relating_type) if self.relating_type else bpy.context.active_object
|
||||
oprops = relating_type.BIMObjectProperties
|
||||
related_objects = Data.types[oprops.ifc_definition_id]
|
||||
for obj in bpy.context.visible_objects:
|
||||
if obj.BIMObjectProperties.ifc_definition_id in related_objects:
|
||||
obj.select_set(True)
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -17,20 +17,32 @@ class BIM_PT_type(Panel):
|
||||
return False
|
||||
if not IfcStore.get_element(props.ifc_definition_id):
|
||||
return False
|
||||
if props.ifc_definition_id not in Data.products:
|
||||
if props.ifc_definition_id not in Data.products and props.ifc_definition_id not in Data.types:
|
||||
Data.load(IfcStore.get_file(), props.ifc_definition_id)
|
||||
if not Data.products[props.ifc_definition_id]:
|
||||
if props.ifc_definition_id not in Data.products and props.ifc_definition_id not in Data.types:
|
||||
return False
|
||||
if not Data.products.get(props.ifc_definition_id, None) and not Data.types.get(props.ifc_definition_id, None):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def draw(self, context):
|
||||
oprops = context.active_object.BIMObjectProperties
|
||||
|
||||
if oprops.ifc_definition_id in Data.products:
|
||||
self.draw_product_ui(context)
|
||||
else:
|
||||
self.draw_type_ui(context)
|
||||
|
||||
def draw_type_ui(self, context):
|
||||
props = context.active_object.BIMTypeProperties
|
||||
oprops = context.active_object.BIMObjectProperties
|
||||
row = self.layout.row(align=True)
|
||||
row.label(text=f"{len(Data.types[oprops.ifc_definition_id])} Typed Objects")
|
||||
row.operator("bim.select_type_objects", icon="RESTRICT_SELECT_OFF", text="")
|
||||
|
||||
def draw_product_ui(self, context):
|
||||
props = context.active_object.BIMTypeProperties
|
||||
oprops = context.active_object.BIMObjectProperties
|
||||
if not oprops.ifc_definition_id:
|
||||
return
|
||||
if oprops.ifc_definition_id not in Data.products:
|
||||
Data.load(IfcStore.get_file(), oprops.ifc_definition_id)
|
||||
|
||||
if props.is_editing_type:
|
||||
row = self.layout.row(align=True)
|
||||
|
||||
Reference in New Issue
Block a user