Fix bug where unedited mesh objects were still tagged as edited which led to unnecessary processing prior to drawing generation or saving.

This commit is contained in:
Dion Moult
2023-09-07 22:09:26 +10:00
parent 292194c4f6
commit 678dce8fc0
5 changed files with 7 additions and 24 deletions
-18
View File
@@ -36,24 +36,6 @@ cwd = os.path.dirname(os.path.realpath(__file__))
global_subscription_owner = object()
def mode_callback(obj, data):
objects = bpy.context.selected_objects
if bpy.context.active_object:
objects += [bpy.context.active_object]
for obj in objects:
if (
obj.mode != "EDIT"
or not obj.data
or not isinstance(obj.data, (bpy.types.Mesh, bpy.types.Curve, bpy.types.TextCurve))
or not obj.BIMObjectProperties.ifc_definition_id
):
continue
if obj.data.BIMMeshProperties.ifc_definition_id:
tool.Ifc.edit(obj)
elif IfcStore.get_file().by_id(obj.BIMObjectProperties.ifc_definition_id).is_a("IfcGridAxis"):
tool.Ifc.edit(obj)
def name_callback(obj, data):
try:
obj.name
-2
View File
@@ -220,7 +220,6 @@ class IfcStore:
if isinstance(obj, bpy.types.Material):
blenderbim.bim.handler.subscribe_to(obj, "diffuse_color", blenderbim.bim.handler.color_callback)
elif isinstance(obj, bpy.types.Object):
blenderbim.bim.handler.subscribe_to(obj, "mode", blenderbim.bim.handler.mode_callback)
blenderbim.bim.handler.subscribe_to(
obj, "active_material_index", blenderbim.bim.handler.active_material_index_callback
)
@@ -249,7 +248,6 @@ class IfcStore:
if isinstance(obj, bpy.types.Material):
blenderbim.bim.handler.subscribe_to(obj, "diffuse_color", blenderbim.bim.handler.color_callback)
elif isinstance(obj, bpy.types.Object):
blenderbim.bim.handler.subscribe_to(obj, "mode", blenderbim.bim.handler.mode_callback)
blenderbim.bim.handler.subscribe_to(
obj, "active_material_index", blenderbim.bim.handler.active_material_index_callback
)
@@ -1415,6 +1415,7 @@ class OverrideModeSetEdit(bpy.types.Operator):
continue
if tool.Geometry.is_meshlike(representation):
tool.Ifc.edit(obj)
if getattr(element, "HasOpenings", None):
# Mesh elements with openings must disable openings
# so that you can edit the original topology.
@@ -1559,6 +1560,8 @@ class OverrideModeSetObject(bpy.types.Operator):
self.edited_objs.append(obj)
elif getattr(element, "HasOpenings", None):
self.unchanged_objs_with_openings.append(obj)
else:
tool.Ifc.finish_edit(obj)
if self.edited_objs:
return context.window_manager.invoke_props_dialog(self)
-1
View File
@@ -120,7 +120,6 @@ class Ifc(blenderbim.core.tool.Ifc):
IfcStore.guid_map[global_id] = obj
blenderbim.bim.handler.subscribe_to(obj, "name", blenderbim.bim.handler.name_callback)
blenderbim.bim.handler.subscribe_to(obj, "mode", blenderbim.bim.handler.mode_callback)
blenderbim.bim.handler.subscribe_to(
obj, "active_material_index", blenderbim.bim.handler.active_material_index_callback
)
@@ -185,10 +185,11 @@ class FormatTransformer(lark.Transformer):
return "".join(args)
def substr(self, args):
return str(args[0])[int(args[1]):int(args[2])]
return str(args[0])[int(args[1]) : int(args[2])]
def round(self, args):
return str(round(float(args[0]) / float(args[1])) * float(args[1]))
value = args[0] or 0.0
return str(round(float(value) / float(args[1])) * float(args[1]))
def format_length(self, args):
return args[0]
@@ -825,7 +826,7 @@ class Selector:
elif key in ("x", "y", "z", "easting", "northing", "elevation") and hasattr(value, "ObjectPlacement"):
if getattr(value, "ObjectPlacement", None):
matrix = ifcopenshell.util.placement.get_local_placement(value.ObjectPlacement)
xyz = matrix[:,3][:3]
xyz = matrix[:, 3][:3]
if key in ("x", "y", "z"):
value = xyz["xyz".index(key)]
else: