diff --git a/src/blenderbim/blenderbim/bim/module/profile/__init__.py b/src/blenderbim/blenderbim/bim/module/profile/__init__.py index d1ac725aeb..69a153e315 100644 --- a/src/blenderbim/blenderbim/bim/module/profile/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/profile/__init__.py @@ -29,7 +29,7 @@ classes = ( operator.EnableEditingArbitraryProfile, operator.EnableEditingProfile, operator.LoadProfiles, - operator.PurgeOrphanProfiles, + operator.PurgeUnusedProfiles, operator.RemoveProfileDef, prop.Profile, prop.BIMProfileProperties, diff --git a/src/blenderbim/blenderbim/bim/module/profile/operator.py b/src/blenderbim/blenderbim/bim/module/profile/operator.py index 03ecf10c6c..c8cc8c3925 100644 --- a/src/blenderbim/blenderbim/bim/module/profile/operator.py +++ b/src/blenderbim/blenderbim/bim/module/profile/operator.py @@ -216,15 +216,14 @@ class EditArbitraryProfile(bpy.types.Operator, tool.Ifc.Operator): model_profile.DumbProfileRegenerator().regenerate_from_profile_def(profile) -class PurgeOrphanProfiles(bpy.types.Operator, tool.Ifc.Operator): - bl_idname = "bim.purge_orphan_profiles" - bl_label = "Purge Orphan Profiles" +class PurgeUnusedProfiles(bpy.types.Operator, tool.Ifc.Operator): + bl_idname = "bim.purge_unused_profiles" + bl_label = "Purge Unused Profiles" bl_options = {"REGISTER", "UNDO"} def _execute(self, context): 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) + core.purge_unused_profiles(tool.Ifc, tool.Profile) if props.is_editing: refresh() bpy.ops.bim.load_profiles() diff --git a/src/blenderbim/blenderbim/bim/module/project/ui.py b/src/blenderbim/blenderbim/bim/module/project/ui.py index 129b23cf38..d994a193df 100644 --- a/src/blenderbim/blenderbim/bim/module/project/ui.py +++ b/src/blenderbim/blenderbim/bim/module/project/ui.py @@ -393,4 +393,5 @@ class BIM_PT_purge(Panel): def draw(self, context): layout = self.layout - layout.operator("bim.purge_orphan_profiles") + layout.operator("bim.purge_unused_profiles") + layout.operator("bim.purge_unused_types") diff --git a/src/blenderbim/blenderbim/core/profile.py b/src/blenderbim/blenderbim/core/profile.py index f4f36badc8..7f2e53b061 100644 --- a/src/blenderbim/blenderbim/core/profile.py +++ b/src/blenderbim/blenderbim/core/profile.py @@ -17,9 +17,8 @@ # along with BlenderBIM Add-on. If not, see . -def purge_orphan_profiles(ifc, profiles_ids): - for profile_id in profiles_ids: - profile_ifc = ifc.get().by_id(profile_id) - if ifc.get().get_total_inverses(profile_ifc) > 0: +def purge_unused_profiles(ifc, profile): + for element_profile in profile.get_model_profiles(): + if ifc.get().get_total_inverses(element_profile) > 0: continue - ifc.run("profile.remove_profile", profile=profile_ifc) + ifc.run("profile.remove_profile", profile=element_profile) diff --git a/src/blenderbim/blenderbim/tool/profile.py b/src/blenderbim/blenderbim/tool/profile.py index 1a1fd9f949..92086a91ca 100644 --- a/src/blenderbim/blenderbim/tool/profile.py +++ b/src/blenderbim/blenderbim/tool/profile.py @@ -21,6 +21,7 @@ import ifcopenshell.util.unit import ifcopenshell.util.placement import ifcopenshell.util.representation import blenderbim.core.tool +import blenderbim.tool as tool from blenderbim.bim.module.model.decorator import ProfileDecorator @@ -70,3 +71,7 @@ class Profile(blenderbim.core.tool.Profile): if profile: return profile return None + + @classmethod + def get_model_profiles(cls): + return tool.Ifc.get().by_type("IfcProfileDef")