mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
You can now purge types from the Purge data panel
And refactor a bit the purge profiles code to make use of the profile tool module
This commit is contained in:
@@ -29,7 +29,7 @@ classes = (
|
||||
operator.EnableEditingArbitraryProfile,
|
||||
operator.EnableEditingProfile,
|
||||
operator.LoadProfiles,
|
||||
operator.PurgeOrphanProfiles,
|
||||
operator.PurgeUnusedProfiles,
|
||||
operator.RemoveProfileDef,
|
||||
prop.Profile,
|
||||
prop.BIMProfileProperties,
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
# 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:
|
||||
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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user