deprecate misc.mark_object_as_edited

in favor of ifc.edit
This commit is contained in:
Andrej730
2024-10-22 12:05:23 +05:00
parent 5c08b8f22d
commit 76869b0b02
6 changed files with 11 additions and 23 deletions
@@ -114,7 +114,7 @@ class ResizeToStorey(bpy.types.Operator, tool.Ifc.Operator):
if element.HasOpenings:
self.report({"ERROR"}, f"Object '{obj.name}', scaling is not supported.")
continue
core.resize_to_storey(tool.Misc, obj=obj, total_storeys=self.total_storeys)
core.resize_to_storey(tool.Misc, tool.Ifc, obj=obj, total_storeys=self.total_storeys)
class SplitAlongEdge(bpy.types.Operator, tool.Ifc.Operator):
+2 -2
View File
@@ -25,7 +25,7 @@ if TYPE_CHECKING:
import bonsai.tool as tool
def resize_to_storey(misc: tool.Misc, obj: bpy.types.Object, total_storeys: int) -> None:
def resize_to_storey(misc: tool.Misc, ifc: tool.Ifc, obj: bpy.types.Object, total_storeys: int) -> None:
storey = misc.get_object_storey(obj)
if not storey:
return
@@ -35,4 +35,4 @@ def resize_to_storey(misc: tool.Misc, obj: bpy.types.Object, total_storeys: int)
misc.set_object_origin_to_bottom(obj)
misc.move_object_to_elevation(obj, misc.get_storey_elevation_in_si(storey))
misc.scale_object_to_height(obj, height)
misc.mark_object_as_edited(obj)
ifc.edit(obj)
-1
View File
@@ -540,7 +540,6 @@ class Misc:
def get_object_storey(cls, obj): pass
def get_storey_elevation_in_si(cls, storey): pass
def get_storey_height_in_si(cls, storey, total_storeys): pass
def mark_object_as_edited(cls, obj): pass
def move_object_to_elevation(cls, obj, elevation): pass
def run_root_copy_class(cls, obj=None): pass
def scale_object_to_height(cls, obj, height): pass
-4
View File
@@ -98,10 +98,6 @@ class Misc(bonsai.core.tool.Misc):
)
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
@classmethod
def mark_object_as_edited(cls, obj: bpy.types.Object) -> None:
tool.Ifc.edit(obj)
@classmethod
def split_objects_with_cutter(
cls, objs: list[bpy.types.Object], cutter: bpy.types.Object
+8 -8
View File
@@ -17,25 +17,25 @@
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
import bonsai.core.misc as subject
from test.core.bootstrap import misc
from test.core.bootstrap import misc, ifc
class TestResizeToStorey:
def test_run(self, misc):
def test_run(self, misc, ifc):
misc.get_object_storey("obj").should_be_called().will_return("storey")
misc.get_storey_elevation_in_si("storey").should_be_called().will_return("elevation")
misc.get_storey_height_in_si("storey", 1).should_be_called().will_return("height")
misc.set_object_origin_to_bottom("obj").should_be_called()
misc.move_object_to_elevation("obj", "elevation").should_be_called()
misc.scale_object_to_height("obj", "height").should_be_called()
misc.mark_object_as_edited("obj").should_be_called()
subject.resize_to_storey(misc, obj="obj", total_storeys=1)
ifc.edit("obj").should_be_called()
subject.resize_to_storey(misc, ifc, obj="obj", total_storeys=1)
def test_doing_nothing_when_the_object_has_no_storey(self, misc):
def test_doing_nothing_when_the_object_has_no_storey(self, misc, ifc):
misc.get_object_storey("obj").should_be_called().will_return(None)
subject.resize_to_storey(misc, obj="obj", total_storeys=1)
subject.resize_to_storey(misc, ifc, obj="obj", total_storeys=1)
def test_doing_nothing_when_the_storey_has_no_height(self, misc):
def test_doing_nothing_when_the_storey_has_no_height(self, misc, ifc):
misc.get_object_storey("obj").should_be_called().will_return("storey")
misc.get_storey_height_in_si("storey", 1).should_be_called().will_return(None)
subject.resize_to_storey(misc, obj="obj", total_storeys=1)
subject.resize_to_storey(misc, ifc, obj="obj", total_storeys=1)
-7
View File
@@ -167,13 +167,6 @@ class TestScaleObjectToHeight(test.bim.bootstrap.NewFile):
assert list(obj.scale) == [1.0, 1.0, 1.0]
class TestMarkObjectAsEdited(test.bim.bootstrap.NewFile):
def test_run(self):
obj = bpy.data.objects.new("Cube", None)
subject.mark_object_as_edited(obj)
assert obj in IfcStore.edited_objs
class TestSplitObjectsWithCutter(test.bim.bootstrap.NewFile):
def test_run(self):
bpy.ops.mesh.primitive_cube_add()