fix #4051: filter to only show IfcProfileDefs that are attached to IfcMaterialProfiles

This commit is contained in:
Ryan Schultz
2024-10-13 11:24:41 -05:00
parent 2f0500a14b
commit a1fb4d6b81
3 changed files with 19 additions and 0 deletions
@@ -37,7 +37,14 @@ class LoadProfiles(bpy.types.Operator):
props = context.scene.BIMProfileProperties
props.profiles.clear()
filter_material_profiles = props.is_filtering_material_profiles
for profile in tool.Ifc.get().by_type("IfcProfileDef"):
if filter_material_profiles:
inverse_references = tool.Ifc.get().get_inverse(profile)
related_material_profiles = [ref for ref in inverse_references if ref.is_a('IfcMaterialProfile')]
if not related_material_profiles:
continue
if not profile.ProfileName:
continue
new = props.profiles.add()
@@ -66,6 +66,14 @@ class BIMProfileProperties(PropertyGroup):
active_arbitrary_profile_id: IntProperty(name="Active Arbitrary Profile Id")
profile_attributes: CollectionProperty(name="Profile Attributes", type=Attribute)
profile_classes: EnumProperty(items=get_profile_classes, name="Profile Classes")
is_filtering_material_profiles: bpy.props.BoolProperty(
name="Filter Material Profiles",
default=False,
description="Check to only show IfcProfileDefs attached to IfcMaterialProfiles",
update=lambda self, context: bpy.ops.bim.load_profiles()
)
def generate_thumbnail_for_active_profile():
@@ -83,6 +83,10 @@ class BIM_PT_profiles(Panel):
self.props,
"active_profile_index",
)
row = self.layout.row()
row.prop(self.props, "is_filtering_material_profiles", text="Filter Material Profiles")
if active_profile:
if active_profile.ifc_class in (
"IfcArbitraryClosedProfileDef",