Fix #5952. Aggressively block scaling of IFC elements to prevent user confusion.

This commit is contained in:
Dion Moult
2025-01-13 18:01:25 +11:00
parent e29f686d3f
commit 581a674654
4 changed files with 17 additions and 18 deletions
-16
View File
@@ -261,8 +261,6 @@ class IfcImporter:
self.profile_code("Setup arrays")
tool.Project.load_linked_models_from_ifc()
self.profile_code("Load linked models")
self.lock_scales()
self.profile_code("Lock objects scales")
self.add_project_to_scene()
self.profile_code("Add project to scene")
if self.ifc_import_settings.should_clean_mesh and len(self.file.by_type("IfcElement")) < 1000:
@@ -1129,20 +1127,6 @@ class IfcImporter:
tool.Aggregate.constrain_all_parts_to_aggregate(relating_obj)
bpy.context.scene.BIMAggregateProperties.aggregate_decorator = True
def lock_scales(self) -> None:
elements = set(self.file.by_type("IfcProduct"))
while elements:
element = elements.pop()
if not getattr(element, "HasOpenings", False):
continue
voided_elements = tool.Aggregate.get_parts_recursively(element)
voided_elements.add(element)
elements.difference_update(voided_elements)
for element in voided_elements:
if not (obj := tool.Ifc.get_object(element)):
continue
tool.Geometry.lock_scale(obj)
class IfcImportSettings:
def __init__(self):
@@ -18,6 +18,7 @@
import bpy
from . import ui, prop, operator
from bpy.app.handlers import persistent
classes = (
operator.AddCurvelikeItem,
@@ -89,7 +90,20 @@ classes = (
addon_keymaps = []
@persistent
def block_scale(scene):
if obj := (getattr(bpy.context, "active_object", None) or bpy.context.view_layer.objects.active):
if isinstance(obj, bpy.types.Object) and obj.BIMObjectProperties.ifc_definition_id:
if obj.scale != (1, 1, 1):
obj.scale = (1, 1, 1)
elif isinstance(obj, bpy.types.Mesh) and obj.BIMMeshProperties.ifc_definition_id:
if obj.scale != (1, 1, 1):
obj.scale = (1, 1, 1)
def register():
bpy.app.handlers.depsgraph_update_pre.append(block_scale)
operator.OverrideDuplicateMoveMacro.define("BIM_OT_override_object_duplicate_move")
operator.OverrideDuplicateMoveMacro.define("TRANSFORM_OT_translate")
operator.OverrideDuplicateMoveLinkedMacro.define("BIM_OT_override_object_duplicate_move_linked")
@@ -158,6 +172,8 @@ def register():
def unregister():
bpy.app.handlers.depsgraph_update_pre.remove(block_scale)
bpy.types.VIEW3D_MT_object.remove(ui.object_menu)
bpy.types.OUTLINER_MT_object.remove(ui.outliner_menu)
bpy.types.VIEW3D_MT_object_context_menu.remove(ui.outliner_menu)
+1
View File
@@ -43,6 +43,7 @@ class Collector(bonsai.core.tool.Collector):
# Note that tool.Geometry.is_locked is only checked within the if
# statements for efficiency as it is a slow check.
tool.Geometry.lock_scale(obj)
if element.is_a("IfcGridAxis"):
if tool.Geometry.is_locked(element):
-2
View File
@@ -132,7 +132,6 @@ class Geometry(bonsai.core.tool.Geometry):
obj.lock_rotation = (True, True, True)
obj.lock_rotation_w = True
obj.lock_rotations_4d = True
obj.lock_scale = (True, True, True)
@classmethod
def unlock_object(cls, obj: bpy.types.Object) -> None:
@@ -140,7 +139,6 @@ class Geometry(bonsai.core.tool.Geometry):
obj.lock_rotation = (False, False, False)
obj.lock_rotation_w = False
obj.lock_rotations_4d = False
obj.lock_scale = (False, False, False)
@classmethod
def lock_scale(cls, obj: bpy.types.Object) -> None: