mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
typing
This commit is contained in:
@@ -911,14 +911,14 @@ def the_material_name_is_not_an_ifc_material(name):
|
||||
@then(parsers.parse('the material "{name}" is an IFC style'))
|
||||
def the_material_name_is_an_ifc_style(name):
|
||||
obj = the_material_name_exists(name)
|
||||
ifc_definition_id = obj.BIMStyleProperties.ifc_definition_id
|
||||
ifc_definition_id = tool.Blender.get_ifc_definition_id(obj)
|
||||
assert ifc_definition_id != 0, f"The material {obj} has a style ID of {ifc_definition_id}"
|
||||
|
||||
|
||||
@then(parsers.parse('the material "{name}" is not an IFC style'))
|
||||
def the_material_name_is_not_an_ifc_style(name):
|
||||
obj = the_material_name_exists(name)
|
||||
ifc_definition_id = obj.BIMStyleProperties.ifc_definition_id
|
||||
ifc_definition_id = tool.Blender.get_ifc_definition_id(obj)
|
||||
assert ifc_definition_id == 0, f"The material {obj} has a style ID of {ifc_definition_id}"
|
||||
|
||||
|
||||
|
||||
@@ -891,11 +891,12 @@ class TestAddReferenceImage(NewFile):
|
||||
assert tool.Cad.are_vectors_equal(obj.dimensions, Vector((3.53982, 2.0, 0.0)))
|
||||
|
||||
material = obj.active_material
|
||||
assert material
|
||||
assert material.name == "image"
|
||||
assert material.BIMStyleProperties.ifc_definition_id != 0
|
||||
assert tool.Blender.get_ifc_definition_id(material) != 0
|
||||
|
||||
ifc_file = tool.Ifc.get()
|
||||
style = ifc_file.by_id(material.BIMStyleProperties.ifc_definition_id)
|
||||
style = tool.Ifc.get_entity(material)
|
||||
assert style
|
||||
styled_items = set(tool.Style.get_styled_items(style))
|
||||
representation_items = set(tool.Geometry.get_active_representation(obj).Items)
|
||||
assert styled_items == representation_items
|
||||
|
||||
@@ -112,7 +112,8 @@ class TestGetObjectMaterialsWithoutStyles(NewFile):
|
||||
material1 = bpy.data.materials.new("Material")
|
||||
material2 = bpy.data.materials.new("Material")
|
||||
material3 = bpy.data.materials.new("Material")
|
||||
material3.BIMStyleProperties.ifc_definition_id = 1
|
||||
props = tool.Style.get_material_style_props(material3)
|
||||
props.ifc_definition_id = 1
|
||||
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
|
||||
obj.data.materials.append(material1)
|
||||
obj.data.materials.append(material2)
|
||||
@@ -307,7 +308,7 @@ class TestRecordObjectMaterials(NewFile):
|
||||
tool.Ifc.set(ifc)
|
||||
style = ifc.createIfcSurfaceStyle()
|
||||
material = bpy.data.materials.new("Material")
|
||||
material.BIMStyleProperties.ifc_definition_id = style.id()
|
||||
tool.Ifc.link(style, material)
|
||||
obj.data.materials.append(material)
|
||||
subject.record_object_materials(obj)
|
||||
assert tool.Geometry.get_mesh_props(obj.data).material_checksum == str([style.id()])
|
||||
|
||||
@@ -462,7 +462,7 @@ class TestApplyIfcMaterialChanges(NewFile):
|
||||
def get_used_styles(self, obj: bpy.types.Object) -> set[ifcopenshell.entity_instance]:
|
||||
ifc_file = tool.Ifc.get()
|
||||
return {
|
||||
ifc_file.by_id(s.material.BIMStyleProperties.ifc_definition_id) for s in obj.material_slots if s.material
|
||||
ifc_file.by_id(tool.Blender.get_ifc_definition_id(s.material)) for s in obj.material_slots if s.material
|
||||
}
|
||||
|
||||
def get_mesh(self, obj: bpy.types.Object) -> bpy.types.Mesh:
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.project
|
||||
import ifcopenshell.api.root
|
||||
import ifcopenshell.api.unit
|
||||
import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
from test.bim.bootstrap import NewFile
|
||||
|
||||
@@ -308,7 +308,8 @@ class TestGetSurfaceRenderingStyle(NewFile):
|
||||
style_item = tool.Ifc.get().createIfcSurfaceStyleRendering()
|
||||
style = tool.Ifc.get().createIfcSurfaceStyle(Styles=[style_item])
|
||||
obj = bpy.data.materials.new("Material")
|
||||
obj.BIMStyleProperties.ifc_definition_id = style.id()
|
||||
props = tool.Style.get_material_style_props(obj)
|
||||
props.ifc_definition_id = style.id()
|
||||
assert subject.get_surface_rendering_style(obj) == style_item
|
||||
|
||||
|
||||
@@ -347,7 +348,7 @@ class TestGetSurfaceShadingStyle(NewFile):
|
||||
style_item = tool.Ifc.get().createIfcSurfaceStyleShading()
|
||||
style = tool.Ifc.get().createIfcSurfaceStyle(Styles=[style_item])
|
||||
obj = bpy.data.materials.new("Material")
|
||||
obj.BIMStyleProperties.ifc_definition_id = style.id()
|
||||
tool.Ifc.link(style, obj)
|
||||
assert subject.get_surface_shading_style(obj) == style_item
|
||||
|
||||
def test_do_not_get_rendering_styles(self):
|
||||
@@ -355,7 +356,7 @@ class TestGetSurfaceShadingStyle(NewFile):
|
||||
style_item = tool.Ifc.get().createIfcSurfaceStyleRendering()
|
||||
style = tool.Ifc.get().createIfcSurfaceStyle(Styles=[style_item])
|
||||
obj = bpy.data.materials.new("Material")
|
||||
obj.BIMStyleProperties.ifc_definition_id = style.id()
|
||||
tool.Ifc.link(style, obj)
|
||||
assert subject.get_surface_shading_style(obj) is None
|
||||
|
||||
|
||||
@@ -365,7 +366,7 @@ class TestGetSurfaceTextureStyle(NewFile):
|
||||
style_item = tool.Ifc.get().createIfcSurfaceStyleWithTextures()
|
||||
style = tool.Ifc.get().createIfcSurfaceStyle(Styles=[style_item])
|
||||
obj = bpy.data.materials.new("Material")
|
||||
obj.BIMStyleProperties.ifc_definition_id = style.id()
|
||||
tool.Ifc.link(style, obj)
|
||||
assert subject.get_surface_texture_style(obj) == style_item
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user