you can now filter structural loads based on name and inverse references

This commit is contained in:
Jesusbill
2021-06-20 20:53:45 +02:00
parent aadb28bb79
commit a0b7fe2736
4 changed files with 47 additions and 6 deletions
@@ -43,6 +43,7 @@ classes = (
operator.DisableEditingStructuralLoad,
operator.RemoveStructuralLoad,
operator.EditStructuralLoad,
operator.ToggleFilterStructuralLoads,
prop.StructuralAnalysisModel,
prop.StructuralActivity,
prop.StructuralLoad,
@@ -761,13 +761,29 @@ class LoadStructuralLoads(bpy.types.Operator):
bl_label = "Load Structural Loads"
def execute(self, context):
self.file = IfcStore.get_file()
props = context.scene.BIMStructuralProperties
while len(props.structural_loads) > 0:
props.structural_loads.remove(0)
for ifc_definition_id, structural_loads in Data.structural_loads.items():
new = props.structural_loads.add()
new.ifc_definition_id = ifc_definition_id
new.name = structural_loads["Name"] or "Unnamed"
if props.filtered_structural_loads:
names = [structural_load["Name"] or "Unnamed" for _, structural_load in Data.structural_loads.items()]
for ifc_definition_id, structural_load in Data.structural_loads.items():
if (
names.count(structural_load["Name"] or "Unnamed") > 1
and len(self.file.get_inverse(self.file.by_id(ifc_definition_id))) < 2
):
continue
new = props.structural_loads.add()
new.ifc_definition_id = ifc_definition_id
new.name = structural_load["Name"] or "Unnamed"
new.number_of_inverse_references = len(self.file.get_inverse(self.file.by_id(ifc_definition_id)))
else:
for ifc_definition_id, structural_load in Data.structural_loads.items():
new = props.structural_loads.add()
new.ifc_definition_id = ifc_definition_id
new.name = structural_load["Name"] or "Unnamed"
new.number_of_inverse_references = len(self.file.get_inverse(self.file.by_id(ifc_definition_id)))
props.is_editing_loads = True
bpy.ops.bim.disable_editing_structural_load()
return {"FINISHED"}
@@ -859,3 +875,16 @@ class EditStructuralLoad(bpy.types.Operator):
Data.load(IfcStore.get_file())
bpy.ops.bim.load_structural_loads()
return {"FINISHED"}
class ToggleFilterStructuralLoads(bpy.types.Operator):
bl_idname = "bim.toggle_filter_structural_loads"
bl_label = "Toggle Filter Structural Loads"
def execute(self, context):
props = context.scene.BIMStructuralProperties
props.filtered_structural_loads = not props.filtered_structural_loads
bpy.ops.bim.load_structural_loads()
return {"FINISHED"}
@@ -112,6 +112,7 @@ class StructuralActivity(PropertyGroup):
class StructuralLoad(PropertyGroup):
name: StringProperty(name="Name")
ifc_definition_id: IntProperty(name="IFC Definition ID")
number_of_inverse_references: IntProperty(name="Number of Inverse References")
class BIMStructuralProperties(PropertyGroup):
@@ -137,12 +138,15 @@ class BIMStructuralProperties(PropertyGroup):
)
load_group_activities: CollectionProperty(name="Load Group Activities", type=StructuralActivity)
active_load_group_activity_index: IntProperty(name="Active Load Group Activity Index")
structural_loads: CollectionProperty(name="Structural Loads", type=StructuralLoad)
active_structural_load_index: IntProperty(name="Active Structural Load Index")
active_structural_load_id: IntProperty(name="Active Structural Load Id")
is_editing_loads: BoolProperty(name="Is Editing Loads", default=False)
structural_load_types: EnumProperty(items=getStructuralLoadTypes, name="Structural Load Types")
structural_load_attributes: CollectionProperty(name="Structural Load Attributes", type=Attribute)
filtered_structural_loads: BoolProperty(name="Filtered Structural Loads", default=False)
class BIMObjectStructuralProperties(PropertyGroup):
@@ -453,11 +453,18 @@ class BIM_PT_structural_loads(Panel):
self.props = context.scene.BIMStructuralProperties
row = self.layout.row(align=True)
row.label(text="{} Structural Loads Found".format(len(Data.structural_loads)), icon="GHOST_ENABLED")
row.label(text="{} Structural Loads Found".format(len(Data.structural_loads)), icon="ANIM_DATA")
if self.props.is_editing_loads:
row.operator(
"bim.toggle_filter_structural_loads",
text="FILTER - OFF" if not self.props.filtered_structural_loads else "FILTER - ON",
icon="FILTER",
)
row.operator("bim.disable_structural_load_editing_ui", text="", icon="SCREEN_BACK")
row = self.layout.row(align=True)
row.prop(self.props, "structural_load_types", text="")
row.operator("bim.add_structural_load", text="", icon="ADD").ifc_class = self.props.structural_load_types
row.operator("bim.disable_structural_load_editing_ui", text="", icon="CANCEL")
else:
row.operator("bim.load_structural_loads", text="", icon="GREASEPENCIL")