Added a button to Load the smart clash groups for the active clash set

This commit is contained in:
Vincent Cadoret
2020-11-21 18:43:07 -05:00
committed by Dion Moult
parent 8aae7c95e6
commit ac12a6785c
3 changed files with 39 additions and 10 deletions
@@ -147,6 +147,7 @@ if bpy is not None:
operator.SelectSmartGroupedClashesPath,
operator.SmartClashGroup,
operator.SelectSmartGroup,
operator.LoadSmartGroupsForActiveClashSet,
operator.SwitchContext,
operator.RemoveContext,
operator.OpenUpstream,
@@ -1903,21 +1903,13 @@ class SelectIfcClashResults(bpy.types.Operator):
class SmartClashGroup(bpy.types.Operator):
bl_idname = "bim.smart_clash_group"
bl_label = "Smart Clash Group"
# filename_ext = ".json"
bl_label = "Smart Group Clashes"
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):
import ifcclash
settings = ifcclash.IfcClashSettings()
# self.filepath = bpy.path.ensure_ext(self.filepath, ".json")
self.filepath = bpy.path.ensure_ext(bpy.context.scene.BIMProperties.clash_results_path, ".json")
settings.output = self.filepath
settings.logger = logging.getLogger("Clash")
@@ -1958,6 +1950,40 @@ class SmartClashGroup(bpy.types.Operator):
return {"FINISHED"}
class LoadSmartGroupsForActiveClashSet(bpy.types.Operator):
bl_idname = "bim.load_smart_groups_for_active_clash_set"
bl_label = "Load Smart Groups for Active Clash Set"
def execute(self, context):
smart_groups_path = bpy.path.ensure_ext(bpy.context.scene.BIMProperties.smart_grouped_clashes_path, ".json")
clash_set_name = bpy.context.scene.BIMProperties.clash_sets[
bpy.context.scene.BIMProperties.active_clash_set_index
].name
with open(smart_groups_path) as f:
smart_grouped_clashes = json.load(f)
# Reset the list of smart_clash_groups for the UI
bpy.context.scene.BIMProperties.smart_clash_groups.clear()
for clash_set, smart_groups in smart_grouped_clashes.items():
# Only select the clashes that correspond to the actively selected IFC Clash Set
if clash_set != clash_set_name:
continue
else:
for smart_group, global_id_pairs in smart_groups[0].items():
new_group = bpy.context.scene.BIMProperties.smart_clash_groups.add()
new_group.number = int(smart_group)
for pair in global_id_pairs:
for id in pair:
new_global_id = new_group.global_ids.add()
new_global_id.name = id
return {"FINISHED"}
class SelectSmartGroup(bpy.types.Operator):
bl_idname = "bim.select_smart_group"
bl_label = "Select Smart Group"
+3 -1
View File
@@ -2107,7 +2107,6 @@ class BIM_UL_smart_groups(bpy.types.UIList):
ob = data
if item:
layout.label(text=str(item.number), translate=False, icon='NONE', icon_value=0)
#layout.prop(item, "number", text="", emboss=False, icon_value=icon)
else:
layout.label(text="", translate=False)
@@ -2392,6 +2391,9 @@ class BIM_PT_clash_manager(Panel):
row = layout.row(align=True)
row.operator("bim.smart_clash_group")
row = layout.row(align=True)
row.operator("bim.load_smart_groups_for_active_clash_set")
layout.template_list('BIM_UL_smart_groups', '', props, 'smart_clash_groups', props, 'active_smart_group_index')