mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 22:31:55 +00:00
New feature to unlink Blender materials and IFC materials
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
@material
|
||||
Feature: Material
|
||||
|
||||
Scenario: Unlink object
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I add a material
|
||||
And I press "bim.add_material"
|
||||
When I press "bim.unlink_material"
|
||||
Then the material "Material" is not an IFC material
|
||||
@@ -30,7 +30,7 @@ Scenario: Unlink style
|
||||
And I add a material
|
||||
And I press "bim.add_style"
|
||||
When I press "bim.unlink_style"
|
||||
Then nothing happens
|
||||
Then the material "Material" is not an IFC style
|
||||
|
||||
Scenario: Enable editing style
|
||||
Given an empty IFC project
|
||||
|
||||
@@ -159,6 +159,14 @@ def the_object_name_exists(name) -> bpy.types.Object:
|
||||
return obj
|
||||
|
||||
|
||||
@then(parsers.parse('the material "{name}" exists'))
|
||||
def the_material_name_exists(name) -> bpy.types.Material:
|
||||
obj = bpy.data.materials.get(name)
|
||||
if not obj:
|
||||
assert False, f'The material "{name}" does not exist'
|
||||
return obj
|
||||
|
||||
|
||||
@then("an IFC file does not exist")
|
||||
def an_ifc_file_does_not_exist():
|
||||
ifc = IfcStore.get_file()
|
||||
@@ -249,6 +257,18 @@ def the_object_name_is_not_an_ifc_element(name):
|
||||
assert id == 0, f"The ID is {id}"
|
||||
|
||||
|
||||
@then(parsers.parse('the material "{name}" is not an IFC material'))
|
||||
def the_material_name_is_not_an_ifc_material(name):
|
||||
id = the_material_name_exists(name).BIMObjectProperties.ifc_definition_id
|
||||
assert id == 0, f"The ID is {id}"
|
||||
|
||||
|
||||
@then(parsers.parse('the material "{name}" is not an IFC style'))
|
||||
def the_material_name_is_not_an_ifc_material(name):
|
||||
id = the_material_name_exists(name).BIMMaterialProperties.ifc_style_id
|
||||
assert id == 0, f"The ID is {id}"
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name}" has "{number}" vertices'))
|
||||
def the_object_name_has_number_vertices(name, number):
|
||||
total = len(the_object_name_exists(name).data.vertices)
|
||||
|
||||
@@ -49,6 +49,13 @@ def context():
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def material():
|
||||
prophet = Prophecy(blenderbim.core.tool.Material)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def owner():
|
||||
prophet = Prophecy(blenderbim.core.tool.Owner)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of BlenderBIM Add-on.
|
||||
#
|
||||
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# BlenderBIM Add-on is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import blenderbim.core.material as subject
|
||||
from test.core.bootstrap import ifc, material
|
||||
|
||||
|
||||
class TestUnlinkMaterial:
|
||||
def test_run(self, material):
|
||||
material.unlink("obj").should_be_called()
|
||||
subject.unlink_material(material, obj="obj")
|
||||
@@ -127,7 +127,7 @@ class TestImportContainers(NewFile):
|
||||
bpy.ops.bim.copy_class(obj=tool.Ifc.get_object(storey1).name)
|
||||
storey2 = tool.Ifc.get().by_type("IfcBuildingStorey")[1]
|
||||
storey2.Name = "Lower"
|
||||
storey2.ObjectPlacement.RelativePlacement.Location.Coordinates = (0., 0., -100.)
|
||||
storey2.ObjectPlacement.RelativePlacement.Location.Coordinates = (0.0, 0.0, -100.0)
|
||||
subject.import_containers(building)
|
||||
props = bpy.context.scene.BIMSpatialProperties
|
||||
assert len(props.containers) == 2
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of BlenderBIM Add-on.
|
||||
#
|
||||
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# BlenderBIM Add-on is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import blenderbim.core.tool
|
||||
import blenderbim.tool as tool
|
||||
from test.bim.bootstrap import NewFile
|
||||
from blenderbim.tool.material import Material as subject
|
||||
|
||||
|
||||
class TestLink(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.materials.new("Material")
|
||||
ifc = ifcopenshell.file()
|
||||
material = ifc.createIfcMaterial()
|
||||
subject.link(material, obj)
|
||||
assert obj.BIMObjectProperties.ifc_definition_id == material.id()
|
||||
|
||||
|
||||
class TestUnlink(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.materials.new("Material")
|
||||
ifc = ifcopenshell.file()
|
||||
material = ifc.createIfcMaterial()
|
||||
subject.link(material, obj)
|
||||
subject.unlink(obj)
|
||||
assert obj.BIMObjectProperties.ifc_definition_id == 0
|
||||
Reference in New Issue
Block a user