mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
You can now purge unused profiles
This commit is contained in:
@@ -29,6 +29,7 @@ classes = (
|
|||||||
operator.EnableEditingArbitraryProfile,
|
operator.EnableEditingArbitraryProfile,
|
||||||
operator.EnableEditingProfile,
|
operator.EnableEditingProfile,
|
||||||
operator.LoadProfiles,
|
operator.LoadProfiles,
|
||||||
|
operator.PurgeOrphanProfiles,
|
||||||
operator.RemoveProfileDef,
|
operator.RemoveProfileDef,
|
||||||
prop.Profile,
|
prop.Profile,
|
||||||
prop.BIMProfileProperties,
|
prop.BIMProfileProperties,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import ifcopenshell.api
|
|||||||
import blenderbim.bim.helper
|
import blenderbim.bim.helper
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
import blenderbim.bim.module.model.profile as model_profile
|
import blenderbim.bim.module.model.profile as model_profile
|
||||||
|
import blenderbim.core.profile as core
|
||||||
from blenderbim.bim.module.model.decorator import ProfileDecorator
|
from blenderbim.bim.module.model.decorator import ProfileDecorator
|
||||||
from blenderbim.bim.module.profile.prop import generate_thumbnail_for_active_profile
|
from blenderbim.bim.module.profile.prop import generate_thumbnail_for_active_profile
|
||||||
from blenderbim.bim.module.profile.data import refresh
|
from blenderbim.bim.module.profile.data import refresh
|
||||||
@@ -213,3 +214,14 @@ class EditArbitraryProfile(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
props.active_arbitrary_profile_id = 0
|
props.active_arbitrary_profile_id = 0
|
||||||
|
|
||||||
model_profile.DumbProfileRegenerator().regenerate_from_profile_def(profile)
|
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"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
def _execute(self, context):
|
||||||
|
profiles_ids = [profile_prop.ifc_definition_id for profile_prop in context.scene.BIMProfileProperties.profiles]
|
||||||
|
core.purge_orphan_profiles(tool.Ifc, profiles_ids=profiles_ids)
|
||||||
|
bpy.ops.bim.load_profiles()
|
||||||
|
|||||||
@@ -79,21 +79,24 @@ class BIM_PT_profiles(Panel):
|
|||||||
self.props,
|
self.props,
|
||||||
"active_profile_index",
|
"active_profile_index",
|
||||||
)
|
)
|
||||||
if active_profile and active_profile.ifc_class in (
|
if active_profile:
|
||||||
"IfcArbitraryClosedProfileDef",
|
if active_profile.ifc_class in (
|
||||||
"IfcArbitraryProfileDefWithVoids",
|
"IfcArbitraryClosedProfileDef",
|
||||||
):
|
"IfcArbitraryProfileDefWithVoids",
|
||||||
if self.props.active_arbitrary_profile_id:
|
):
|
||||||
row = self.layout.row(align=True)
|
if self.props.active_arbitrary_profile_id:
|
||||||
row.operator("bim.edit_arbitrary_profile", text="Save Arbitrary Profile", icon="CHECKMARK")
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.disable_editing_arbitrary_profile", text="", icon="CANCEL")
|
row.operator("bim.edit_arbitrary_profile", text="Save Arbitrary Profile", icon="CHECKMARK")
|
||||||
else:
|
row.operator("bim.disable_editing_arbitrary_profile", text="", icon="CANCEL")
|
||||||
row = self.layout.row()
|
else:
|
||||||
row.operator("bim.enable_editing_arbitrary_profile", text="Edit Arbitrary Profile", icon="GREASEPENCIL")
|
row = self.layout.row()
|
||||||
|
row.operator(
|
||||||
|
"bim.enable_editing_arbitrary_profile", text="Edit Arbitrary Profile", icon="GREASEPENCIL"
|
||||||
|
)
|
||||||
|
|
||||||
profile_entity = tool.Ifc.get().by_id(active_profile.ifc_definition_id)
|
profile_entity = tool.Ifc.get().by_id(active_profile.ifc_definition_id)
|
||||||
users_of_profile = tool.Ifc.get().get_total_inverses(profile_entity)
|
users_of_profile = tool.Ifc.get().get_total_inverses(profile_entity)
|
||||||
self.layout.label(icon="INFO", text=f"Profile has {users_of_profile} inverse relationship(s) in project")
|
self.layout.label(icon="INFO", text=f"Profile has {users_of_profile} inverse relationship(s) in project")
|
||||||
|
|
||||||
if self.props.active_profile_id:
|
if self.props.active_profile_id:
|
||||||
self.draw_editable_ui(context)
|
self.draw_editable_ui(context)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ classes = (
|
|||||||
ui.BIM_PT_project,
|
ui.BIM_PT_project,
|
||||||
ui.BIM_PT_project_library,
|
ui.BIM_PT_project_library,
|
||||||
ui.BIM_PT_links,
|
ui.BIM_PT_links,
|
||||||
|
ui.BIM_PT_purge,
|
||||||
ui.BIM_UL_library,
|
ui.BIM_UL_library,
|
||||||
ui.BIM_UL_filter_categories,
|
ui.BIM_UL_filter_categories,
|
||||||
ui.BIM_UL_links,
|
ui.BIM_UL_links,
|
||||||
|
|||||||
@@ -381,3 +381,16 @@ class BIM_UL_links(UIList):
|
|||||||
op.filepath = item.name
|
op.filepath = item.name
|
||||||
op = row.operator("bim.unlink_ifc", text="", icon="X")
|
op = row.operator("bim.unlink_ifc", text="", icon="X")
|
||||||
op.filepath = item.name
|
op.filepath = item.name
|
||||||
|
|
||||||
|
|
||||||
|
class BIM_PT_purge(Panel):
|
||||||
|
bl_label = "Purge Data"
|
||||||
|
bl_options = {"DEFAULT_CLOSED"}
|
||||||
|
bl_space_type = "PROPERTIES"
|
||||||
|
bl_region_type = "WINDOW"
|
||||||
|
bl_context = "scene"
|
||||||
|
bl_parent_id = "BIM_PT_tab_quality_control"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.operator("bim.purge_orphan_profiles")
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||||
|
# Copyright (C) 2023 Dion Moult <dion@thinkmoult.com>
|
||||||
|
#
|
||||||
|
# This file is part of BlenderBIM Add-on.
|
||||||
|
#
|
||||||
|
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# BlenderBIM Add-on is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
||||||
|
continue
|
||||||
|
ifc.run("profile.remove_profile", profile=profile_ifc)
|
||||||
Reference in New Issue
Block a user