Add buttons to selected related boundaries

Related by a common:
- BuildingElement
- BuildingElementType
- Space
- SpaceType
This commit is contained in:
CyrilWaechter
2023-02-17 13:21:24 +01:00
parent 11894de455
commit 743bd2c48f
3 changed files with 61 additions and 6 deletions
@@ -20,19 +20,21 @@ import bpy
from . import ui, operator, prop
classes = (
operator.ColourByRelatedBuildingElement,
operator.DisableEditingBoundary,
operator.EditBoundaryAttributes,
operator.EnableEditingBoundary,
operator.LoadProjectSpaceBoundaries,
operator.LoadSpaceBoundaries,
operator.LoadBoundary,
operator.SelectSpaceBoundaries,
operator.SelectRelatedElementBoundaries,
operator.SelectProjectBoundaries,
operator.ColourByRelatedBuildingElement,
operator.EnableEditingBoundary,
operator.DisableEditingBoundary,
operator.EditBoundaryAttributes,
operator.SelectRelatedElementTypeBoundaries,
operator.SelectSpaceBoundaries,
operator.UpdateBoundaryGeometry,
ui.BIM_PT_Boundary,
ui.BIM_PT_SpaceBoundaries,
ui.BIM_PT_SceneBoundaries,
ui.BIM_PT_SpaceBoundaries,
prop.BIMBoundaryProperties,
)
@@ -158,6 +158,54 @@ class LoadSpaceBoundaries(bpy.types.Operator):
return {"FINISHED"}
def get_element_boundaries(element):
if not element:
return ()
if element.is_a("IfcSpace"):
return (b for b in element.BoundedBy or ())
return (b for b in element.ProvidesBoundaries)
class SelectRelatedElementBoundaries(bpy.types.Operator):
bl_idname = "bim.select_related_element_boundaries"
bl_label = "Select related element space boundaries"
bl_options = {"REGISTER", "UNDO"}
related_element: bpy.props.IntProperty()
def execute(self, context):
for obj in context.visible_objects:
obj.select_set(False)
element = tool.Ifc.get().by_id(self.related_element)
for rel in get_element_boundaries(element):
obj = tool.Ifc.get_object(rel)
if obj:
obj.select_set(True)
return {"FINISHED"}
class SelectRelatedElementTypeBoundaries(bpy.types.Operator):
bl_idname = "bim.select_related_element_type_boundaries"
bl_label = "Select related element type space boundaries"
bl_options = {"REGISTER", "UNDO"}
related_element: bpy.props.IntProperty()
def execute(self, context):
for obj in context.visible_objects:
obj.select_set(False)
element = tool.Ifc.get().by_id(self.related_element)
if not element:
return {"FINISHED"}
element_type = tool.Root.get_element_type(element)
if not element_type:
return {"FINISHED"}
for child in tool.Type.get_type_occurrences(element_type):
for rel in get_element_boundaries(child):
obj = tool.Ifc.get_object(rel)
if obj:
obj.select_set(True)
return {"FINISHED"}
class SelectSpaceBoundaries(bpy.types.Operator):
bl_idname = "bim.select_space_boundaries"
bl_label = "Select all space boundaries"
@@ -102,6 +102,11 @@ class BIM_PT_Boundary(Panel):
row.label(text=f"{entity.is_a()}/{entity.Name}")
op = row.operator("bim.select_global_id", text="", icon="OBJECT_DATA")
op.global_id = entity.GlobalId
if ifc_attribute in ("RelatingSpace", "RelatedBuildingElement"):
op = row.operator("bim.select_related_element_boundaries", text="", icon="RESTRICT_SELECT_OFF")
op.related_element = entity.id()
op = row.operator("bim.select_related_element_type_boundaries", text="", icon="ASSET_MANAGER")
op.related_element = entity.id()
else:
row.label(text="")