mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
Fix #5952. Aggressively block scaling of IFC elements to prevent user confusion.
This commit is contained in:
@@ -261,8 +261,6 @@ class IfcImporter:
|
|||||||
self.profile_code("Setup arrays")
|
self.profile_code("Setup arrays")
|
||||||
tool.Project.load_linked_models_from_ifc()
|
tool.Project.load_linked_models_from_ifc()
|
||||||
self.profile_code("Load linked models")
|
self.profile_code("Load linked models")
|
||||||
self.lock_scales()
|
|
||||||
self.profile_code("Lock objects scales")
|
|
||||||
self.add_project_to_scene()
|
self.add_project_to_scene()
|
||||||
self.profile_code("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:
|
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)
|
tool.Aggregate.constrain_all_parts_to_aggregate(relating_obj)
|
||||||
bpy.context.scene.BIMAggregateProperties.aggregate_decorator = True
|
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:
|
class IfcImportSettings:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
from . import ui, prop, operator
|
from . import ui, prop, operator
|
||||||
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
operator.AddCurvelikeItem,
|
operator.AddCurvelikeItem,
|
||||||
@@ -89,7 +90,20 @@ classes = (
|
|||||||
addon_keymaps = []
|
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():
|
def register():
|
||||||
|
bpy.app.handlers.depsgraph_update_pre.append(block_scale)
|
||||||
|
|
||||||
operator.OverrideDuplicateMoveMacro.define("BIM_OT_override_object_duplicate_move")
|
operator.OverrideDuplicateMoveMacro.define("BIM_OT_override_object_duplicate_move")
|
||||||
operator.OverrideDuplicateMoveMacro.define("TRANSFORM_OT_translate")
|
operator.OverrideDuplicateMoveMacro.define("TRANSFORM_OT_translate")
|
||||||
operator.OverrideDuplicateMoveLinkedMacro.define("BIM_OT_override_object_duplicate_move_linked")
|
operator.OverrideDuplicateMoveLinkedMacro.define("BIM_OT_override_object_duplicate_move_linked")
|
||||||
@@ -158,6 +172,8 @@ def register():
|
|||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
|
bpy.app.handlers.depsgraph_update_pre.remove(block_scale)
|
||||||
|
|
||||||
bpy.types.VIEW3D_MT_object.remove(ui.object_menu)
|
bpy.types.VIEW3D_MT_object.remove(ui.object_menu)
|
||||||
bpy.types.OUTLINER_MT_object.remove(ui.outliner_menu)
|
bpy.types.OUTLINER_MT_object.remove(ui.outliner_menu)
|
||||||
bpy.types.VIEW3D_MT_object_context_menu.remove(ui.outliner_menu)
|
bpy.types.VIEW3D_MT_object_context_menu.remove(ui.outliner_menu)
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class Collector(bonsai.core.tool.Collector):
|
|||||||
|
|
||||||
# Note that tool.Geometry.is_locked is only checked within the if
|
# Note that tool.Geometry.is_locked is only checked within the if
|
||||||
# statements for efficiency as it is a slow check.
|
# statements for efficiency as it is a slow check.
|
||||||
|
tool.Geometry.lock_scale(obj)
|
||||||
|
|
||||||
if element.is_a("IfcGridAxis"):
|
if element.is_a("IfcGridAxis"):
|
||||||
if tool.Geometry.is_locked(element):
|
if tool.Geometry.is_locked(element):
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ class Geometry(bonsai.core.tool.Geometry):
|
|||||||
obj.lock_rotation = (True, True, True)
|
obj.lock_rotation = (True, True, True)
|
||||||
obj.lock_rotation_w = True
|
obj.lock_rotation_w = True
|
||||||
obj.lock_rotations_4d = True
|
obj.lock_rotations_4d = True
|
||||||
obj.lock_scale = (True, True, True)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def unlock_object(cls, obj: bpy.types.Object) -> None:
|
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 = (False, False, False)
|
||||||
obj.lock_rotation_w = False
|
obj.lock_rotation_w = False
|
||||||
obj.lock_rotations_4d = False
|
obj.lock_rotations_4d = False
|
||||||
obj.lock_scale = (False, False, False)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def lock_scale(cls, obj: bpy.types.Object) -> None:
|
def lock_scale(cls, obj: bpy.types.Object) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user