mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Active profil users count is now dynamically fetched when the profile is clicked in the UI list
This commit is contained in:
@@ -36,7 +36,7 @@ class ProfileData:
|
||||
def load(cls):
|
||||
cls.data = {
|
||||
"total_profiles": cls.total_profiles(),
|
||||
"profiles_users": cls.profiles_users(),
|
||||
"active_profile_users": cls.active_profile_users(),
|
||||
"profile_classes": cls.profile_classes(),
|
||||
"is_arbitrary_profile": cls.is_arbitrary_profile(),
|
||||
"is_editing_arbitrary_profile": cls.is_editing_arbitrary_profile(),
|
||||
@@ -48,14 +48,11 @@ class ProfileData:
|
||||
return len([p for p in tool.Ifc.get().by_type("IfcProfileDef") if p.ProfileName])
|
||||
|
||||
@classmethod
|
||||
def profiles_users(cls):
|
||||
profile_id_to_users = {}
|
||||
for profile_prop in bpy.context.scene.BIMProfileProperties.profiles:
|
||||
profile_id = profile_prop.ifc_definition_id
|
||||
profile_ifc = tool.Ifc.get().by_id(profile_id)
|
||||
profile_users = tool.Ifc.get().get_total_inverses(profile_ifc)
|
||||
profile_id_to_users[profile_id] = profile_users
|
||||
return profile_id_to_users
|
||||
def active_profile_users(cls):
|
||||
profiles_props = bpy.context.scene.BIMProfileProperties
|
||||
profile_prop = profiles_props.profiles[profiles_props.active_profile_index]
|
||||
profile_ifc = tool.Ifc.get().by_id(profile_prop.ifc_definition_id)
|
||||
return tool.Ifc.get().get_total_inverses(profile_ifc)
|
||||
|
||||
@classmethod
|
||||
def profile_classes(cls):
|
||||
|
||||
@@ -222,6 +222,9 @@ class PurgeOrphanProfiles(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def _execute(self, context):
|
||||
profiles_ids = [profile_prop.ifc_definition_id for profile_prop in context.scene.BIMProfileProperties.profiles]
|
||||
props = context.scene.BIMProfileProperties
|
||||
profiles_ids = [profile_prop.ifc_definition_id for profile_prop in props.profiles]
|
||||
core.purge_orphan_profiles(tool.Ifc, profiles_ids=profiles_ids)
|
||||
bpy.ops.bim.load_profiles()
|
||||
if props.is_editing:
|
||||
refresh()
|
||||
bpy.ops.bim.load_profiles()
|
||||
|
||||
@@ -49,10 +49,14 @@ class Profile(PropertyGroup):
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
|
||||
|
||||
def update_active_profile_index(self, context):
|
||||
ProfileData.data["active_profile_users"] = ProfileData.active_profile_users()
|
||||
|
||||
|
||||
class BIMProfileProperties(PropertyGroup):
|
||||
is_editing: BoolProperty(name="Is Editing")
|
||||
profiles: CollectionProperty(name="Profiles", type=Profile)
|
||||
active_profile_index: IntProperty(name="Active Profile Index")
|
||||
active_profile_index: IntProperty(name="Active Profile Index", update=update_active_profile_index)
|
||||
active_profile_id: IntProperty(name="Active Profile Id")
|
||||
active_arbitrary_profile_id: IntProperty(name="Active Arbitrary Profile Id")
|
||||
profile_attributes: CollectionProperty(name="Profile Attributes", type=Attribute)
|
||||
|
||||
@@ -94,7 +94,7 @@ class BIM_PT_profiles(Panel):
|
||||
"bim.enable_editing_arbitrary_profile", text="Edit Arbitrary Profile", icon="GREASEPENCIL"
|
||||
)
|
||||
|
||||
users_of_profile = ProfileData.data["profiles_users"][active_profile.ifc_definition_id]
|
||||
users_of_profile = ProfileData.data["active_profile_users"]
|
||||
self.layout.label(icon="INFO", text=f"Profile has {users_of_profile} inverse relationship(s) in project")
|
||||
|
||||
if self.props.active_profile_id:
|
||||
|
||||
Reference in New Issue
Block a user