Deprecate should_sync_changes_first for switching representation, since it is no longer relevant in item editing.

This commit is contained in:
Dion Moult
2025-10-06 16:19:39 +11:00
parent a2ccff67ca
commit e662308665
25 changed files with 3 additions and 70 deletions
@@ -2220,7 +2220,6 @@ class ActivateModel(bpy.types.Operator):
representation=model, representation=model,
should_reload=False, should_reload=False,
is_global=True, is_global=True,
should_sync_changes_first=True,
) )
tool.Blender.reset_object_visibility() tool.Blender.reset_object_visibility()
@@ -182,7 +182,6 @@ def create_annotation_occurrence(context):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
if obj.data and not relating_type_rep: if obj.data and not relating_type_rep:
@@ -467,7 +467,6 @@ class SwitchRepresentation(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=self.should_reload, should_reload=self.should_reload,
is_global=self.should_switch_all_meshes, is_global=self.should_switch_all_meshes,
should_sync_changes_first=True,
) )
@@ -723,7 +722,6 @@ class UpdateParametricRepresentation(bpy.types.Operator):
representation=tool.Ifc.get().by_id(props.ifc_definition_id), representation=tool.Ifc.get().by_id(props.ifc_definition_id),
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
if show_representation_parameters: if show_representation_parameters:
core.get_representation_ifc_parameters(tool.Geometry, obj=obj) core.get_representation_ifc_parameters(tool.Geometry, obj=obj)
@@ -1906,7 +1904,6 @@ class OverrideJoin(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
apply_openings=True, apply_openings=True,
) )
@@ -195,7 +195,6 @@ class SplitAlongEdge(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
apply_openings=False, apply_openings=False,
) )
@@ -226,7 +225,6 @@ class SplitAlongEdge(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
apply_openings=True, apply_openings=True,
) )
@@ -147,7 +147,6 @@ def update_door_modifier_representation(obj: bpy.types.Object) -> None:
representation=ifcopenshell.util.representation.get_representation(element, active_context), representation=ifcopenshell.util.representation.get_representation(element, active_context),
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
# type attributes # type attributes
@@ -583,7 +582,6 @@ class CancelEditingDoor(bpy.types.Operator, tool.Ifc.Operator):
representation=body, representation=body,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
props.is_editing = False props.is_editing = False
@@ -188,7 +188,6 @@ class FilledOpeningGenerator:
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
def regenerate_from_type(self, usecase_path: str, ifc_file: ifcopenshell.file, settings: dict[str, Any]) -> None: def regenerate_from_type(self, usecase_path: str, ifc_file: ifcopenshell.file, settings: dict[str, Any]) -> None:
@@ -251,7 +250,6 @@ class FilledOpeningGenerator:
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
def generate_opening_from_filling( def generate_opening_from_filling(
@@ -422,7 +420,6 @@ class RecalculateFill(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
return {"FINISHED"} return {"FINISHED"}
@@ -800,7 +797,6 @@ class CloneOpening(Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
return {"FINISHED"} return {"FINISHED"}
@@ -582,7 +582,6 @@ def get_generic_product_preview_data(context, relating_type):
representation, representation,
should_reload=True, should_reload=True,
is_global=False, is_global=False,
should_sync_changes_first=False,
) )
context.view_layer.update() context.view_layer.update()
break break
@@ -408,7 +408,6 @@ class AddOccurrence(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
elif self.representation_template == "EXTRUSION": elif self.representation_template == "EXTRUSION":
builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get()) builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get())
@@ -424,7 +423,6 @@ class AddOccurrence(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
return return
@@ -455,7 +453,6 @@ class AddOccurrence(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
# Update required as core.type.assign_type may change obj.data # Update required as core.type.assign_type may change obj.data
@@ -740,5 +737,4 @@ def regenerate_profile_usage(usecase_path, ifc_file, settings):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
@@ -169,7 +169,6 @@ class DumbProfileGenerator:
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="EPset_Parametric") pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="EPset_Parametric")
@@ -570,7 +569,6 @@ class DumbProfileJoiner:
representation=new_body, representation=new_body,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
tool.Geometry.record_object_materials(obj) tool.Geometry.record_object_materials(obj)
if element.is_a("IfcFlowSegment") or element.is_a("IfcFlowFitting"): if element.is_a("IfcFlowSegment") or element.is_a("IfcFlowFitting"):
@@ -1039,7 +1037,6 @@ def disable_editing_extrusion_axis(context):
representation=body, representation=body,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
return {"FINISHED"} return {"FINISHED"}
@@ -1103,7 +1100,6 @@ class EditExtrusionAxis(bpy.types.Operator, tool.Ifc.Operator):
representation=body, representation=body,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
bpy.context.view_layer.update() bpy.context.view_layer.update()
@@ -540,7 +540,6 @@ def cancel_editing_railing_path(context: bpy.types.Context) -> set[str]:
representation=body, representation=body,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
return {"FINISHED"} return {"FINISHED"}
@@ -169,7 +169,6 @@ class DumbSlabGenerator:
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
obj.matrix_world = obj.matrix_world @ Matrix.Rotation(self.x_angle, 4, "X") obj.matrix_world = obj.matrix_world @ Matrix.Rotation(self.x_angle, 4, "X")
@@ -362,7 +361,6 @@ class DumbSlabPlaner:
representation=new_rep, representation=new_rep,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
bonsai.core.geometry.remove_representation( bonsai.core.geometry.remove_representation(
tool.Ifc, tool.Geometry, obj=obj, representation=representation tool.Ifc, tool.Geometry, obj=obj, representation=representation
@@ -388,7 +386,6 @@ class DumbSlabPlaner:
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
@@ -590,7 +587,6 @@ class EditSketchExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
return {"FINISHED"} return {"FINISHED"}
@@ -634,7 +630,6 @@ def disable_editing_extrusion_profile(context):
representation=body, representation=body,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
return {"FINISHED"} return {"FINISHED"}
@@ -769,7 +764,6 @@ class EditExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator):
representation=body, representation=body,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
# Only certain classes should have a footprint # Only certain classes should have a footprint
@@ -519,7 +519,6 @@ class ChangeExtrusionXAngle(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
# Object rotation # Object rotation
@@ -1026,7 +1025,6 @@ class DumbWallGenerator:
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="EPset_Parametric") pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="EPset_Parametric")
ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Engine": "Bonsai.DumbLayer2"}) ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Engine": "Bonsai.DumbLayer2"})
@@ -125,7 +125,6 @@ def update_window_modifier_representation(context: bpy.types.Context) -> None:
representation=ifcopenshell.util.representation.get_representation(element, active_context), representation=ifcopenshell.util.representation.get_representation(element, active_context),
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=True,
) )
# type attributes # type attributes
@@ -497,7 +496,6 @@ class CancelEditingWindow(bpy.types.Operator, tool.Ifc.Operator):
representation=body, representation=body,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
props.is_editing = False props.is_editing = False
@@ -335,7 +335,6 @@ class AssignClass(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
else: else:
@@ -581,7 +580,6 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
if not tool.Ifc.get_entity(props.representation_obj): if not tool.Ifc.get_entity(props.representation_obj):
bpy.data.objects.remove(props.representation_obj) bpy.data.objects.remove(props.representation_obj)
@@ -603,7 +601,6 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
elif representation_template == "EXTRUSION": elif representation_template == "EXTRUSION":
builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get()) builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get())
@@ -652,7 +649,6 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
elif representation_template in ("LAYERSET_AXIS2", "LAYERSET_AXIS3"): elif representation_template in ("LAYERSET_AXIS2", "LAYERSET_AXIS3"):
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
@@ -765,7 +761,6 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
elif representation_template == "EDGE": elif representation_template == "EDGE":
builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get()) builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get())
@@ -780,7 +775,6 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
elif representation_template == "FACE": elif representation_template == "FACE":
builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get()) builder = ifcopenshell.util.shape_builder.ShapeBuilder(tool.Ifc.get())
@@ -795,7 +789,6 @@ class AddElement(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
bpy.context.view_layer.update() # Ensures obj.matrix_world is correct bpy.context.view_layer.update() # Ensures obj.matrix_world is correct
@@ -123,7 +123,6 @@ class UnassignType(bpy.types.Operator, tool.Ifc.Operator):
representation=new_active_representation, representation=new_active_representation,
should_reload=False, should_reload=False,
is_global=False, is_global=False,
should_sync_changes_first=False,
) )
return {"FINISHED"} return {"FINISHED"}
@@ -152,7 +152,6 @@ class AddOpening(bpy.types.Operator, tool.Ifc.Operator):
is_global=True, is_global=True,
# Don't sync changes because object has an opening, # Don't sync changes because object has an opening,
# therefore bim.update_representaiton wouldn't work either way. # therefore bim.update_representaiton wouldn't work either way.
should_sync_changes_first=False,
) )
tool.Geometry.lock_scale(voided_obj) tool.Geometry.lock_scale(voided_obj)
@@ -198,7 +197,6 @@ class RemoveOpening(bpy.types.Operator, tool.Ifc.Operator):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
tool.Geometry.unlock_scale_object_with_openings(obj) tool.Geometry.unlock_scale_object_with_openings(obj)
tool.Geometry.clear_cache(element) tool.Geometry.clear_cache(element)
+1 -11
View File
@@ -117,22 +117,14 @@ def switch_representation(
representation: ifcopenshell.entity_instance, representation: ifcopenshell.entity_instance,
should_reload: bool = True, should_reload: bool = True,
is_global: bool = True, is_global: bool = True,
should_sync_changes_first: bool = False,
apply_openings: bool = True, apply_openings: bool = True,
) -> None: ) -> None:
"""Function can switch to representation that wasn't yet assigned to that object. See #2766. """Function can switch to representation that wasn't yet assigned to that object. See #2766.
:param should_sync_changes_first: sync ifc representation with current state of `obj.data`
:param should_reload: reload `obj.data` from ifc representation :param should_reload: reload `obj.data` from ifc representation
:param is_global: replace mesh data for all users of `obj.data`, not just `obj` :param is_global: replace mesh data for all users of `obj.data`, not just `obj`
""" """
if should_sync_changes_first and ifc.is_edited(obj) and not geometry.is_box_representation(representation):
representation_id = geometry.get_representation_id(representation)
geometry.run_geometry_update_representation(obj=obj)
if not geometry.does_representation_id_exist(representation_id):
return
if not geometry.get_object_data(obj) and geometry.is_text_literal(representation): if not geometry.get_object_data(obj) and geometry.is_text_literal(representation):
return return
@@ -142,9 +134,7 @@ def switch_representation(
geometry.reimport_element_representations(obj, representation, apply_openings=apply_openings) geometry.reimport_element_representations(obj, representation, apply_openings=apply_openings)
def get_representation_ifc_parameters( def get_representation_ifc_parameters(geometry: type[tool.Geometry], obj: bpy.types.Object) -> None:
geometry: type[tool.Geometry], obj: bpy.types.Object, should_sync_changes_first: bool = False
) -> None:
geometry.import_representation_parameters(geometry.get_object_data(obj)) geometry.import_representation_parameters(geometry.get_object_data(obj))
-2
View File
@@ -1180,7 +1180,6 @@ class Drawing(bonsai.core.tool.Drawing):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
@classmethod @classmethod
@@ -2225,7 +2224,6 @@ class Drawing(bonsai.core.tool.Drawing):
representation=priority_representation, representation=priority_representation,
should_reload=False, should_reload=False,
is_global=True, is_global=True,
should_sync_changes_first=True,
) )
has_context = True has_context = True
break break
-2
View File
@@ -1352,7 +1352,6 @@ class Geometry(bonsai.core.tool.Geometry):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
apply_openings=True, apply_openings=True,
) )
@@ -1389,7 +1388,6 @@ class Geometry(bonsai.core.tool.Geometry):
obj=obj, obj=obj,
representation=new_representation, representation=new_representation,
should_reload=False, should_reload=False,
should_sync_changes_first=False,
is_global=True, is_global=True,
) )
+1 -1
View File
@@ -248,7 +248,7 @@ class Ifc(bonsai.core.tool.Ifc):
Marking object as edited is an optimization mechanism - instead of saving Marking object as edited is an optimization mechanism - instead of saving
changed geometry to IFC, we mark it as changed and then it's saved later changed geometry to IFC, we mark it as changed and then it's saved later
(typically during project save or switch_representation(should_sync_changes_first=True)). (typically during project save).
Other caveat of using edited objects is that it won't have an effect for objects with openings, Other caveat of using edited objects is that it won't have an effect for objects with openings,
since we can't deduce non-openings representation from edited representation with openings. since we can't deduce non-openings representation from edited representation with openings.
-4
View File
@@ -1093,7 +1093,6 @@ class Model(bonsai.core.tool.Model):
representation=new_representation, representation=new_representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
@classmethod @classmethod
@@ -1308,7 +1307,6 @@ class Model(bonsai.core.tool.Model):
representation=body, representation=body,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
@classmethod @classmethod
@@ -1654,7 +1652,6 @@ class Model(bonsai.core.tool.Model):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
apply_openings=True, apply_openings=True,
) )
@@ -2470,7 +2467,6 @@ class Model(bonsai.core.tool.Model):
representation=rep, representation=rep,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
tool.Geometry.record_object_materials(obj) tool.Geometry.record_object_materials(obj)
-1
View File
@@ -328,7 +328,6 @@ class Root(bonsai.core.tool.Root):
representation=representation, representation=representation,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
@classmethod @classmethod
-1
View File
@@ -1200,7 +1200,6 @@ class Spatial(bonsai.core.tool.Spatial):
representation=body, representation=body,
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=False,
) )
@classmethod @classmethod
-1
View File
@@ -141,5 +141,4 @@ class Type(bonsai.core.tool.Type):
representation=representation, representation=representation,
should_reload=should_reload, should_reload=should_reload,
is_global=is_global, is_global=is_global,
should_sync_changes_first=False,
) )
+1 -4
View File
@@ -205,7 +205,6 @@ class TestSwitchRepresentation:
representation="mapped_rep", representation="mapped_rep",
should_reload=True, should_reload=True,
is_global=True, is_global=True,
should_sync_changes_first=True,
apply_openings=True, apply_openings=True,
) )
@@ -224,7 +223,6 @@ class TestSwitchRepresentation:
representation="mapped_rep", representation="mapped_rep",
should_reload=False, should_reload=False,
is_global=False, is_global=False,
should_sync_changes_first=True,
) )
def test_not_switching_if_an_updated_representation_is_the_same_one_we_were_going_to_switch_to(self, ifc, geometry): def test_not_switching_if_an_updated_representation_is_the_same_one_we_were_going_to_switch_to(self, ifc, geometry):
@@ -240,7 +238,6 @@ class TestSwitchRepresentation:
representation="mapped_rep", representation="mapped_rep",
should_reload=False, should_reload=False,
is_global=False, is_global=False,
should_sync_changes_first=True,
) )
@@ -248,7 +245,7 @@ class TestGetRepresentationIfcParameters:
def test_run(self, geometry): def test_run(self, geometry):
geometry.get_object_data("obj").should_be_called().will_return("data") geometry.get_object_data("obj").should_be_called().will_return("data")
geometry.import_representation_parameters("data").should_be_called() geometry.import_representation_parameters("data").should_be_called()
subject.get_representation_ifc_parameters(geometry, obj="obj", should_sync_changes_first=False) subject.get_representation_ifc_parameters(geometry, obj="obj")
class TestRemoveRepresentation: class TestRemoveRepresentation: