mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 14:07:43 +00:00
typing
This commit is contained in:
@@ -360,7 +360,7 @@ def i_load_a_new_pset_template_file():
|
||||
|
||||
@given("I create default MEP types")
|
||||
def i_create_default_mep_types():
|
||||
model_props = bpy.context.scene.BIMModelProperties
|
||||
model_props = tool.Model.get_model_props()
|
||||
|
||||
# add couple segments types
|
||||
model_props.type_class = "IfcDuctSegmentType"
|
||||
@@ -1244,13 +1244,13 @@ def i_display_the_construction_type_browser():
|
||||
@given("I add the construction type")
|
||||
@when("I add the construction type")
|
||||
def i_add_the_active_construction_type():
|
||||
props = bpy.context.scene.BIMModelProperties
|
||||
props = tool.Model.get_model_props()
|
||||
bpy.ops.bim.add_constr_type_instance(relating_type_id=int(props.relating_type_id))
|
||||
|
||||
|
||||
@then(parsers.parse("construction type is {relating_type_name}"))
|
||||
def construction_type(relating_type_name):
|
||||
props = bpy.context.scene.BIMModelProperties
|
||||
props = tool.Model.get_model_props()
|
||||
relating_type = AuthoringData.relating_type_name_by_id(props.ifc_class, props.relating_type_id)
|
||||
assert relating_type == relating_type_name, f"Construction Type is a {relating_type}, not a {relating_type_name}"
|
||||
|
||||
@@ -1333,7 +1333,8 @@ def the_obj_layer_lenght_is_set_to(value):
|
||||
|
||||
print(50 * "@", bpy.context.selected_objects)
|
||||
|
||||
bpy.context.scene.BIMModelProperties.length = value
|
||||
props = tool.Model.get_model_props()
|
||||
props.length = value
|
||||
bpy.ops.bim.change_layer_length(length=value)
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import bpy
|
||||
import mathutils
|
||||
import ifcopenshell
|
||||
import ifcopenshell.guid
|
||||
import ifcopenshell.util.element
|
||||
import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
from test.bim.bootstrap import NewFile
|
||||
@@ -107,7 +108,7 @@ class TestDeleteDrawingElements(NewFile):
|
||||
assert False
|
||||
except:
|
||||
pass
|
||||
assert not bpy.data.objects.get("Object")
|
||||
assert not bpy.data.objects["Object"]
|
||||
|
||||
|
||||
class TestDisableEditingDrawings(NewFile):
|
||||
@@ -141,9 +142,10 @@ class TestDisableEditingSheets(NewFile):
|
||||
class TestDisableEditingText(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
obj.BIMTextProperties.is_editing = True
|
||||
props = tool.Drawing.get_text_props(obj)
|
||||
props.is_editing = True
|
||||
subject.disable_editing_text(obj)
|
||||
assert obj.BIMTextProperties.is_editing == False
|
||||
assert props.is_editing == False
|
||||
|
||||
|
||||
class TestDisableEditingAssignedProduct(NewFile):
|
||||
@@ -194,7 +196,8 @@ class TestEnableEditingText(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
subject.enable_editing_text(obj)
|
||||
assert obj.BIMTextProperties.is_editing == True
|
||||
props = tool.Drawing.get_text_props(obj)
|
||||
assert props.is_editing == True
|
||||
|
||||
|
||||
class TestEnableEditingAssignedProduct(NewFile):
|
||||
@@ -238,7 +241,7 @@ class TestEnsureUniqueIdentification(NewFile):
|
||||
class TestExportTextLiteralAttributes(NewFile):
|
||||
def test_run(self):
|
||||
TestImportTextAttributes().test_run()
|
||||
assert subject.export_text_literal_attributes(bpy.data.objects.get("Object")) == [
|
||||
assert subject.export_text_literal_attributes(bpy.data.objects["Object"]) == [
|
||||
{
|
||||
"Literal": "Literal",
|
||||
"Path": "RIGHT",
|
||||
@@ -584,7 +587,8 @@ class TestImportTextAttributes(NewFile):
|
||||
element.ObjectType = "TEXT" # TODO: double check if it's valid to set this
|
||||
tool.Ifc.link(element, obj)
|
||||
subject.import_text_attributes(obj)
|
||||
literal_props = obj.BIMTextProperties.literals[0]
|
||||
props = tool.Drawing.get_text_props(obj)
|
||||
literal_props = props.literals[0]
|
||||
assert literal_props.attributes.get("Literal").string_value == "Literal"
|
||||
assert literal_props.attributes.get("Path").enum_value == "RIGHT"
|
||||
assert literal_props.attributes.get("BoxAlignment").string_value == "bottom-left"
|
||||
@@ -733,11 +737,12 @@ class TestUpdateTextValue(NewFile):
|
||||
TestGetTextLiteral().test_run()
|
||||
ifc = tool.Ifc.get()
|
||||
|
||||
obj = bpy.data.objects.get("Object")
|
||||
obj = bpy.data.objects["Object"]
|
||||
subject.update_text_value(obj)
|
||||
literal = obj.BIMTextProperties.literals[0]
|
||||
props = tool.Drawing.get_text_props(obj)
|
||||
literal = props.literals[0]
|
||||
|
||||
assert obj.BIMTextProperties.font_size == "2.5"
|
||||
assert props.font_size == "2.5"
|
||||
assert literal.value == "Literal"
|
||||
assert literal.box_alignment[:] == tuple([False] * 6 + [True] + [False] * 2)
|
||||
assert literal.ifc_definition_id == ifc.by_type("IfcTextLiteralWithExtent")[0].id()
|
||||
@@ -745,7 +750,7 @@ class TestUpdateTextValue(NewFile):
|
||||
def test_using_attribute_variables(self):
|
||||
TestGetTextLiteral().test_run()
|
||||
|
||||
obj = bpy.data.objects.get("Object")
|
||||
obj = bpy.data.objects["Object"]
|
||||
ifc = tool.Ifc.get()
|
||||
wall = ifc.createIfcWall(Name="Baz")
|
||||
label = ifc.by_type("IfcAnnotation")[0]
|
||||
@@ -754,12 +759,13 @@ class TestUpdateTextValue(NewFile):
|
||||
ifc.by_type("IfcTextLiteralWithExtent")[0].Literal = "Foo {{Name}} Bar"
|
||||
|
||||
subject.update_text_value(obj)
|
||||
assert obj.BIMTextProperties.literals[0].value == "Foo Baz Bar"
|
||||
props = tool.Drawing.get_text_props(obj)
|
||||
assert props.literals[0].value == "Foo Baz Bar"
|
||||
|
||||
def test_using_property_variables(self):
|
||||
TestGetTextLiteral().test_run()
|
||||
|
||||
obj = bpy.data.objects.get("Object")
|
||||
obj = bpy.data.objects["Object"]
|
||||
ifc = tool.Ifc.get()
|
||||
wall = ifc.createIfcWall()
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, name="Custom_Pset", product=wall)
|
||||
@@ -770,14 +776,16 @@ class TestUpdateTextValue(NewFile):
|
||||
ifc.by_type("IfcTextLiteralWithExtent")[0].Literal = "Foo {{Custom_Pset.Key}} Bar"
|
||||
|
||||
subject.update_text_value(obj)
|
||||
assert obj.BIMTextProperties.literals[0].value == "Foo Baz Bar"
|
||||
props = tool.Drawing.get_text_props(obj)
|
||||
assert props.literals[0].value == "Foo Baz Bar"
|
||||
|
||||
def test_update_text_font_size(self):
|
||||
TestGetTextLiteral().test_run()
|
||||
obj = bpy.data.objects.get("Object")
|
||||
obj = bpy.data.objects["Object"]
|
||||
with bpy.context.temp_override(active_object=obj):
|
||||
bpy.ops.bim.enable_editing_text()
|
||||
obj.BIMTextProperties.font_size = "7.0"
|
||||
props = tool.Drawing.get_text_props(obj)
|
||||
props.font_size = "7.0"
|
||||
bpy.ops.bim.edit_text()
|
||||
annotation_classes = ifcopenshell.util.element.get_pset(tool.Ifc.get_entity(obj), "EPset_Annotation", "Classes")
|
||||
assert "title" in annotation_classes
|
||||
@@ -786,11 +794,12 @@ class TestUpdateTextValue(NewFile):
|
||||
def test_add_second_literal(self, setup=True):
|
||||
if setup:
|
||||
TestGetTextLiteral().test_run()
|
||||
obj = bpy.data.objects.get("Object")
|
||||
obj = bpy.data.objects["Object"]
|
||||
with bpy.context.temp_override(active_object=obj):
|
||||
bpy.ops.bim.enable_editing_text()
|
||||
bpy.ops.bim.add_text_literal()
|
||||
literal = obj.BIMTextProperties.literals[1]
|
||||
props = tool.Drawing.get_text_props(obj)
|
||||
literal = props.literals[1]
|
||||
literal.attributes["Literal"].string_value = "test_value"
|
||||
bpy.ops.bim.edit_text()
|
||||
|
||||
@@ -802,8 +811,8 @@ class TestUpdateTextValue(NewFile):
|
||||
self.test_update_text_font_size() # sets font size to "7.0"
|
||||
self.test_add_second_literal(setup=False)
|
||||
|
||||
obj = bpy.data.objects.get("Object")
|
||||
props = obj.BIMTextProperties
|
||||
obj = bpy.data.objects["Object"]
|
||||
props = tool.Drawing.get_text_props(obj)
|
||||
assert obj is not None, obj
|
||||
with bpy.context.temp_override(active_object=obj):
|
||||
bpy.ops.bim.enable_editing_text()
|
||||
|
||||
@@ -41,13 +41,15 @@ class TestGenerateOccurrenceName(NewFile):
|
||||
def test_generating_based_on_class(self):
|
||||
ifc = ifcopenshell.file()
|
||||
element_type = ifc.createIfcWallType(Name="Foobar")
|
||||
bpy.context.scene.BIMModelProperties.occurrence_name_style = "CLASS"
|
||||
props = tool.Model.get_model_props()
|
||||
props.occurrence_name_style = "CLASS"
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Wall"
|
||||
|
||||
def test_generating_based_on_type_name(self):
|
||||
ifc = ifcopenshell.file()
|
||||
element_type = ifc.createIfcWallType()
|
||||
bpy.context.scene.BIMModelProperties.occurrence_name_style = "TYPE"
|
||||
props = tool.Model.get_model_props()
|
||||
props.occurrence_name_style = "TYPE"
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Unnamed"
|
||||
element_type.Name = "Foobar"
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Foobar"
|
||||
@@ -55,8 +57,9 @@ class TestGenerateOccurrenceName(NewFile):
|
||||
def test_generating_based_on_a_custom_function(self):
|
||||
ifc = ifcopenshell.file()
|
||||
element_type = ifc.createIfcWallType()
|
||||
bpy.context.scene.BIMModelProperties.occurrence_name_style = "CUSTOM"
|
||||
bpy.context.scene.BIMModelProperties.occurrence_name_function = '"Foobar"'
|
||||
props = tool.Model.get_model_props()
|
||||
props.occurrence_name_style = "CUSTOM"
|
||||
props.occurrence_name_function = '"Foobar"'
|
||||
assert subject.generate_occurrence_name(element_type, "IfcWall") == "Foobar"
|
||||
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ class TestSetDefaultModelingDimensions(NewFile):
|
||||
ifc.createIfcProject()
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc)
|
||||
subject.set_default_modeling_dimensions()
|
||||
props = bpy.context.scene.BIMModelProperties
|
||||
props = tool.Model.get_model_props()
|
||||
assert props.extrusion_depth == 3
|
||||
assert props.length == 1
|
||||
assert props.rl1 == 0
|
||||
|
||||
@@ -34,7 +34,7 @@ class TestAddTrackedOpening(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
subject.add_tracked_opening(obj, "OPENING")
|
||||
props = bpy.context.scene.BIMModelProperties
|
||||
props = tool.Model.get_model_props()
|
||||
assert props.openings[0].obj == obj
|
||||
assert props.openings[0].name == "OPENING"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user