mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
typing
This commit is contained in:
@@ -23,6 +23,7 @@ import bpy
|
||||
import pytest
|
||||
import webbrowser
|
||||
import bonsai.bim.handler
|
||||
import bonsai.tool as tool
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.element
|
||||
import ifcopenshell.util.representation
|
||||
@@ -66,7 +67,8 @@ class NewIfc4X3:
|
||||
bpy.data.batch_remove(bpy.data.objects)
|
||||
bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=True, do_recursive=True)
|
||||
bonsai.bim.handler.load_post(None)
|
||||
bpy.context.scene.BIMProjectProperties.export_schema = "IFC4X3_ADD2"
|
||||
props = tool.Project.get_project_props()
|
||||
props.export_schema = "IFC4X3_ADD2"
|
||||
bpy.ops.bim.create_project()
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ scenarios("feature")
|
||||
|
||||
variables = {
|
||||
"cwd": Path.cwd().as_posix(),
|
||||
"ifc": "IfcStore.get_file()",
|
||||
"ifc": "tool.Ifc.get()",
|
||||
"pset_ifc": "IfcStore.pset_template_file",
|
||||
"classification_ifc": "IfcStore.classification_file",
|
||||
}
|
||||
@@ -190,7 +190,8 @@ def an_empty_blender_session():
|
||||
# default project settings
|
||||
bpy.context.scene.unit_settings.system = "METRIC"
|
||||
bpy.context.scene.unit_settings.length_unit = "MILLIMETERS"
|
||||
bpy.context.scene.BIMProjectProperties.template_file = "0"
|
||||
props = tool.Project.get_project_props()
|
||||
props.template_file = "0"
|
||||
tool.Blender.get_addon_preferences().should_play_chaching_sound = False
|
||||
|
||||
|
||||
@@ -203,7 +204,8 @@ def an_empty_ifc_project():
|
||||
@given("an empty IFC2X3 project")
|
||||
def an_empty_ifc_2x3_project():
|
||||
an_empty_blender_session()
|
||||
bpy.context.scene.BIMProjectProperties.export_schema = "IFC2X3"
|
||||
props = tool.Project.get_project_props()
|
||||
props.export_schema = "IFC2X3"
|
||||
bpy.ops.bim.create_project()
|
||||
|
||||
|
||||
@@ -742,7 +744,7 @@ def the_object_name_has_a_representation_type_of_context(name, type, context):
|
||||
def the_object_name_data_is_a_type_representation_of_context(name, type, context):
|
||||
ifc = an_ifc_file_exists()
|
||||
context, subcontext, target_view = context.split("/")
|
||||
rep = ifc.by_id(the_object_name_exists(name).data.BIMMeshProperties.ifc_definition_id)
|
||||
rep = ifc.by_id(tool.Geometry.get_mesh_props(the_object_name_exists(name).data).ifc_definition_id)
|
||||
assert rep
|
||||
assert rep.RepresentationType == type, f"The object {name} is not a {type} representation"
|
||||
assert rep.ContextOfItems.ContextType == context
|
||||
@@ -888,7 +890,7 @@ def the_object_name_has_no_data(name):
|
||||
|
||||
@then(parsers.parse('the object "{name}" has data which is an IFC representation'))
|
||||
def the_object_name_has_ifc_representation_data(name):
|
||||
id = the_object_name_exists(name).data.BIMMeshProperties.ifc_definition_id
|
||||
id = tool.Geometry.get_mesh_props(the_object_name_exists(name).data).ifc_definition_id
|
||||
assert id != 0, f"The ID is {id}"
|
||||
|
||||
|
||||
|
||||
@@ -113,30 +113,34 @@ class TestDeleteDrawingElements(NewFile):
|
||||
|
||||
class TestDisableEditingDrawings(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_drawings = True
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.is_editing_drawings = True
|
||||
subject.disable_editing_drawings()
|
||||
assert bpy.context.scene.DocProperties.is_editing_drawings == False
|
||||
assert props.is_editing_drawings == False
|
||||
|
||||
|
||||
class TestDisableEditingSchedules(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_schedules = True
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.is_editing_schedules = True
|
||||
subject.disable_editing_schedules()
|
||||
assert bpy.context.scene.DocProperties.is_editing_schedules == False
|
||||
assert props.is_editing_schedules == False
|
||||
|
||||
|
||||
class TestDisableEditingReferences(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_references = True
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.is_editing_references = True
|
||||
subject.disable_editing_references()
|
||||
assert bpy.context.scene.DocProperties.is_editing_references == False
|
||||
assert props.is_editing_references == False
|
||||
|
||||
|
||||
class TestDisableEditingSheets(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_sheets = True
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.is_editing_sheets = True
|
||||
subject.disable_editing_sheets()
|
||||
assert bpy.context.scene.DocProperties.is_editing_sheets == False
|
||||
assert props.is_editing_sheets == False
|
||||
|
||||
|
||||
class TestDisableEditingText(NewFile):
|
||||
@@ -166,30 +170,34 @@ class TestEnableEditing(NewFile):
|
||||
|
||||
class TestEnableEditingDrawings(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_drawings = False
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.is_editing_drawings = False
|
||||
subject.enable_editing_drawings()
|
||||
assert bpy.context.scene.DocProperties.is_editing_drawings == True
|
||||
assert props.is_editing_drawings == True
|
||||
|
||||
|
||||
class TestEnableEditingSchedules(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_schedules = False
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.is_editing_schedules = False
|
||||
subject.enable_editing_schedules()
|
||||
assert bpy.context.scene.DocProperties.is_editing_schedules == True
|
||||
assert props.is_editing_schedules == True
|
||||
|
||||
|
||||
class TestEnableEditingReferences(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_references = False
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.is_editing_references = False
|
||||
subject.enable_editing_references()
|
||||
assert bpy.context.scene.DocProperties.is_editing_references == True
|
||||
assert props.is_editing_references == True
|
||||
|
||||
|
||||
class TestEnableEditingSheets(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.is_editing_sheets = False
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.is_editing_sheets = False
|
||||
subject.enable_editing_sheets()
|
||||
assert bpy.context.scene.DocProperties.is_editing_sheets == True
|
||||
assert props.is_editing_sheets == True
|
||||
|
||||
|
||||
class TestEnableEditingText(NewFile):
|
||||
@@ -492,7 +500,7 @@ class TestImportDrawings(NewFile):
|
||||
pset = ifcopenshell.api.run("pset.add_pset", ifc, product=drawing, name="EPset_Drawing")
|
||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"TargetView": "PLAN_VIEW"})
|
||||
subject.import_drawings()
|
||||
props = bpy.context.scene.DocProperties
|
||||
props = tool.Drawing.get_document_props()
|
||||
for d in props.drawings:
|
||||
d.is_expanded = True
|
||||
subject.import_drawings()
|
||||
@@ -508,7 +516,7 @@ class TestImportSchedules(NewFile):
|
||||
ifc.createIfcDocumentInformation(Identification="Y", Name="FOOBAZ")
|
||||
document = ifc.createIfcDocumentInformation(Identification="X", Name="FOOBAR", Scope="SCHEDULE")
|
||||
subject.import_documents("SCHEDULE")
|
||||
props = bpy.context.scene.DocProperties
|
||||
props = tool.Drawing.get_document_props()
|
||||
assert props.schedules[0].ifc_definition_id == document.id()
|
||||
assert props.schedules[0].identification == "X"
|
||||
assert props.schedules[0].name == "FOOBAR"
|
||||
@@ -519,7 +527,7 @@ class TestImportSchedules(NewFile):
|
||||
ifc.createIfcDocumentInformation(DocumentId="Y", Name="FOOBAZ")
|
||||
document = ifc.createIfcDocumentInformation(DocumentId="X", Name="FOOBAR", Scope="SCHEDULE")
|
||||
subject.import_documents("SCHEDULE")
|
||||
props = bpy.context.scene.DocProperties
|
||||
props = tool.Drawing.get_document_props()
|
||||
assert props.schedules[0].ifc_definition_id == document.id()
|
||||
assert props.schedules[0].identification == "X"
|
||||
assert props.schedules[0].name == "FOOBAR"
|
||||
@@ -532,7 +540,7 @@ class TestImportReferences(NewFile):
|
||||
ifc.createIfcDocumentInformation(Identification="Y", Name="FOOBAZ")
|
||||
document = ifc.createIfcDocumentInformation(Identification="X", Name="FOOBAR", Scope="REFERENCE")
|
||||
subject.import_documents("REFERENCE")
|
||||
props = bpy.context.scene.DocProperties
|
||||
props = tool.Drawing.get_document_props()
|
||||
assert props.references[0].ifc_definition_id == document.id()
|
||||
assert props.references[0].identification == "X"
|
||||
assert props.references[0].name == "FOOBAR"
|
||||
@@ -543,7 +551,7 @@ class TestImportReferences(NewFile):
|
||||
ifc.createIfcDocumentInformation(DocumentId="Y", Name="FOOBAZ")
|
||||
document = ifc.createIfcDocumentInformation(DocumentId="X", Name="FOOBAR", Scope="REFERENCE")
|
||||
subject.import_documents("REFERENCE")
|
||||
props = bpy.context.scene.DocProperties
|
||||
props = tool.Drawing.get_document_props()
|
||||
assert props.references[0].ifc_definition_id == document.id()
|
||||
assert props.references[0].identification == "X"
|
||||
assert props.references[0].name == "FOOBAR"
|
||||
@@ -556,7 +564,7 @@ class TestImportSheets(NewFile):
|
||||
ifc.createIfcDocumentInformation(Identification="Y", Name="FOOBAZ")
|
||||
document = ifc.createIfcDocumentInformation(Identification="X", Name="FOOBAR", Scope="SHEET")
|
||||
subject.import_sheets()
|
||||
props = bpy.context.scene.DocProperties
|
||||
props = tool.Drawing.get_document_props()
|
||||
assert props.sheets[0].ifc_definition_id == document.id()
|
||||
assert props.sheets[0].identification == "X"
|
||||
assert props.sheets[0].name == "FOOBAR"
|
||||
@@ -567,7 +575,7 @@ class TestImportSheets(NewFile):
|
||||
ifc.createIfcDocumentInformation(DocumentId="Y", Name="FOOBAZ")
|
||||
document = ifc.createIfcDocumentInformation(DocumentId="X", Name="FOOBAR", Scope="SHEET")
|
||||
subject.import_sheets()
|
||||
props = bpy.context.scene.DocProperties
|
||||
props = tool.Drawing.get_document_props()
|
||||
assert props.sheets[0].ifc_definition_id == document.id()
|
||||
assert props.sheets[0].identification == "X"
|
||||
assert props.sheets[0].name == "FOOBAR"
|
||||
@@ -657,9 +665,10 @@ class TestSetName(NewFile):
|
||||
|
||||
class TestShowDecorations(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.DocProperties.should_draw_decorations = False
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.should_draw_decorations = False
|
||||
subject.show_decorations()
|
||||
assert bpy.context.scene.DocProperties.should_draw_decorations is True
|
||||
assert props.should_draw_decorations is True
|
||||
|
||||
|
||||
class TestDrawingMaintainingSheetPosition(NewFile):
|
||||
@@ -680,7 +689,7 @@ class TestDrawingMaintainingSheetPosition(NewFile):
|
||||
return drawing_data
|
||||
|
||||
def test_run(self):
|
||||
props = bpy.context.scene.DocProperties
|
||||
props = tool.Drawing.get_document_props()
|
||||
bpy.ops.bim.create_project()
|
||||
ifc = tool.Ifc.get()
|
||||
sheet_path = Path.cwd() / "layouts" / "A00 - UNTITLED.svg"
|
||||
@@ -845,10 +854,11 @@ class TestDrawingStyles(NewFile):
|
||||
ifc = tool.Ifc.get()
|
||||
drawing = ifc.by_type("IfcAnnotation")[0]
|
||||
bpy.ops.bim.expand_target_view(target_view="PLAN_VIEW")
|
||||
props = bpy.context.scene.DocProperties
|
||||
props = tool.Drawing.get_document_props()
|
||||
props.active_drawing_index = 2
|
||||
bpy.ops.bim.activate_drawing(drawing=drawing.id())
|
||||
self.drawing_styles = bpy.context.scene.DocProperties.drawing_styles
|
||||
props = tool.Drawing.get_document_props()
|
||||
self.drawing_styles = props.drawing_styles
|
||||
|
||||
def test_drawing_styles_not_loaded_if_underlay_is_inactive(self):
|
||||
self.setup_project_with_drawing()
|
||||
@@ -867,7 +877,8 @@ class TestDrawingStyles(NewFile):
|
||||
|
||||
class TestAddReferenceImage(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.BIMProjectProperties.template_file = "0"
|
||||
props = tool.Project.get_project_props()
|
||||
props.template_file = "0"
|
||||
bpy.ops.bim.create_project()
|
||||
ifc_path = Path("test/files/temp/test.ifc").absolute()
|
||||
bpy.ops.bim.save_project(filepath=str(ifc_path), should_save_as=True)
|
||||
|
||||
@@ -171,14 +171,14 @@ class TestGetCartesianPointCoordinateOffset(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
obj.BIMObjectProperties.blender_offset_type = "CARTESIAN_POINT"
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = True
|
||||
obj.BIMObjectProperties.cartesian_point_offset = "1,2,3"
|
||||
assert np.allclose(subject.get_cartesian_point_offset(obj), np.array((1.0, 2.0, 3.0)))
|
||||
|
||||
def test_get_null_if_not_a_cartesian_point_offset_type(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = True
|
||||
obj.BIMObjectProperties.cartesian_point_offset = "1,2,3"
|
||||
assert subject.get_cartesian_point_offset(obj) is None
|
||||
@@ -186,7 +186,7 @@ class TestGetCartesianPointCoordinateOffset(NewFile):
|
||||
def test_get_null_if_no_blender_offset(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
obj.BIMObjectProperties.blender_offset_type = "CARTESIAN_POINT"
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = False
|
||||
assert subject.get_cartesian_point_offset(obj) is None
|
||||
|
||||
@@ -237,14 +237,15 @@ class TestImportRepresentationParameters(NewFile):
|
||||
item = ifc.createIfcExtrudedAreaSolid(SweptArea=swept_area, Depth=2)
|
||||
representation = ifc.createIfcShapeRepresentation(Items=[item])
|
||||
data = bpy.data.meshes.new("Mesh")
|
||||
data.BIMMeshProperties.ifc_definition_id = representation.id()
|
||||
mprops = tool.Geometry.get_mesh_props(data)
|
||||
mprops.ifc_definition_id = representation.id()
|
||||
subject.import_representation_parameters(data)
|
||||
assert data.BIMMeshProperties.ifc_parameters[0].name == "IfcExtrudedAreaSolid/Depth"
|
||||
assert data.BIMMeshProperties.ifc_parameters[0].step_id == item.id()
|
||||
assert data.BIMMeshProperties.ifc_parameters[0].index == 3
|
||||
assert data.BIMMeshProperties.ifc_parameters[1].name == "IfcCircleProfileDef/Radius"
|
||||
assert data.BIMMeshProperties.ifc_parameters[1].step_id == swept_area.id()
|
||||
assert data.BIMMeshProperties.ifc_parameters[1].index == 3
|
||||
assert mprops.ifc_parameters[0].name == "IfcExtrudedAreaSolid/Depth"
|
||||
assert mprops.ifc_parameters[0].step_id == item.id()
|
||||
assert mprops.ifc_parameters[0].index == 3
|
||||
assert mprops.ifc_parameters[1].name == "IfcCircleProfileDef/Radius"
|
||||
assert mprops.ifc_parameters[1].step_id == swept_area.id()
|
||||
assert mprops.ifc_parameters[1].index == 3
|
||||
|
||||
|
||||
class TestIsBodyRepresentation(NewFile):
|
||||
@@ -293,7 +294,7 @@ class TestLink(NewFile):
|
||||
element = ifc.createIfcShapeRepresentation()
|
||||
obj = bpy.data.meshes.new("Mesh")
|
||||
subject.link(element, obj)
|
||||
assert obj.BIMMeshProperties.ifc_definition_id == element.id()
|
||||
assert tool.Geometry.get_mesh_props(obj).ifc_definition_id == element.id()
|
||||
|
||||
|
||||
class TestRecordObjectMaterials(NewFile):
|
||||
@@ -306,7 +307,7 @@ class TestRecordObjectMaterials(NewFile):
|
||||
material.BIMStyleProperties.ifc_definition_id = style.id()
|
||||
obj.data.materials.append(material)
|
||||
subject.record_object_materials(obj)
|
||||
assert obj.data.BIMMeshProperties.material_checksum == str([style.id()])
|
||||
assert tool.Geometry.get_mesh_props(obj).material_checksum == str([style.id()])
|
||||
|
||||
|
||||
class TestRecordObjectPosition(NewFile):
|
||||
|
||||
@@ -39,7 +39,7 @@ class TestImportProjectedCRS(NewFile):
|
||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
|
||||
subject.import_projected_crs()
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
assert len(props.projected_crs) == 0
|
||||
|
||||
def test_importing_projected_crs(self):
|
||||
@@ -58,7 +58,7 @@ class TestImportProjectedCRS(NewFile):
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT")
|
||||
projected_crs.MapUnit = unit
|
||||
subject.import_projected_crs()
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
assert props.projected_crs.get("Name").string_value == "Name"
|
||||
assert props.projected_crs.get("Description").string_value == "Description"
|
||||
assert props.projected_crs.get("GeodeticDatum").string_value == "GeodeticDatum"
|
||||
@@ -71,7 +71,7 @@ class TestImportProjectedCRS(NewFile):
|
||||
ifc = ifcopenshell.file(schema="IFC2X3")
|
||||
tool.Ifc.set(ifc)
|
||||
subject.import_projected_crs()
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
assert len(props.projected_crs) == 0
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class TestImportCoordinateOperation(NewFile):
|
||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
|
||||
subject.import_coordinate_operation()
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
assert len(props.coordinate_operation) == 0
|
||||
|
||||
def test_importing_coordinate_operation(self):
|
||||
@@ -99,7 +99,7 @@ class TestImportCoordinateOperation(NewFile):
|
||||
map_conversion.XAxisOrdinate = 5
|
||||
map_conversion.Scale = 6
|
||||
subject.import_coordinate_operation()
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
assert props.coordinate_operation.get("Eastings").string_value == "1.0"
|
||||
assert props.coordinate_operation.get("Northings").string_value == "2.0"
|
||||
assert props.coordinate_operation.get("OrthogonalHeight").string_value == "3.0"
|
||||
@@ -112,7 +112,7 @@ class TestImportCoordinateOperation(NewFile):
|
||||
ifc = ifcopenshell.file(schema="IFC2X3")
|
||||
tool.Ifc.set(ifc)
|
||||
subject.import_coordinate_operation()
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
assert len(props.coordinate_operation) == 0
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class TestImportTrueNorth(NewFile):
|
||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
|
||||
subject.import_true_north()
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
assert props.true_north_abscissa == "0"
|
||||
assert props.true_north_ordinate == "1"
|
||||
assert props.true_north_angle == "0"
|
||||
@@ -135,7 +135,7 @@ class TestImportTrueNorth(NewFile):
|
||||
context = ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
|
||||
context.TrueNorth = ifc.createIfcDirection((1.0, 2.0, 0.0))
|
||||
subject.import_true_north()
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
assert props.true_north_abscissa == "1.0"
|
||||
assert props.true_north_ordinate == "2.0"
|
||||
assert props.true_north_angle == "-26.5650512"
|
||||
@@ -176,35 +176,39 @@ class TestGetTrueNorthAttributes(NewFile):
|
||||
|
||||
class TestEnableEditing(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.BIMGeoreferenceProperties.is_editing = False
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.is_editing = False
|
||||
subject.enable_editing()
|
||||
assert bpy.context.scene.BIMGeoreferenceProperties.is_editing is True
|
||||
assert props.is_editing is True
|
||||
|
||||
|
||||
class TestDisableEditing(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.BIMGeoreferenceProperties.is_editing = True
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.is_editing = True
|
||||
subject.disable_editing()
|
||||
assert bpy.context.scene.BIMGeoreferenceProperties.is_editing is False
|
||||
assert props.is_editing is False
|
||||
|
||||
|
||||
class TestSetCoordinates(NewFile):
|
||||
def test_run(self):
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
subject.set_coordinates("local", [1.0, 2.0, 3.0])
|
||||
assert bpy.context.scene.BIMGeoreferenceProperties.local_coordinates == "1.0,2.0,3.0"
|
||||
assert props.local_coordinates == "1.0,2.0,3.0"
|
||||
subject.set_coordinates("blender", [4.0, 5.0, 6.0])
|
||||
assert bpy.context.scene.BIMGeoreferenceProperties.blender_coordinates == "4.0,5.0,6.0"
|
||||
assert props.blender_coordinates == "4.0,5.0,6.0"
|
||||
subject.set_coordinates("map", [7.0, 8.0, 9.0])
|
||||
assert bpy.context.scene.BIMGeoreferenceProperties.map_coordinates == "7.0,8.0,9.0"
|
||||
assert props.map_coordinates == "7.0,8.0,9.0"
|
||||
|
||||
|
||||
class TestGetCoordinates(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.BIMGeoreferenceProperties.local_coordinates = "1.0,2.0,3.0"
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.local_coordinates = "1.0,2.0,3.0"
|
||||
assert subject.get_coordinates("local") == [1.0, 2.0, 3.0]
|
||||
bpy.context.scene.BIMGeoreferenceProperties.blender_coordinates = "4.0,5.0,6.0"
|
||||
props.blender_coordinates = "4.0,5.0,6.0"
|
||||
assert subject.get_coordinates("blender") == [4.0, 5.0, 6.0]
|
||||
bpy.context.scene.BIMGeoreferenceProperties.map_coordinates = "7.0,8.0,9.0"
|
||||
props.map_coordinates = "7.0,8.0,9.0"
|
||||
assert subject.get_coordinates("map") == [7.0, 8.0, 9.0]
|
||||
|
||||
|
||||
@@ -231,7 +235,7 @@ class TestXyz2Enh(NewFile):
|
||||
ifc = ifcopenshell.file()
|
||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
tool.Ifc.set(ifc)
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = True
|
||||
props.blender_offset_x = "1.0"
|
||||
assert subject.xyz2enh([0.0, 0.0, 0.0]) == (1.0, 0.0, 0.0)
|
||||
@@ -247,7 +251,7 @@ class TestXyz2Enh(NewFile):
|
||||
assert subject.xyz2enh([0.0, 0.0, 0.0]) == (1.0, 0.0, 0.0)
|
||||
|
||||
def test_applying_both_blender_offset_and_map_conversion(self):
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = True
|
||||
props.blender_offset_x = "1.0"
|
||||
ifc = ifcopenshell.file()
|
||||
@@ -271,7 +275,7 @@ class TestEnh2Xyz(NewFile):
|
||||
ifc = ifcopenshell.file()
|
||||
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
|
||||
tool.Ifc.set(ifc)
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = True
|
||||
props.blender_offset_x = "1.0"
|
||||
assert subject.enh2xyz([0.0, 0.0, 0.0]) == (-1.0, 0.0, 0.0)
|
||||
@@ -287,7 +291,7 @@ class TestEnh2Xyz(NewFile):
|
||||
assert subject.enh2xyz([0.0, 0.0, 0.0]) == (-1.0, 0.0, 0.0)
|
||||
|
||||
def test_applying_both_blender_offset_and_map_conversion(self):
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = True
|
||||
props.blender_offset_x = "1.0"
|
||||
ifc = ifcopenshell.file()
|
||||
|
||||
@@ -189,7 +189,7 @@ class TestLink(test.bim.bootstrap.NewFile):
|
||||
element = ifc.create_entity("IfcShapeRepresentation")
|
||||
obj = bpy.data.meshes.new("Material")
|
||||
subject.link(element, obj)
|
||||
assert obj.BIMMeshProperties.ifc_definition_id == element.id()
|
||||
assert tool.Geometry.get_mesh_props(obj).ifc_definition_id == element.id()
|
||||
|
||||
|
||||
class TestUnlink(test.bim.bootstrap.NewFile):
|
||||
|
||||
@@ -520,7 +520,8 @@ class TestLoadingIndexedMap(NewFile):
|
||||
class TestSetupActiveBsddClassification(NewFile):
|
||||
def run_test(self, schema: ifcopenshell.util.schema.IFC_SCHEMA) -> None:
|
||||
schema_ = "IFC4X3_ADD2" if schema == "IFC4X3" else schema
|
||||
bpy.context.scene.BIMProjectProperties.export_schema = schema_
|
||||
props = tool.Project.get_project_props()
|
||||
props.export_schema = schema_
|
||||
bpy.ops.bim.create_project()
|
||||
ifc_file = tool.Ifc.get()
|
||||
name = "CCI Construction"
|
||||
|
||||
@@ -378,7 +378,7 @@ class TestGenerateStair2DProfile(NewFile):
|
||||
|
||||
class TestUsingArrays(NewFile):
|
||||
def setup_array(self, add_second_layer=False, sync_children=False):
|
||||
bpy.context.scene.BIMProjectProperties.template_file = "0"
|
||||
tool.Project.get_project_props().template_file = "0"
|
||||
bpy.ops.bim.create_project()
|
||||
|
||||
bpy.ops.mesh.primitive_cube_add()
|
||||
@@ -467,7 +467,8 @@ class TestApplyIfcMaterialChanges(NewFile):
|
||||
return mesh
|
||||
|
||||
def setup_test(self, and_elements: bool = True) -> None:
|
||||
bpy.context.scene.BIMProjectProperties.template_file = "0"
|
||||
props = tool.Project.get_project_props()
|
||||
props.template_file = "0"
|
||||
bpy.context.scene.unit_settings.length_unit = "MILLIMETERS"
|
||||
bpy.ops.bim.create_project()
|
||||
ifc_file = tool.Ifc.get()
|
||||
|
||||
@@ -244,25 +244,25 @@ class TestLoadProject(NewFile):
|
||||
|
||||
class TestLoadLinkedModels(NewFile):
|
||||
def test_load_linked_models_no_document(self):
|
||||
links = bpy.context.scene.BIMProjectProperties.links
|
||||
props = tool.Project.get_project_props()
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
subject.load_linked_models_from_ifc()
|
||||
assert len(links) == 0
|
||||
assert len(props.links) == 0
|
||||
|
||||
def test_load_linked_models_document_no_references(self):
|
||||
ifc = ifcopenshell.file()
|
||||
links = bpy.context.scene.BIMProjectProperties.links
|
||||
props = tool.Project.get_project_props()
|
||||
ifcopenshell.api.root.create_entity(ifc, "IfcProject")
|
||||
document = ifcopenshell.api.document.add_information(ifc)
|
||||
document.Name = "BBIM_Linked_Models"
|
||||
tool.Ifc.set(ifc)
|
||||
subject.load_linked_models_from_ifc()
|
||||
assert len(links) == 0
|
||||
assert len(props.links) == 0
|
||||
|
||||
def test_load_linked_models_document_with_references(self):
|
||||
ifc = ifcopenshell.file()
|
||||
links = bpy.context.scene.BIMProjectProperties.links
|
||||
props = tool.Project.get_project_props()
|
||||
ifcopenshell.api.root.create_entity(ifc, "IfcProject")
|
||||
document = ifcopenshell.api.document.add_information(ifc)
|
||||
document.Name = "BBIM_Linked_Models"
|
||||
@@ -271,8 +271,8 @@ class TestLoadLinkedModels(NewFile):
|
||||
reference.Location = linked_model_path
|
||||
tool.Ifc.set(ifc)
|
||||
subject.load_linked_models_from_ifc()
|
||||
assert len(links) == 1
|
||||
assert links[0].name == linked_model_path
|
||||
assert len(props.links) == 1
|
||||
assert props.links[0].name == linked_model_path
|
||||
|
||||
|
||||
class TestSaveLinkedModelsToIfc(NewFile):
|
||||
@@ -286,8 +286,8 @@ class TestSaveLinkedModelsToIfc(NewFile):
|
||||
def test_save_linked_models_to_ifc_paths_to_add(self):
|
||||
ifc = ifcopenshell.file()
|
||||
ifcopenshell.api.root.create_entity(ifc, "IfcProject")
|
||||
links = bpy.context.scene.BIMProjectProperties.links
|
||||
link = links.add()
|
||||
props = tool.Project.get_project_props()
|
||||
link = props.links.add()
|
||||
linked_model_path = "test.ifc"
|
||||
link.name = linked_model_path
|
||||
tool.Ifc.set(ifc)
|
||||
@@ -299,7 +299,7 @@ class TestSaveLinkedModelsToIfc(NewFile):
|
||||
|
||||
def test_save_linked_models_to_ifc_already_created_references(self):
|
||||
ifc = ifcopenshell.file()
|
||||
links = bpy.context.scene.BIMProjectProperties.links
|
||||
links = tool.Project.get_project_props().links
|
||||
ifcopenshell.api.root.create_entity(ifc, "IfcProject")
|
||||
|
||||
document = ifcopenshell.api.document.add_information(ifc)
|
||||
@@ -326,7 +326,7 @@ class TestSaveLinkedModelsToIfc(NewFile):
|
||||
|
||||
def test_save_linked_models_to_ifc_references_to_remove(self):
|
||||
ifc = ifcopenshell.file()
|
||||
links = bpy.context.scene.BIMProjectProperties.links
|
||||
links = tool.Project.get_project_props().links
|
||||
ifcopenshell.api.root.create_entity(ifc, "IfcProject")
|
||||
|
||||
document = ifcopenshell.api.document.add_information(ifc)
|
||||
|
||||
@@ -120,8 +120,8 @@ class TestGetObjectRepresentation(NewFile):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
representation = ifc.createIfcShapeRepresentation()
|
||||
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
|
||||
obj.data.BIMMeshProperties.ifc_definition_id = representation.id()
|
||||
obj = bpy.data.objects.new("Object", (mesh := bpy.data.meshes.new("Mesh")))
|
||||
tool.Geometry.get_mesh_props(mesh).ifc_definition_id = representation.id()
|
||||
assert subject.get_object_representation(obj) == representation
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ class TestSetObjectName(NewFile):
|
||||
|
||||
class TestReassignClass(NewFile):
|
||||
def test_reassigning_multiple_occurrences_of_the_same_type(self):
|
||||
bpy.context.scene.BIMProjectProperties.template_file = "IFC4 Demo Template.ifc"
|
||||
tool.Project.get_project_props().template_file = "IFC4 Demo Template.ifc"
|
||||
bpy.ops.bim.create_project()
|
||||
ifc_file = tool.Ifc.get()
|
||||
context = bpy.context
|
||||
|
||||
@@ -20,6 +20,7 @@ import bpy
|
||||
import numpy as np
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.geolocation
|
||||
|
||||
import test.bim.bootstrap
|
||||
import bonsai.core.tool
|
||||
@@ -34,7 +35,7 @@ class TestImplementsTool(test.bim.bootstrap.NewFile):
|
||||
|
||||
class TestGetGlobalMatrix(test.bim.bootstrap.NewFile):
|
||||
def test_getting_an_absolute_matrix_if_no_blender_offset(self):
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = False
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
assert (subject.get_absolute_matrix(obj) == np.array(obj.matrix_world)).all()
|
||||
@@ -45,7 +46,7 @@ class TestGetGlobalMatrix(test.bim.bootstrap.NewFile):
|
||||
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", prefix="MILLI")
|
||||
ifcopenshell.api.run("unit.assign_unit", ifc, units=[unit])
|
||||
tool.Ifc.set(ifc)
|
||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = True
|
||||
props.blender_offset_x = "1000"
|
||||
props.blender_offset_y = "2000"
|
||||
|
||||
Reference in New Issue
Block a user