Meshes are auto updated in the IFC as well when edit mode is toggled now.

This commit is contained in:
Dion Moult
2021-02-23 19:19:06 +11:00
parent 28fbf0ea99
commit 1e22dbca1e
4 changed files with 36 additions and 3 deletions
+30 -1
View File
@@ -5,6 +5,36 @@ from bpy.app.handlers import persistent
from blenderbim.bim.ifc import IfcStore
def mode_callback(obj, data):
if (
obj.mode != "OBJECT"
or not obj.data
or not isinstance(obj.data, bpy.types.Mesh)
or not obj.data.BIMMeshProperties.ifc_definition_id
or not bpy.context.scene.BIMGeometryProperties.should_auto_update_mesh_representations
):
return
representation = IfcStore.get_file().by_id(obj.data.BIMMeshProperties.ifc_definition_id)
if representation.RepresentationType == "Tessellation" or representation.RepresentationType == "Brep":
bpy.ops.bim.update_mesh_representation(obj=obj.name)
def subscribe_to(object, data_path, callback):
subscribe_to = object.path_resolve(data_path, False)
bpy.msgbus.subscribe_rna(
key=subscribe_to,
owner=object,
args=(
object,
data_path,
),
notify=callback,
options={
"PERSISTENT",
},
)
@persistent
def loadIfcStore(scene):
IfcStore.file = None
@@ -31,7 +61,6 @@ def loadIfcStore(scene):
@persistent
def ensureIfcExported(scene):
print('ensuring')
if IfcStore.get_file() and not bpy.context.scene.BIMProperties.ifc_file:
# The invocation pops up a file select window.
# This is non-blocking, therefore the Blend file is saved before we export.
@@ -1,5 +1,6 @@
import bpy
import ifcopenshell
import blenderbim.bim.handler
class IfcStore:
@@ -36,6 +37,7 @@ class IfcStore:
if hasattr(element, "GlobalId"):
IfcStore.guid_map[element.GlobalId] = obj
obj.BIMObjectProperties.ifc_definition_id = element.id()
blenderbim.bim.handler.subscribe_to(obj, "mode", blenderbim.bim.handler.mode_callback)
@staticmethod
def unlink_element(element, obj=None):
@@ -14,6 +14,7 @@ from bpy.props import (
class BIMGeometryProperties(PropertyGroup):
should_auto_update_mesh_representations: BoolProperty(name="Should Auto Update Representations", default=True)
# Revit workaround
should_use_presentation_style_assignment: BoolProperty(name="Force Presentation Style Assignment", default=False)
# RIB iTwo, DESITE BIM workaround
@@ -66,8 +66,9 @@ class BIM_PT_mesh(Panel):
layout = self.layout
props = context.active_object.data.BIMMeshProperties
row = layout.row()
row.operator("bim.map_representation")
sprops = context.scene.BIMGeometryProperties
row = self.layout.row()
row.prop(sprops, "should_auto_update_mesh_representations")
row = layout.row(align=True)
op = row.operator("bim.switch_representation", text="Bake Voids", icon="SELECT_SUBTRACT")