mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
deprecate geometry.is_edited
in favor of ifc.is_edited
This commit is contained in:
@@ -491,11 +491,7 @@ class BIM_PT_tabs(Panel):
|
||||
op = row.operator("bim.open_uri", text="", icon="QUESTION")
|
||||
op.uri = "https://docs.bonsaibim.org/guides/troubleshooting.html#incompatible-blender-features"
|
||||
|
||||
if (
|
||||
(o := context.active_object)
|
||||
and tool.Ifc.get_entity(o)
|
||||
and [round(x, 4) for x in list(o.matrix_world.to_scale())] != [1, 1, 1]
|
||||
):
|
||||
if (o := context.active_object) and tool.Ifc.get_entity(o) and tool.Geometry.is_scaled(o):
|
||||
box = self.layout.box()
|
||||
box.alert = True
|
||||
row = box.row(align=True)
|
||||
|
||||
@@ -115,7 +115,7 @@ def switch_representation(
|
||||
:param is_global: replace mesh data for all users of `obj.data`, not just `obj`
|
||||
|
||||
"""
|
||||
if should_sync_changes_first and geometry.is_edited(obj) and not geometry.is_box_representation(representation):
|
||||
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):
|
||||
|
||||
@@ -823,8 +823,8 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
return isinstance(data, supported_types)
|
||||
|
||||
@classmethod
|
||||
def is_edited(cls, obj: bpy.types.Object) -> bool:
|
||||
return not all([tool.Cad.is_x(o, 1.0) for o in obj.scale]) or obj in IfcStore.edited_objs
|
||||
def is_scaled(cls, obj: bpy.types.Object) -> bool:
|
||||
return not all([tool.Cad.is_x(o, 1.0) for o in obj.scale])
|
||||
|
||||
@classmethod
|
||||
def is_mapped_representation(cls, representation: ifcopenshell.entity_instance) -> bool:
|
||||
|
||||
@@ -67,7 +67,7 @@ class Ifc(bonsai.core.tool.Ifc):
|
||||
|
||||
@classmethod
|
||||
def is_edited(cls, obj: bpy.types.Object) -> bool:
|
||||
return list(obj.scale) != [1.0, 1.0, 1.0] or obj in IfcStore.edited_objs
|
||||
return tool.Geometry.is_scaled(obj) or obj in IfcStore.edited_objs
|
||||
|
||||
@classmethod
|
||||
def is_moved(cls, obj: bpy.types.Object) -> bool:
|
||||
|
||||
@@ -195,7 +195,7 @@ class TestAddRepresentation:
|
||||
|
||||
class TestSwitchRepresentation:
|
||||
def test_switching_to_a_representation(self, ifc, geometry):
|
||||
geometry.is_edited("obj").should_be_called().will_return(False)
|
||||
ifc.is_edited("obj").should_be_called().will_return(False)
|
||||
geometry.get_object_data("obj").should_be_called().will_return("current_obj_data")
|
||||
geometry.reimport_element_representations("obj", "mapped_rep", apply_openings=True).should_be_called()
|
||||
subject.switch_representation(
|
||||
@@ -210,7 +210,7 @@ class TestSwitchRepresentation:
|
||||
)
|
||||
|
||||
def test_updating_a_representation_if_the_blender_object_has_been_edited_prior_to_switching(self, ifc, geometry):
|
||||
geometry.is_edited("obj").should_be_called().will_return(True)
|
||||
ifc.is_edited("obj").should_be_called().will_return(True)
|
||||
geometry.is_box_representation("mapped_rep").should_be_called().will_return(False)
|
||||
geometry.get_representation_id("mapped_rep").should_be_called().will_return("representation_id")
|
||||
geometry.run_geometry_update_representation(obj="obj").should_be_called()
|
||||
@@ -228,7 +228,7 @@ class TestSwitchRepresentation:
|
||||
)
|
||||
|
||||
def test_not_switching_if_an_updated_representation_is_the_same_one_we_were_going_to_switch_to(self, geometry):
|
||||
geometry.is_edited("obj").should_be_called().will_return(True)
|
||||
ifc.is_edited("obj").should_be_called().will_return(True)
|
||||
geometry.is_box_representation("mapped_rep").should_be_called().will_return(False)
|
||||
geometry.get_representation_id("mapped_rep").should_be_called().will_return("representation_id")
|
||||
geometry.run_geometry_update_representation(obj="obj").should_be_called()
|
||||
|
||||
@@ -298,18 +298,6 @@ class TestIsBoxRepresentation(NewFile):
|
||||
assert subject.is_box_representation(representation) is False
|
||||
|
||||
|
||||
class TestIsEdited(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
|
||||
assert subject.is_edited(obj) is False
|
||||
obj.scale[0] = 2
|
||||
assert subject.is_edited(obj) is True
|
||||
obj.scale[0] = 1
|
||||
assert subject.is_edited(obj) is False
|
||||
tool.Ifc.edit(obj)
|
||||
assert subject.is_edited(obj) is True
|
||||
|
||||
|
||||
class TestIsMappedRepresentation(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
|
||||
@@ -66,6 +66,18 @@ class TestGetSchema(test.bim.bootstrap.NewFile):
|
||||
assert subject.get_schema() == "IFC4"
|
||||
|
||||
|
||||
class TestIsEdited(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
|
||||
assert subject.is_edited(obj) is False
|
||||
obj.scale[0] = 2
|
||||
assert subject.is_edited(obj) is True
|
||||
obj.scale[0] = 1
|
||||
assert subject.is_edited(obj) is False
|
||||
tool.Ifc.edit(obj)
|
||||
assert subject.is_edited(obj) is True
|
||||
|
||||
|
||||
class TestIsMoved(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
|
||||
Reference in New Issue
Block a user