New feature where you can select related objects from an actively selected type.

This commit is contained in:
Dion Moult
2021-07-21 10:41:59 +10:00
parent a7252273b4
commit c40fd91730
3 changed files with 37 additions and 7 deletions
@@ -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)