From 1921b4cecfbfbef4b54de37e24b0709a7c26351c Mon Sep 17 00:00:00 2001 From: Vincent Cadoret Date: Fri, 6 Nov 2020 21:14:21 -0500 Subject: [PATCH] Added clash manager basic interface to load smart grouped clashes --- .../blenderbim/bim/__init__.py | 2 ++ .../blenderbim/bim/operator.py | 29 +++++++++++++++++++ src/ifcblenderexport/blenderbim/bim/ui.py | 13 +++++++++ 3 files changed, 44 insertions(+) diff --git a/src/ifcblenderexport/blenderbim/bim/__init__.py b/src/ifcblenderexport/blenderbim/bim/__init__.py index 86c83ad22a..7a4e7039cb 100644 --- a/src/ifcblenderexport/blenderbim/bim/__init__.py +++ b/src/ifcblenderexport/blenderbim/bim/__init__.py @@ -143,6 +143,7 @@ if bpy is not None: operator.SelectClashSource, operator.ExecuteIfcClash, operator.SelectIfcClashResults, + operator.SmartClashGroup, operator.SwitchContext, operator.RemoveContext, operator.OpenUpstream, @@ -319,6 +320,7 @@ if bpy is not None: ui.BIM_PT_modeling_utilities, ui.BIM_PT_annotation_utilities, ui.BIM_PT_qto_utilities, + ui.BIM_PT_clash_manager, ui.BIM_PT_misc_utilities, ui.BIM_UL_generic, ui.BIM_UL_clash_sets, diff --git a/src/ifcblenderexport/blenderbim/bim/operator.py b/src/ifcblenderexport/blenderbim/bim/operator.py index 5cb3b3b0e9..0c1cc29695 100644 --- a/src/ifcblenderexport/blenderbim/bim/operator.py +++ b/src/ifcblenderexport/blenderbim/bim/operator.py @@ -1873,7 +1873,36 @@ class SelectIfcClashResults(bpy.types.Operator): obj.select_set(True) return {"FINISHED"} +class SmartClashGroup(bpy.types.Operator): + bl_idname = "bim.smart_clash_group" + bl_label = "Smart Clash Group" + filename_ext = ".json" + filepath: bpy.props.StringProperty(subtype="FILE_PATH") + def invoke(self, context, event): + self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".json") + WindowManager = context.window_manager + WindowManager.fileselect_add(self) + return {"RUNNING_MODAL"} + + def execute(self, context): + self.filepath = bpy.path.ensure_ext(self.filepath, ".json") + with open(self.filepath) as f: + clash_sets = json.load(f) + + for obj in bpy.context.visible_objects: + global_id = obj.BIMObjectProperties.attributes.get("GlobalId") + if global_id: + for smart_groups in clash_sets.values(): + for smart_group_list in smart_groups: + for smart_group, clashes in smart_group_list.items(): + for id in clashes: + if global_id.string_value in id: + print("object match: ", global_id) + obj.select_set(True) + + return {"FINISHED"} + class SelectBcfFile(bpy.types.Operator): bl_idname = "bim.select_bcf_file" bl_label = "Select BCF File" diff --git a/src/ifcblenderexport/blenderbim/bim/ui.py b/src/ifcblenderexport/blenderbim/bim/ui.py index 42aad30b43..13e1591454 100644 --- a/src/ifcblenderexport/blenderbim/bim/ui.py +++ b/src/ifcblenderexport/blenderbim/bim/ui.py @@ -2357,6 +2357,19 @@ class BIM_PT_qto_utilities(Panel): row = layout.row(align=True) row.operator("bim.calculate_object_volumes") +class BIM_PT_clash_manager(Panel): + bl_idname = "BIM_PT_clash_manager" + bl_label = "Clash Manager" + bl_space_type = "VIEW_3D" + bl_region_type = "UI" + bl_category = "BlenderBIM" + + def draw(self, context): + layout = self.layout + props = context.scene.BIMProperties + + row = layout.row(align=True) + row.operator("bim.smart_clash_group") class BIM_PT_misc_utilities(Panel): bl_idname = "BIM_PT_misc_utilities"