mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Meshes are auto updated in the IFC as well when edit mode is toggled now.
This commit is contained in:
@@ -5,6 +5,36 @@ from bpy.app.handlers import persistent
|
|||||||
from blenderbim.bim.ifc import IfcStore
|
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
|
@persistent
|
||||||
def loadIfcStore(scene):
|
def loadIfcStore(scene):
|
||||||
IfcStore.file = None
|
IfcStore.file = None
|
||||||
@@ -31,7 +61,6 @@ def loadIfcStore(scene):
|
|||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def ensureIfcExported(scene):
|
def ensureIfcExported(scene):
|
||||||
print('ensuring')
|
|
||||||
if IfcStore.get_file() and not bpy.context.scene.BIMProperties.ifc_file:
|
if IfcStore.get_file() and not bpy.context.scene.BIMProperties.ifc_file:
|
||||||
# The invocation pops up a file select window.
|
# The invocation pops up a file select window.
|
||||||
# This is non-blocking, therefore the Blend file is saved before we export.
|
# This is non-blocking, therefore the Blend file is saved before we export.
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import blenderbim.bim.handler
|
||||||
|
|
||||||
|
|
||||||
class IfcStore:
|
class IfcStore:
|
||||||
@@ -36,6 +37,7 @@ class IfcStore:
|
|||||||
if hasattr(element, "GlobalId"):
|
if hasattr(element, "GlobalId"):
|
||||||
IfcStore.guid_map[element.GlobalId] = obj
|
IfcStore.guid_map[element.GlobalId] = obj
|
||||||
obj.BIMObjectProperties.ifc_definition_id = element.id()
|
obj.BIMObjectProperties.ifc_definition_id = element.id()
|
||||||
|
blenderbim.bim.handler.subscribe_to(obj, "mode", blenderbim.bim.handler.mode_callback)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def unlink_element(element, obj=None):
|
def unlink_element(element, obj=None):
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ from bpy.props import (
|
|||||||
|
|
||||||
|
|
||||||
class BIMGeometryProperties(PropertyGroup):
|
class BIMGeometryProperties(PropertyGroup):
|
||||||
|
should_auto_update_mesh_representations: BoolProperty(name="Should Auto Update Representations", default=True)
|
||||||
# Revit workaround
|
# Revit workaround
|
||||||
should_use_presentation_style_assignment: BoolProperty(name="Force Presentation Style Assignment", default=False)
|
should_use_presentation_style_assignment: BoolProperty(name="Force Presentation Style Assignment", default=False)
|
||||||
# RIB iTwo, DESITE BIM workaround
|
# RIB iTwo, DESITE BIM workaround
|
||||||
|
|||||||
@@ -66,8 +66,9 @@ class BIM_PT_mesh(Panel):
|
|||||||
layout = self.layout
|
layout = self.layout
|
||||||
props = context.active_object.data.BIMMeshProperties
|
props = context.active_object.data.BIMMeshProperties
|
||||||
|
|
||||||
row = layout.row()
|
sprops = context.scene.BIMGeometryProperties
|
||||||
row.operator("bim.map_representation")
|
row = self.layout.row()
|
||||||
|
row.prop(sprops, "should_auto_update_mesh_representations")
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
op = row.operator("bim.switch_representation", text="Bake Voids", icon="SELECT_SUBTRACT")
|
op = row.operator("bim.switch_representation", text="Bake Voids", icon="SELECT_SUBTRACT")
|
||||||
|
|||||||
Reference in New Issue
Block a user