mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Fix remaining failing tool tests
This commit is contained in:
@@ -1015,7 +1015,6 @@ class Style:
|
||||
def get_elements_by_style(cls, style): pass
|
||||
def get_currently_edited_material(cls): pass
|
||||
def get_name(cls, obj): pass
|
||||
def get_style(cls, obj): pass
|
||||
def get_style_elements(cls, blender_material): pass
|
||||
def get_surface_rendering_attributes(cls, obj, verbose=True): pass
|
||||
def get_surface_rendering_style(cls, obj): pass
|
||||
|
||||
@@ -95,7 +95,7 @@ class Loader(bonsai.core.tool.Loader):
|
||||
def get_name(cls, element: ifcopenshell.entity_instance) -> str:
|
||||
if element.is_a("IfcGridAxis"):
|
||||
return "{}/{}".format(element.is_a(), element.AxisTag)
|
||||
return "{}/{}".format(element.is_a(), getattr(element, "Name", "None"))
|
||||
return "{}/{}".format(element.is_a(), getattr(element, "Name", "Unnamed") or "Unnamed")
|
||||
|
||||
@classmethod
|
||||
def link_mesh(
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import bonsai.core.tool
|
||||
@@ -32,14 +31,21 @@ class TestImplementsTool(NewFile):
|
||||
|
||||
class TestValidateInput(NewFile):
|
||||
def test_simple_units(self):
|
||||
ifc = ifcopenshell.api.project.create_file()
|
||||
tool.Ifc.set(ifc)
|
||||
ifcopenshell.api.root.create_entity(ifc, ifc_class="IfcProject")
|
||||
unit = ifcopenshell.api.unit.add_si_unit(ifc, unit_type="LENGTHUNIT", prefix=None)
|
||||
ifcopenshell.api.unit.assign_unit(ifc, [unit])
|
||||
unit_settings = bpy.context.scene.unit_settings
|
||||
unit_settings.system = "METRIC"
|
||||
unit_settings.length_unit = "METERS"
|
||||
assert subject.validate_input("25", "D") == (True, "25.0")
|
||||
unit.Prefix = "MILLI"
|
||||
unit_settings.length_unit = "MILLIMETERS"
|
||||
assert subject.validate_input("25", "D") == (True, "0.025")
|
||||
|
||||
unit_settings.system = "IMPERIAL"
|
||||
unit = ifcopenshell.api.unit.add_conversion_based_unit(ifc, name="foot")
|
||||
ifcopenshell.api.unit.assign_unit(ifc, [unit])
|
||||
assert subject.validate_input("25", "D") == (True, "7.62")
|
||||
assert subject.validate_input("25'", "D") == (True, "7.62")
|
||||
assert subject.validate_input('25"', "D") == (True, "0.635")
|
||||
|
||||
@@ -201,7 +201,6 @@ class TestGetRelatedCostItemQuantities(test.bim.bootstrap.NewFile):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
wall = ifc.createIfcWall()
|
||||
product = tool.Ifc.get_entity(wall)
|
||||
schedule = ifcopenshell.api.run("cost.add_cost_schedule", ifc)
|
||||
item = ifcopenshell.api.run("cost.add_cost_item", ifc, cost_schedule=schedule)
|
||||
ifcopenshell.api.run("cost.edit_cost_item", ifc, cost_item=item, attributes={"Name": "Foo"})
|
||||
|
||||
@@ -250,7 +250,7 @@ class TestGenerateSpace(NewFile):
|
||||
mesh = space.data
|
||||
assert isinstance(mesh, bpy.types.Mesh)
|
||||
assert len(mesh.vertices) == 8
|
||||
TEST_VERTS = (
|
||||
TEST_VERTS = sorted((
|
||||
((5.0, 5.0, 10.0)),
|
||||
((-5.0, 5.0, 10.0)),
|
||||
((-5.0, -5.0, 10.0)),
|
||||
@@ -259,5 +259,5 @@ class TestGenerateSpace(NewFile):
|
||||
((-5.0, -5.0, 0.0)),
|
||||
((5.0, 5.0, 0.0)),
|
||||
((5.0, -5.0, 0.0)),
|
||||
)
|
||||
assert np.allclose(TEST_VERTS, [tuple(v.co) for v in mesh.vertices])
|
||||
))
|
||||
assert np.allclose(TEST_VERTS, sorted([tuple(v.co) for v in mesh.vertices]))
|
||||
|
||||
@@ -117,23 +117,6 @@ class TestGetName(NewFile):
|
||||
assert subject.get_name(bpy.data.materials.new("Material")) == "Material"
|
||||
|
||||
|
||||
class TestGetStyle(NewFile):
|
||||
def test_getting_no_style(self):
|
||||
assert subject.get_style(bpy.data.materials.new("Material")) is None
|
||||
|
||||
def test_getting_a_linked_style(self):
|
||||
tool.Ifc.set(ifcopenshell.file())
|
||||
style = tool.Ifc.get().createIfcSurfaceStyle()
|
||||
obj = bpy.data.materials.new("Material")
|
||||
obj.BIMStyleProperties.ifc_definition_id = style.id()
|
||||
assert subject.get_style(obj) == style
|
||||
|
||||
def test_getting_nothing_for_a_broken_link_style(self):
|
||||
obj = bpy.data.materials.new("Material")
|
||||
obj.BIMStyleProperties.ifc_definition_id = 1
|
||||
assert subject.get_style(obj) == None
|
||||
|
||||
|
||||
class TestGetSurfaceRenderingAttributes(NewFile):
|
||||
def test_get_different_surface_and_diffuse_colours_from_a_principled_bsdf(self):
|
||||
obj = bpy.data.materials.new("Material")
|
||||
|
||||
Reference in New Issue
Block a user