mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
Fix bug where switching to an object with modifiers applied would double the effect of modifiers.
This commit is contained in:
@@ -33,6 +33,26 @@ Scenario: Switch representation
|
||||
And I press "bim.switch_representation(obj='IfcWall/Cube', ifc_definition_id={representation})"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Switch representation - existing Blender modifiers must be purged
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I add an array modifier
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||
And I press "bim.assign_class"
|
||||
When the variable "representation" is "{ifc}.by_type('IfcShapeRepresentation')[0].id()"
|
||||
And I press "bim.switch_representation(obj='IfcWall/Cube', ifc_definition_id={representation})"
|
||||
Then the object "IfcWall/Cube" has no modifiers
|
||||
|
||||
Scenario: Update representation
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||
And I press "bim.assign_class"
|
||||
And I press "bim.update_representation(obj='IfcWall/Cube')"
|
||||
Then the object "IfcWall/Cube" has a "Tessellation" representation of "Model/Body/MODEL_VIEW"
|
||||
|
||||
Scenario: Copy representation
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
|
||||
@@ -94,6 +94,11 @@ def i_add_a_material():
|
||||
bpy.context.active_object.active_material = bpy.data.materials.new("Material")
|
||||
|
||||
|
||||
@given("I add an array modifier")
|
||||
def i_add_a_cube():
|
||||
bpy.ops.object.modifier_add(type="ARRAY")
|
||||
|
||||
|
||||
@when(parsers.parse('I add a cube of size "{size}" at "{location}"'))
|
||||
def i_add_a_cube_of_size_size_at_location(size, location):
|
||||
bpy.ops.mesh.primitive_cube_add(size=float(size), location=[float(co) for co in location.split(",")])
|
||||
@@ -424,3 +429,8 @@ def the_file_name_should_contain_value(name, value):
|
||||
name = replace_variables(name)
|
||||
with open(name, "r") as f:
|
||||
assert value in f.read()
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name}" has no modifiers'))
|
||||
def the_object_name_has_no_modifiers(name):
|
||||
assert len(the_object_name_exists(name).modifiers) == 0
|
||||
|
||||
@@ -189,6 +189,7 @@ class TestSwitchRepresentation:
|
||||
geometry.rename_object("new_data", "name").should_be_called()
|
||||
geometry.link("representation", "new_data").should_be_called()
|
||||
geometry.change_object_data("obj", "new_data", is_global=True).should_be_called()
|
||||
geometry.clear_modifiers("obj").should_be_called()
|
||||
geometry.is_body_representation("representation").should_be_called().will_return(True)
|
||||
geometry.create_dynamic_voids("obj").should_be_called()
|
||||
subject.switch_representation(
|
||||
@@ -204,6 +205,7 @@ class TestSwitchRepresentation:
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||
geometry.change_object_data("obj", "data", is_global=True).should_be_called()
|
||||
geometry.clear_modifiers("obj").should_be_called()
|
||||
geometry.is_body_representation("representation").should_be_called().will_return(True)
|
||||
geometry.create_dynamic_voids("obj").should_be_called()
|
||||
subject.switch_representation(
|
||||
@@ -219,7 +221,7 @@ class TestSwitchRepresentation:
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||
geometry.change_object_data("obj", "data", is_global=False).should_be_called()
|
||||
geometry.clear_dynamic_voids("obj").should_be_called()
|
||||
geometry.clear_modifiers("obj").should_be_called()
|
||||
subject.switch_representation(
|
||||
geometry,
|
||||
obj="obj",
|
||||
|
||||
@@ -53,11 +53,11 @@ class TestChangeObjectData(test.bim.bootstrap.NewFile):
|
||||
assert obj2.data == data2
|
||||
|
||||
|
||||
class TestClearDynamicVoids(test.bim.bootstrap.NewFile):
|
||||
class TestClearModifiers(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
|
||||
obj.modifiers.new("IfcOpeningElement", "BOOLEAN")
|
||||
subject.clear_dynamic_voids(obj)
|
||||
subject.clear_modifiers(obj)
|
||||
assert len(obj.modifiers) == 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user