mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
enhance ui for ifc-diff
This commit is contained in:
@@ -92,6 +92,7 @@ classes = [
|
||||
operator.SelectIfcFile,
|
||||
operator.SelectSchemaDir,
|
||||
operator.SelectURIAttribute,
|
||||
operator.EditBlenderCollection,
|
||||
prop.StrProperty,
|
||||
operator.BIM_OT_enum_property_search, # /!\ Register AFTER prop.StrProperty
|
||||
prop.ObjProperty,
|
||||
|
||||
@@ -25,6 +25,7 @@ classes = (
|
||||
operator.SelectDiffOldFile,
|
||||
operator.SelectDiffNewFile,
|
||||
operator.ExecuteIfcDiff,
|
||||
prop.Relationships,
|
||||
prop.DiffProperties,
|
||||
ui.BIM_PT_diff,
|
||||
)
|
||||
|
||||
@@ -114,10 +114,11 @@ class ExecuteIfcDiff(bpy.types.Operator):
|
||||
context.scene.DiffProperties.diff_old_file,
|
||||
context.scene.DiffProperties.diff_new_file,
|
||||
self.filepath,
|
||||
context.scene.DiffProperties.diff_relationships.split(),
|
||||
[r.relationship for r in context.scene.DiffProperties.diff_relationships],
|
||||
context.scene.DiffProperties.diff_filter_elements,
|
||||
)
|
||||
ifc_diff.diff()
|
||||
diff = ifc_diff.diff()
|
||||
ifc_diff.export()
|
||||
context.scene.DiffProperties.diff_json_file = self.filepath
|
||||
context.scene.DiffProperties.diff_result = diff
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -30,10 +30,16 @@ from bpy.props import (
|
||||
CollectionProperty,
|
||||
)
|
||||
|
||||
class Relationships(PropertyGroup):
|
||||
relationship: EnumProperty(
|
||||
name="Relationship",
|
||||
items=[(r,r,r) for r in ["type", "property", "container", "aggregate", "classification"]],
|
||||
)
|
||||
|
||||
class DiffProperties(PropertyGroup):
|
||||
diff_json_file: StringProperty(default="", name="Diff JSON File")
|
||||
diff_old_file: StringProperty(default="", name="Diff Old IFC File")
|
||||
diff_new_file: StringProperty(default="", name="Diff New IFC File")
|
||||
diff_relationships: StringProperty(default="", name="Diff Relationships")
|
||||
diff_relationships: CollectionProperty(type=Relationships, name="Diff Relationships")
|
||||
diff_filter_elements: StringProperty(default="", name="Diff Filter")
|
||||
diff_result: StringProperty(default="", name="Diff Result")
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
from bpy.types import Panel
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
import blenderbim.tool as tool
|
||||
import json
|
||||
|
||||
|
||||
class BIM_PT_diff(Panel):
|
||||
@@ -48,15 +50,52 @@ class BIM_PT_diff(Panel):
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(bim_properties, "diff_relationships")
|
||||
row.context_pointer_set("bim_prop_group", bim_properties)
|
||||
add = row.operator("bim.edit_blender_collection", icon="ADD", text="")
|
||||
add.option = "add"
|
||||
add.collection = "diff_relationships"
|
||||
|
||||
for index, r in enumerate(bim_properties.diff_relationships):
|
||||
row = layout.row(align=True)
|
||||
row.context_pointer_set("bim_prop_group", bim_properties)
|
||||
row.prop(r, "relationship", text=" ")
|
||||
remove = row.operator("bim.edit_blender_collection", icon="REMOVE", text="")
|
||||
remove.option = "remove"
|
||||
remove.collection = "diff_relationships"
|
||||
remove.index = index
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.prop(bim_properties, "diff_filter_elements")
|
||||
row.operator("bim.ifc_selector", icon="FILTER", text="")
|
||||
|
||||
row = layout.row()
|
||||
row.operator("bim.execute_ifc_diff")
|
||||
if bim_properties.diff_result:
|
||||
row = layout.row()
|
||||
row.alignment = "CENTER"
|
||||
row.label(text=bim_properties.diff_result)
|
||||
|
||||
# TODO: show if there ifc diff operation is sucessful
|
||||
row = layout.row(align=True)
|
||||
row.prop(bim_properties, "diff_json_file")
|
||||
row.operator("bim.select_diff_json_file", icon="FILE_FOLDER", text="")
|
||||
row.operator("bim.visualise_diff", icon="HIDE_OFF", text="")
|
||||
|
||||
|
||||
# Show diff results #
|
||||
if bim_properties.diff_json_file:
|
||||
with open(context.scene.DiffProperties.diff_json_file, "r") as file:
|
||||
results = json.load(file)
|
||||
if results:
|
||||
row = layout.row()
|
||||
row = layout.row()
|
||||
row.label(text="Diff Results:")
|
||||
for g in results["changed"]:
|
||||
obj = tool.Ifc.get_entity(context.active_object)
|
||||
if obj.GlobalId == g:
|
||||
for k,v in results["changed"][g].items():
|
||||
row = layout.row()
|
||||
row.alignment = "LEFT"
|
||||
row.label(text=f"{str(k).upper()}: {str(v)}")
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import bpy
|
||||
from . import ui, prop, operator
|
||||
|
||||
classes = (
|
||||
operator.EditBlenderCollection,
|
||||
operator.ActivateIfcClassFilter,
|
||||
operator.ActivateIfcBuildingStoreyFilter,
|
||||
operator.ColourByAttribute,
|
||||
|
||||
@@ -69,22 +69,6 @@ def does_keyword_exist(pattern, string, context):
|
||||
return True
|
||||
|
||||
|
||||
class EditBlenderCollection(Operator):
|
||||
bl_idname = "bim.edit_blender_collection"
|
||||
bl_label = "Add or Remove blender collection item"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
option: StringProperty()
|
||||
collection: StringProperty()
|
||||
index: IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
if self.option == "add":
|
||||
getattr(context.bim_prop_group, self.collection).add()
|
||||
else:
|
||||
getattr(context.bim_prop_group, self.collection).remove(self.index)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class SelectGlobalId(Operator):
|
||||
"""Click to select the objects that match with the given Global ID"""
|
||||
|
||||
@@ -562,7 +546,7 @@ class FilterModelElements(Operator):
|
||||
if obj.BIMObjectProperties.ifc_definition_id in sel_element_ids:
|
||||
obj.hide_set(True)
|
||||
|
||||
|
||||
#This needs to be moved into ui code, I know ;) - vulevukusej
|
||||
class IfcSelector(Operator):
|
||||
"""Select elements in model with IFC Selector"""
|
||||
|
||||
@@ -581,7 +565,6 @@ class IfcSelector(Operator):
|
||||
|
||||
def draw(self, context):
|
||||
from . import ui
|
||||
|
||||
ui.IfcSelectorUI.draw(context, self.layout)
|
||||
|
||||
|
||||
|
||||
@@ -595,3 +595,18 @@ class BIM_OT_enum_property_search(bpy.types.Operator):
|
||||
values = [values]
|
||||
for value in values:
|
||||
self.add_item(identifier=key, name=key + " (" + value + ")")
|
||||
|
||||
class EditBlenderCollection(bpy.types.Operator):
|
||||
bl_idname = "bim.edit_blender_collection"
|
||||
bl_label = "Add or Remove blender collection item"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
option: bpy.props.StringProperty(description="add or remove item from collection")
|
||||
collection: bpy.props.StringProperty(description="collection to be edited")
|
||||
index: bpy.props.IntProperty(description="index of item to be removed")
|
||||
|
||||
def execute(self, context):
|
||||
if self.option == "add":
|
||||
getattr(context.bim_prop_group, self.collection).add()
|
||||
else:
|
||||
getattr(context.bim_prop_group, self.collection).remove(self.index)
|
||||
return {"FINISHED"}
|
||||
|
||||
Reference in New Issue
Block a user