mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
#2094. Removing styles now also purges Blender material object if possible.
This commit is contained in:
@@ -112,7 +112,6 @@ Scenario: Assign material - Assign a material profile set
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Select by material
|
||||
Scenario: Load materials - then add material
|
||||
Given an empty IFC project
|
||||
And I press "bim.load_materials"
|
||||
And I press "bim.add_material(obj='')"
|
||||
|
||||
@@ -14,7 +14,8 @@ Scenario: Remove style
|
||||
And I add a cube
|
||||
And I add a material
|
||||
And I press "bim.add_style"
|
||||
When I press "bim.remove_style"
|
||||
And the variable "style" is "{ifc}.by_type('IfcSurfaceStyle')[0].id()"
|
||||
When I press "bim.remove_style(style={style})"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Add style
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import blenderbim.core.style as subject
|
||||
from test.core.bootstrap import ifc, style
|
||||
from test.core.bootstrap import ifc, material, style
|
||||
|
||||
|
||||
class TestAddStyle:
|
||||
@@ -53,11 +53,32 @@ class TestAddStyle:
|
||||
|
||||
|
||||
class TestRemoveStyle:
|
||||
def test_run(self, ifc, style):
|
||||
style.get_style("obj").should_be_called().will_return("style")
|
||||
def test_removing_a_style(self, ifc, material, style):
|
||||
ifc.get_object("style").should_be_called().will_return("obj")
|
||||
ifc.unlink(obj="obj", element="style").should_be_called()
|
||||
ifc.run("style.remove_style", style="style").should_be_called()
|
||||
subject.remove_style(ifc, style, obj="obj")
|
||||
ifc.get_entity("obj").should_be_called().will_return("material")
|
||||
style.is_editing_styles().should_be_called().will_return(False)
|
||||
subject.remove_style(ifc, material, style, style="style")
|
||||
|
||||
def test_removing_a_style_and_reloading_imported_styles(self, ifc, material, style):
|
||||
ifc.get_object("style").should_be_called().will_return("obj")
|
||||
ifc.unlink(obj="obj", element="style").should_be_called()
|
||||
ifc.run("style.remove_style", style="style").should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return("material")
|
||||
style.is_editing_styles().should_be_called().will_return(True)
|
||||
style.get_active_style_type().should_be_called().will_return("style_type")
|
||||
style.import_presentation_styles("style_type").should_be_called()
|
||||
subject.remove_style(ifc, material, style, style="style")
|
||||
|
||||
def test_removing_an_object_if_it_is_not_still_used_for_a_material(self, ifc, material, style):
|
||||
ifc.get_object("style").should_be_called().will_return("obj")
|
||||
ifc.unlink(obj="obj", element="style").should_be_called()
|
||||
ifc.run("style.remove_style", style="style").should_be_called()
|
||||
ifc.get_entity("obj").should_be_called().will_return(None)
|
||||
material.delete_object("obj").should_be_called()
|
||||
style.is_editing_styles().should_be_called().will_return(False)
|
||||
subject.remove_style(ifc, material, style, style="style")
|
||||
|
||||
|
||||
class TestUpdateStyleColours:
|
||||
|
||||
@@ -78,6 +78,16 @@ class TestExportSurfaceAttributes(NewFile):
|
||||
assert subject.export_surface_attributes(obj) == {"Name": "Name", "Side": "BOTH"}
|
||||
|
||||
|
||||
class TestGetActiveStyleType(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
bpy.context.scene.BIMStylesProperties.style_type = "IfcSurfaceStyle"
|
||||
assert subject.get_active_style_type() == "IfcSurfaceStyle"
|
||||
bpy.context.scene.BIMStylesProperties.style_type = "IfcCurveStyle"
|
||||
assert subject.get_active_style_type() == "IfcCurveStyle"
|
||||
|
||||
|
||||
class TestGetContext(NewFile):
|
||||
def test_run(self):
|
||||
bpy.ops.bim.create_project()
|
||||
@@ -408,3 +418,11 @@ class TestImportPresentationStyles(NewFile):
|
||||
assert props.styles[0].ifc_definition_id == style.id()
|
||||
assert props.styles[0].name == "Name"
|
||||
assert props.styles[0].total_elements == 0
|
||||
|
||||
|
||||
class TestIsEditingStyles(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.BIMStylesProperties.is_editing = False
|
||||
subject.is_editing_styles() is False
|
||||
bpy.context.scene.BIMStylesProperties.is_editing = True
|
||||
subject.is_editing_styles() is True
|
||||
|
||||
Reference in New Issue
Block a user