Merge branch 'v0.7.0' into interface-to-interact-with-Brickschema

This commit is contained in:
Riley Wong
2023-06-30 00:05:20 -07:00
committed by GitHub
230 changed files with 9556 additions and 3363 deletions
+14 -11
View File
@@ -264,29 +264,32 @@ class TestAssign(NewFile):
def test_in_decomposition_mode_drawings_are_placed_in_a_group_in_a_views_collection(self):
bpy.ops.bim.create_project()
element_obj = bpy.data.objects.new("IfcAnnotation/Name", None)
element_obj = bpy.data.objects.new("IfcAnnotation/DRAWING", None)
element = tool.Ifc.get().createIfcAnnotation(ObjectType="DRAWING")
tool.Ifc.link(element, element_obj)
group = ifcopenshell.api.run("group.add_group", tool.Ifc.get())
group.ObjectType = "DRAWING"
ifcopenshell.api.run("group.assign_group", tool.Ifc.get(), products=[element], group=group)
subject.assign(element_obj)
assert element_obj.users_collection[0].name == "IfcGroup/Unnamed"
assert bpy.data.collections.get("Views").children.get("IfcGroup/Unnamed")
assert element_obj.users_collection[0].name == "IfcAnnotation/DRAWING"
assert bpy.data.collections.get("Views").children.get("IfcAnnotation/DRAWING")
assert bpy.data.collections.get("IfcProject/My Project").children.get("Views")
def test_in_decomposition_mode_annotations_are_placed_in_a_group_in_a_views_collection(self):
bpy.ops.bim.create_project()
self.test_in_decomposition_mode_drawings_are_placed_in_a_group_in_a_views_collection()
ifc_file = tool.Ifc.get()
element_obj = bpy.data.objects.new("IfcAnnotation/Name", None)
element = tool.Ifc.get().createIfcAnnotation()
element = ifc_file.createIfcAnnotation()
tool.Ifc.link(element, element_obj)
group = ifcopenshell.api.run("group.add_group", tool.Ifc.get())
group.ObjectType = "DRAWING"
ifcopenshell.api.run("group.assign_group", tool.Ifc.get(), products=[element], group=group)
group = ifc_file.by_type("IfcGroup")[0]
ifcopenshell.api.run("group.assign_group", ifc_file, products=[element], group=group)
subject.assign(element_obj)
assert element_obj.users_collection[0].name == "IfcGroup/Unnamed"
assert bpy.data.collections.get("Views").children.get("IfcGroup/Unnamed")
assert bpy.data.collections.get("IfcProject/My Project").children.get("Views")
assert element_obj.users_collection[0].name == "IfcAnnotation/DRAWING"
def test_in_decomposition_mode_structural_members_are_placed_in_a_members_collection(self):
bpy.ops.bim.create_project()
+3
View File
@@ -305,6 +305,9 @@ class TestGetDrawingCollection(NewFile):
collection = bpy.data.collections.new("Collection")
bpy.context.scene.collection.children.link(collection)
collection.objects.link(obj)
obj.BIMObjectProperties.collection = collection
collection.BIMCollectionProperties.obj = obj
element = ifc.createIfcAnnotation()
tool.Ifc.link(element, obj)
assert subject.get_drawing_collection(element) == collection
+2 -2
View File
@@ -478,7 +478,7 @@ class TestShouldGenerateUVs(NewFile):
obj.data.materials.append(material)
material.use_nodes = True
bsdf = material.node_tree.nodes["Principled BSDF"]
bsdf = tool.Blender.get_material_node(material, "BSDF_PRINCIPLED")
node = material.node_tree.nodes.new(type="ShaderNodeTexImage")
material.node_tree.links.new(bsdf.inputs["Base Color"], node.outputs["Color"])
@@ -494,7 +494,7 @@ class TestShouldGenerateUVs(NewFile):
obj.data.materials.append(material)
material.use_nodes = True
bsdf = material.node_tree.nodes["Principled BSDF"]
bsdf = tool.Blender.get_material_node(material, "BSDF_PRINCIPLED")
node = material.node_tree.nodes.new(type="ShaderNodeTexImage")
material.node_tree.links.new(bsdf.inputs["Base Color"], node.outputs["Color"])
-11
View File
@@ -170,14 +170,3 @@ class TestIsMaterialUsedInSets(NewFile):
material_set_item.Material = material
assert subject.is_material_used_in_sets(material) is True
class TestSelectElements(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc().set(ifc)
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcPump")
obj = bpy.data.objects.new("Object", None)
bpy.context.scene.collection.objects.link(obj)
tool.Ifc.link(element, obj)
subject.select_elements([element])
assert obj in bpy.context.selected_objects
+4 -1
View File
@@ -44,7 +44,7 @@ class TestCreateEmpty(NewFile):
class TestLoadDefaultThumbnails(NewFile):
def test_nothing(self):
pass # Not possible to test this headlessly
pass # Not possible to test this headlessly
class TestRunAggregateAssignObject(NewFile):
@@ -93,6 +93,9 @@ class TestSetActiveSpatialElement(NewFile):
collection = bpy.data.collections.new("Foo")
bpy.context.scene.collection.children.link(collection)
collection.objects.link(obj)
obj.BIMObjectProperties.collection = collection
collection.BIMCollectionProperties.obj = obj
layer = bpy.context.view_layer.layer_collection.children["Foo"]
assert bpy.context.view_layer.active_layer_collection != layer
subject.set_active_spatial_element(obj)
+12
View File
@@ -257,3 +257,15 @@ class TestSetRelativeObjectMatrix(NewFile):
matrix[0][3] = 1
subject.set_relative_object_matrix(obj, relative_obj, matrix)
assert obj.matrix_world[0][3] == 2
class TestSelectProducts(NewFile):
def test_select_products(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
product = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
obj = bpy.data.objects.new("Object", None)
bpy.context.scene.collection.objects.link(obj)
tool.Ifc.link(product, obj)
subject.select_products([product])
assert obj in bpy.context.selected_objects
+26 -18
View File
@@ -136,7 +136,7 @@ class TestGetSurfaceRenderingAttributes(NewFile):
obj = bpy.data.materials.new("Material")
obj.diffuse_color = [1, 1, 1, 1]
obj.use_nodes = True
node = obj.node_tree.nodes["Principled BSDF"]
node = tool.Blender.get_material_node(obj, "BSDF_PRINCIPLED")
node.inputs["Alpha"].default_value = 0.8
node.inputs["Base Color"].default_value = [0.5, 0.5, 0.5, 0.5]
node.inputs["Roughness"].default_value = 0.2
@@ -163,11 +163,15 @@ class TestGetSurfaceRenderingAttributes(NewFile):
obj = bpy.data.materials.new("Material")
obj.diffuse_color = [1, 1, 1, 1]
obj.use_nodes = True
node = obj.node_tree.nodes["Principled BSDF"]
output = tool.Blender.get_material_node(obj, "OUTPUT_MATERIAL")
node = tool.Blender.get_material_node(obj, "BSDF_PRINCIPLED")
obj.node_tree.nodes.remove(node)
node = obj.node_tree.nodes.new(type="ShaderNodeBsdfGlossy")
node.inputs["Color"].default_value = [0.5, 0.5, 0.5, 0.5]
node.inputs["Roughness"].default_value = 0.2
obj.node_tree.links.new(node.outputs[0], output.inputs[0])
assert subject.get_surface_rendering_attributes(obj) == {
"SurfaceColour": {
"Name": None,
@@ -190,11 +194,15 @@ class TestGetSurfaceRenderingAttributes(NewFile):
obj = bpy.data.materials.new("Material")
obj.diffuse_color = [1, 1, 1, 1]
obj.use_nodes = True
node = obj.node_tree.nodes["Principled BSDF"]
output = tool.Blender.get_material_node(obj, "OUTPUT_MATERIAL")
node = tool.Blender.get_material_node(obj, "BSDF_PRINCIPLED")
obj.node_tree.nodes.remove(node)
node = obj.node_tree.nodes.new(type="ShaderNodeBsdfDiffuse")
node.inputs["Color"].default_value = [0.5, 0.5, 0.5, 0.5]
node.inputs["Roughness"].default_value = 0.2
obj.node_tree.links.new(node.outputs[0], output.inputs[0])
assert subject.get_surface_rendering_attributes(obj) == {
"SurfaceColour": {
"Name": None,
@@ -217,11 +225,15 @@ class TestGetSurfaceRenderingAttributes(NewFile):
obj = bpy.data.materials.new("Material")
obj.diffuse_color = [1, 1, 1, 1]
obj.use_nodes = True
node = obj.node_tree.nodes["Principled BSDF"]
output = tool.Blender.get_material_node(obj, "OUTPUT_MATERIAL")
node = tool.Blender.get_material_node(obj, "BSDF_PRINCIPLED")
obj.node_tree.nodes.remove(node)
node = obj.node_tree.nodes.new(type="ShaderNodeBsdfGlass")
node.inputs["Color"].default_value = [0.5, 0.5, 0.5, 0.5]
node.inputs["Roughness"].default_value = 0.2
obj.node_tree.links.new(node.outputs[0], output.inputs[0])
assert subject.get_surface_rendering_attributes(obj) == {
"SurfaceColour": {
"Name": None,
@@ -244,10 +256,14 @@ class TestGetSurfaceRenderingAttributes(NewFile):
obj = bpy.data.materials.new("Material")
obj.diffuse_color = [1, 1, 1, 1]
obj.use_nodes = True
node = obj.node_tree.nodes["Principled BSDF"]
output = tool.Blender.get_material_node(obj, "OUTPUT_MATERIAL")
node = tool.Blender.get_material_node(obj, "BSDF_PRINCIPLED")
obj.node_tree.nodes.remove(node)
node = obj.node_tree.nodes.new(type="ShaderNodeEmission")
node.inputs["Color"].default_value = [0.5, 0.5, 0.5, 0.5]
obj.node_tree.links.new(node.outputs[0], output.inputs[0])
assert subject.get_surface_rendering_attributes(obj) == {
"SurfaceColour": {
"Name": None,
@@ -270,10 +286,14 @@ class TestGetSurfaceRenderingAttributes(NewFile):
obj = bpy.data.materials.new("Material")
obj.diffuse_color = [1, 1, 1, 1]
obj.use_nodes = True
node = obj.node_tree.nodes["Principled BSDF"]
output = tool.Blender.get_material_node(obj, "OUTPUT_MATERIAL")
node = tool.Blender.get_material_node(obj, "BSDF_PRINCIPLED")
obj.node_tree.nodes.remove(node)
node = obj.node_tree.nodes.new(type="ShaderNodeVolumePrincipled")
node.inputs["Color"].default_value = [0.5, 0.5, 0.5, 0.5]
obj.node_tree.links.new(node.outputs[0], output.inputs[0])
assert subject.get_surface_rendering_attributes(obj) == {
"SurfaceColour": {
"Name": None,
@@ -440,15 +460,3 @@ class TestIsEditingStyles(NewFile):
subject.is_editing_styles() is False
bpy.context.scene.BIMStylesProperties.is_editing = True
subject.is_editing_styles() is True
class TestSelectElements(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc().set(ifc)
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcPump")
obj = bpy.data.objects.new("Object", None)
bpy.context.scene.collection.objects.link(obj)
tool.Ifc.link(element, obj)
subject.select_elements([element])
assert obj in bpy.context.selected_objects
-12
View File
@@ -196,18 +196,6 @@ class TestRunRootAssignClass(NewFile):
pass
class TestSelectElements(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc().set(ifc)
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcPump")
obj = bpy.data.objects.new("Object", None)
bpy.context.scene.collection.objects.link(obj)
tool.Ifc.link(element, obj)
subject.select_elements([element])
assert obj in bpy.context.selected_objects
class TestSelectSystemProducts(NewFile):
def test_run(self):
ifc = ifcopenshell.file()