Fix failing georeference and spatial core/tool/bim tests and clean dead code

This commit is contained in:
Dion Moult
2024-08-03 23:08:35 +10:00
parent 7af5db7cd4
commit 2196c16097
10 changed files with 122 additions and 280 deletions
@@ -21,7 +21,6 @@ from . import ui, prop, operator
classes = (
operator.AddGeoreferencing,
operator.ConvertAngleToCoordinates,
operator.DisableEditingGeoreferencing,
operator.DisableEditingTrueNorth,
operator.DisableEditingWCS,
@@ -87,23 +87,6 @@ class GetCursorLocation(bpy.types.Operator, tool.Ifc.Operator):
core.get_cursor_location(tool.Georeference)
class ConvertAngleToCoordinates(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.convert_angle_to_coord"
bl_label = "Convert Angle To Y Axis"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Convert angle to Y axis"
type: bpy.props.StringProperty()
@classmethod
def poll(cls, context):
file = tool.Ifc.get()
props = context.scene.BIMGeoreferenceProperties
return file and (props.angle_degree_input_x or props.angle_degree_input_y)
def _execute(self, context):
core.convert_angle_to_coord(tool.Georeference, type=self.type)
class ImportPlot(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.import_plot"
bl_label = "Import Plot"
@@ -138,7 +121,7 @@ class EditWCS(bpy.types.Operator, tool.Ifc.Operator):
bl_description = "Edit the WCS"
def _execute(self, context):
core.edit_wcs(tool.Ifc, tool.Georeference)
core.edit_wcs(tool.Georeference)
class DisableEditingWCS(bpy.types.Operator, tool.Ifc.Operator):
@@ -38,8 +38,8 @@ def disable_editing_georeferencing(georeference):
def edit_georeferencing(ifc, georeference):
ifc.run(
"georeference.edit_georeferencing",
projected_crs=georeference.get_projected_crs_attributes(),
coordinate_operation=georeference.get_coordinate_operation_attributes(),
projected_crs=georeference.export_projected_crs(),
coordinate_operation=georeference.export_coordinate_operation(),
)
georeference.disable_editing()
georeference.set_model_origin()
@@ -47,17 +47,12 @@ def edit_georeferencing(ifc, georeference):
def get_cursor_location(georeference):
location = georeference.get_cursor_location()
if georeference.has_blender_offset:
if georeference.has_blender_offset():
georeference.set_coordinates("blender", location)
else:
georeference.set_coordinates("local", location)
def convert_angle_to_coord(georeference, type):
vector_coordinates = georeference.angle2coords(georeference.get_angle(type), type)
georeference.set_vector_coordinates(vector_coordinates, type)
def import_plot(georeference, filepath):
georeference.import_plot(filepath)
@@ -71,7 +66,7 @@ def disable_editing_wcs(georeference):
georeference.disable_editing_wcs()
def edit_wcs(ifc, georeference):
def edit_wcs(georeference):
wcs = georeference.export_wcs()
georeference.set_wcs(wcs)
georeference.disable_editing_wcs()
+8 -11
View File
@@ -430,31 +430,27 @@ class Geometry:
@interface
class Georeference:
def angle2coords(cls, angle, type): pass
def add_georeferencing(cls): pass
def disable_editing(cls): pass
def disable_editing_true_north(cls): pass
def disable_editing_wcs(cls): pass
def enable_editing(cls): pass
def enable_editing_true_north(cls): pass
def enable_editing_wcs(cls): pass
def enh2xyz(cls, coordinates): pass
def export_coordinate_operation(cls): pass
def export_projected_crs(cls): pass
def export_wcs(cls): pass
def get_angle(cls, type): pass
def get_coordinate_operation_attributes(cls): pass
def get_coordinates(cls, io): pass
def get_cursor_location(cls): pass
def get_projected_crs_attributes(cls): pass
def get_true_north_attributes(cls): pass
def import_map_conversion(cls): pass
def has_blender_offset(cls): pass
def import_coordinate_operation(cls): pass
def import_projected_crs(cls): pass
def import_true_north(cls): pass
def import_wcs(cls): pass
def set_blender_grid_north(cls): pass
def set_blender_true_north(cls): pass
def set_coordinates(cls, io, coordinates): pass
def set_cursor_location(cls, coordinates): pass
def set_ifc_grid_north(cls): pass
def set_ifc_true_north(cls): pass
def set_model_origin(cls): pass
def set_vector_coordinates(cls, vector_coordinates, type): pass
def set_wcs(cls, matrix): pass
def xyz2enh(cls, coordinates): pass
@@ -884,6 +880,7 @@ class Spatial:
def select_products(cls, products, unhide=False): pass
def set_active_object(cls, obj): pass
def set_relative_object_matrix(cls, target_obj, relative_to_obj, matrix): pass
def set_target_container_as_default(cls): pass
def show_scene_objects(cls): pass
# HERE STARTS SPATIAL TOOL
+2 -33
View File
@@ -27,7 +27,6 @@ import ifcopenshell.util.unit
import blenderbim.core.tool
import blenderbim.tool as tool
import blenderbim.bim.helper
from math import radians, cos, sin
class Georeference(blenderbim.core.tool.Georeference):
@@ -151,7 +150,7 @@ class Georeference(blenderbim.core.tool.Georeference):
return
@classmethod
def get_projected_crs_attributes(cls):
def export_projected_crs(cls):
def callback(attributes, prop):
if not prop.is_null and prop.name == "MapUnit":
attributes[prop.name] = tool.Ifc.get().by_id(int(prop.enum_value))
@@ -161,7 +160,7 @@ class Georeference(blenderbim.core.tool.Georeference):
return blenderbim.bim.helper.export_attributes(props.projected_crs, callback=callback)
@classmethod
def get_coordinate_operation_attributes(cls):
def export_coordinate_operation(cls):
measure_type = None
def callback(attributes, prop):
@@ -238,12 +237,6 @@ class Georeference(blenderbim.core.tool.Georeference):
scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
return [o / scale for o in bpy.context.scene.cursor.location]
@classmethod
def set_cursor_location(cls):
coordinates = cls.get_coordinates("local")
scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
bpy.context.scene.cursor.location = [co * scale for co in coordinates]
@classmethod
def xyz2enh(cls, coordinates, should_return_in_map_units=True):
props = bpy.context.scene.BIMGeoreferenceProperties
@@ -279,30 +272,6 @@ class Georeference(blenderbim.core.tool.Georeference):
)
return coordinates
@classmethod
def angle2coords(cls, angle, type):
if type == "rel_x":
return ifcopenshell.util.geolocation.angle2xaxis(angle)
elif type == "rel_y":
return ifcopenshell.util.geolocation.angle2yaxis(angle)
@classmethod
def get_angle(cls, type):
if type == "rel_x":
return bpy.context.scene.BIMGeoreferenceProperties.angle_degree_input_x
elif type == "rel_y":
return bpy.context.scene.BIMGeoreferenceProperties.angle_degree_input_y
@classmethod
def set_vector_coordinates(cls, vector_coordinates, type):
x, y = vector_coordinates
if type == "rel_x":
bpy.context.scene.BIMGeoreferenceProperties.x_axis_abscissa_output = str(x)
bpy.context.scene.BIMGeoreferenceProperties.x_axis_ordinate_output = str(y)
elif type == "rel_y":
bpy.context.scene.BIMGeoreferenceProperties.y_axis_abscissa_output = str(x)
bpy.context.scene.BIMGeoreferenceProperties.y_axis_ordinate_output = str(y)
@classmethod
def import_plot(cls, filepath):
import bmesh
@@ -32,45 +32,17 @@ Scenario: Disable editing georeferencing
When I press "bim.disable_editing_georeferencing"
Then nothing happens
Scenario: Set IFC grid north
Given an empty IFC project
And I press "bim.add_georeferencing"
And I press "bim.enable_editing_georeferencing"
When I press "bim.set_ifc_grid_north"
Then nothing happens
Scenario: Set Blender grid north
Given an empty IFC project
And I press "bim.add_georeferencing"
And I press "bim.enable_editing_georeferencing"
And I press "bim.set_ifc_grid_north"
When I press "bim.set_blender_grid_north"
Then nothing happens
Scenario: Get cursor location
Given an empty IFC project
When I press "bim.get_cursor_location"
Then nothing happens
Scenario: Set IFC true north
Given an empty IFC project
When I press "bim.set_ifc_true_north"
Then nothing happens
Scenario: Set Blender true north
Given an empty IFC project
And I press "bim.set_ifc_true_north"
When I press "bim.set_blender_true_north"
Then nothing happens
Scenario: Convert local to global
Scenario: Convert local to map
Given an empty IFC project
When I set "scene.BIMGeoreferenceProperties.local_coordinates" to "0,0,0"
And I press "bim.convert_local_to_global"
Then "scene.BIMGeoreferenceProperties.map_coordinates" is "0.0,0.0,0.0"
Scenario: Convert global to local
Scenario: Convert map to local
Given an empty IFC project
When I set "scene.BIMGeoreferenceProperties.map_coordinates" to "0,0,0"
And I press "bim.convert_global_to_local"
Then "scene.BIMGeoreferenceProperties.local_coordinates" is "0.0,0.0,0.0"
@@ -25,9 +25,9 @@ Scenario: Assign container
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And the object "IfcWall/Cube" is selected
And I press "bim.enable_editing_container"
And the variable "site" is "tool.Ifc.get().by_type('IfcSite')[0].id()"
And I press "bim.set_default_container(container={site})"
And I press "bim.enable_editing_container"
When I press "bim.assign_container()"
Then the object "IfcWall/Cube" is in the collection "IfcSite/My Site"
+63 -52
View File
@@ -21,16 +21,15 @@ from test.core.bootstrap import ifc, georeference
class TestAddGeoreferencing:
def test_run(self, ifc):
ifc.run("georeference.add_georeferencing").should_be_called()
subject.add_georeferencing(ifc)
def test_run(self, georeference):
georeference.add_georeferencing().should_be_called()
subject.add_georeferencing(georeference)
class TestEnableGeoreferencing:
class TestEnableEditingGeoreferencing:
def test_run(self, georeference):
georeference.import_projected_crs().should_be_called()
georeference.import_map_conversion().should_be_called()
georeference.import_true_north().should_be_called()
georeference.import_coordinate_operation().should_be_called()
georeference.enable_editing().should_be_called()
subject.enable_editing_georeferencing(georeference)
@@ -41,72 +40,84 @@ class TestRemoveGeoreferencing:
subject.remove_georeferencing(ifc)
class TestDisableEditingGeoreferencing:
def test_run(self, georeference):
georeference.disable_editing().should_be_called()
subject.disable_editing_georeferencing(georeference)
class TestEditGeoreferencing:
def test_run(self, ifc, georeference):
georeference.get_projected_crs_attributes().should_be_called().will_return("projected_crs_attributes")
georeference.get_map_conversion_attributes().should_be_called().will_return("map_conversion_attributes")
georeference.get_true_north_attributes().should_be_called().will_return("true_north_attributes")
georeference.export_projected_crs().should_be_called().will_return("projected_crs_attributes")
georeference.export_coordinate_operation().should_be_called().will_return("coordinate_operation_attributes")
ifc.run(
"georeference.edit_georeferencing",
projected_crs="projected_crs_attributes",
map_conversion="map_conversion_attributes",
true_north="true_north_attributes",
coordinate_operation="coordinate_operation_attributes",
).should_be_called()
georeference.disable_editing().should_be_called()
georeference.set_model_origin().should_be_called()
subject.edit_georeferencing(ifc, georeference)
class TestSetIfcGridNorth:
def test_run(self, georeference):
georeference.set_ifc_grid_north().should_be_called()
subject.set_ifc_grid_north(georeference)
class TestSetBlenderGridNorth:
def test_run(self, georeference):
georeference.set_blender_grid_north().should_be_called()
subject.set_blender_grid_north(georeference)
class TestSetIfcTrueNorth:
def test_run(self, georeference):
georeference.set_ifc_true_north().should_be_called()
subject.set_ifc_true_north(georeference)
class TestSetBlenderTrueNorth:
def test_run(self, georeference):
georeference.set_blender_true_north().should_be_called()
subject.set_blender_true_north(georeference)
class TestGetCursorLocation:
def test_run(self, georeference):
georeference.get_cursor_location().should_be_called().will_return("coordinates")
georeference.set_coordinates("input", "coordinates").should_be_called()
georeference.has_blender_offset().should_be_called().will_return(False)
georeference.set_coordinates("local", "coordinates").should_be_called()
subject.get_cursor_location(georeference)
def test_with_a_blender_offset(self, georeference):
georeference.get_cursor_location().should_be_called().will_return("coordinates")
georeference.has_blender_offset().should_be_called().will_return(True)
georeference.set_coordinates("blender", "coordinates").should_be_called()
subject.get_cursor_location(georeference)
class TestSetCursorLocation:
class TestEnableEditingWCS:
def test_run(self, georeference):
georeference.get_coordinates("output").should_be_called().will_return("coordinates")
georeference.set_cursor_location("coordinates").should_be_called()
subject.set_cursor_location(georeference)
georeference.import_wcs().should_be_called()
georeference.enable_editing_wcs().should_be_called()
subject.enable_editing_wcs(georeference)
class TestConvertLocalToGlobal:
class TestDisableEditingWCS:
def test_run(self, georeference):
georeference.get_coordinates("input").should_be_called().will_return("coordinates")
georeference.xyz2enh("coordinates").should_be_called().will_return("enh")
georeference.set_coordinates("output", "enh").should_be_called()
georeference.set_cursor_location("enh").should_be_called()
subject.convert_local_to_global(georeference)
georeference.disable_editing_wcs().should_be_called()
subject.disable_editing_wcs(georeference)
class TestConvertGlobalToLocal:
class TestEditWCS:
def test_run(self, georeference):
georeference.get_coordinates("input").should_be_called().will_return("coordinates")
georeference.enh2xyz("coordinates").should_be_called().will_return("xyz")
georeference.set_coordinates("output", "xyz").should_be_called()
georeference.set_cursor_location("xyz").should_be_called()
subject.convert_global_to_local(georeference)
georeference.export_wcs().should_be_called().will_return("wcs")
georeference.set_wcs("wcs").should_be_called()
georeference.disable_editing_wcs().should_be_called()
georeference.set_model_origin().should_be_called()
subject.edit_wcs(georeference)
class TestEnableEditingTrueNorth:
def test_run(self, georeference):
georeference.import_true_north().should_be_called()
georeference.enable_editing_true_north().should_be_called()
subject.enable_editing_true_north(georeference)
class TestDisableEditingTrueNorth:
def test_run(self, georeference):
georeference.disable_editing_true_north().should_be_called()
subject.disable_editing_true_north(georeference)
class TestEditTrueNorth:
def test_run(self, ifc, georeference):
georeference.get_true_north_attributes().should_be_called().will_return("true_north")
ifc.run("georeference.edit_true_north", true_north="true_north").should_be_called()
georeference.disable_editing_true_north().should_be_called()
subject.edit_true_north(ifc, georeference)
class TestRemoveTrueNorth:
def test_run(self, ifc):
ifc.run("georeference.edit_true_north", true_north=None).should_be_called()
subject.remove_true_north(ifc)
+1
View File
@@ -52,6 +52,7 @@ class TestAssignContainer:
class TestEnableEditingContainer:
def test_run(self, spatial):
spatial.set_target_container_as_default().should_be_called()
spatial.enable_editing("obj").should_be_called()
subject.enable_editing_container(spatial, obj="obj")
+40 -125
View File
@@ -75,17 +75,17 @@ class TestImportProjectedCRS(NewFile):
assert len(props.projected_crs) == 0
class TestImportMapConversion(NewFile):
class TestImportCoordinateOperation(NewFile):
def test_importing_nothing_with_no_georeferencing(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
subject.import_map_conversion()
subject.import_coordinate_operation()
props = bpy.context.scene.BIMGeoreferenceProperties
assert len(props.map_conversion) == 0
assert len(props.coordinate_operation) == 0
def test_importing_map_conversion(self):
def test_importing_coordinate_operation(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
@@ -98,21 +98,22 @@ class TestImportMapConversion(NewFile):
map_conversion.XAxisAbscissa = 4
map_conversion.XAxisOrdinate = 5
map_conversion.Scale = 6
subject.import_map_conversion()
subject.import_coordinate_operation()
props = bpy.context.scene.BIMGeoreferenceProperties
assert props.map_conversion.get("Eastings").string_value == "1.0"
assert props.map_conversion.get("Northings").string_value == "2.0"
assert props.map_conversion.get("OrthogonalHeight").string_value == "3.0"
assert props.map_conversion.get("XAxisAbscissa").string_value == "4.0"
assert props.map_conversion.get("XAxisOrdinate").string_value == "5.0"
assert props.map_conversion.get("Scale").string_value == "6.0"
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"
assert props.x_axis_abscissa == "4.0"
assert props.x_axis_ordinate == "5.0"
assert props.grid_north_angle == "-51.3401917"
assert props.coordinate_operation.get("Scale").string_value == "6.0"
def test_run_ifc2x3(self):
ifc = ifcopenshell.file(schema="IFC2X3")
tool.Ifc.set(ifc)
subject.import_map_conversion()
subject.import_coordinate_operation()
props = bpy.context.scene.BIMGeoreferenceProperties
assert len(props.map_conversion) == 0
assert len(props.coordinate_operation) == 0
class TestImportTrueNorth(NewFile):
@@ -120,10 +121,12 @@ class TestImportTrueNorth(NewFile):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
context = ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
subject.import_true_north()
props = bpy.context.scene.BIMGeoreferenceProperties
assert props.has_true_north is False
assert props.true_north_abscissa == "0"
assert props.true_north_ordinate == "1"
assert props.true_north_angle == "0"
def test_run(self):
ifc = ifcopenshell.file()
@@ -135,13 +138,13 @@ class TestImportTrueNorth(NewFile):
props = bpy.context.scene.BIMGeoreferenceProperties
assert props.true_north_abscissa == "1.0"
assert props.true_north_ordinate == "2.0"
assert props.has_true_north is True
assert props.true_north_angle == "-26.5650512"
class TestGetProjectedCRSAttributes(NewFile):
class TestExportProjectedCRS(NewFile):
def test_run(self):
TestImportProjectedCRS().test_importing_projected_crs()
assert subject.get_projected_crs_attributes() == {
assert subject.export_projected_crs() == {
"Name": "Name",
"Description": "Description",
"GeodeticDatum": "GeodeticDatum",
@@ -152,10 +155,10 @@ class TestGetProjectedCRSAttributes(NewFile):
}
class TestGetMapConversionAttributes(NewFile):
class TestExportCoordinateOperation(NewFile):
def test_run(self):
TestImportMapConversion().test_importing_map_conversion()
assert subject.get_map_conversion_attributes() == {
TestImportCoordinateOperation().test_importing_coordinate_operation()
assert subject.export_coordinate_operation() == {
"Eastings": 1.0,
"Northings": 2.0,
"OrthogonalHeight": 3.0,
@@ -187,18 +190,22 @@ class TestDisableEditing(NewFile):
class TestSetCoordinates(NewFile):
def test_run(self):
subject.set_coordinates("input", [1.0, 2.0, 3.0])
assert bpy.context.scene.BIMGeoreferenceProperties.coordinate_input == "1.0,2.0,3.0"
subject.set_coordinates("output", [4.0, 5.0, 6.0])
assert bpy.context.scene.BIMGeoreferenceProperties.coordinate_output == "4.0,5.0,6.0"
subject.set_coordinates("local", [1.0, 2.0, 3.0])
assert bpy.context.scene.BIMGeoreferenceProperties.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"
subject.set_coordinates("map", [7.0, 8.0, 9.0])
assert bpy.context.scene.BIMGeoreferenceProperties.map_coordinates == "7.0,8.0,9.0"
class TestGetCoordinates(NewFile):
def test_run(self):
bpy.context.scene.BIMGeoreferenceProperties.coordinate_input = "1.0,2.0,3.0"
assert subject.get_coordinates("input") == [1.0, 2.0, 3.0]
bpy.context.scene.BIMGeoreferenceProperties.coordinate_output = "4.0,5.0,6.0"
assert subject.get_coordinates("output") == [4.0, 5.0, 6.0]
bpy.context.scene.BIMGeoreferenceProperties.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"
assert subject.get_coordinates("blender") == [4.0, 5.0, 6.0]
bpy.context.scene.BIMGeoreferenceProperties.map_coordinates = "7.0,8.0,9.0"
assert subject.get_coordinates("map") == [7.0, 8.0, 9.0]
class TestGetCursorLocation(NewFile):
@@ -213,41 +220,6 @@ class TestGetCursorLocation(NewFile):
assert subject.get_cursor_location() == [1000.0, 2000.0, 3000.0]
class TestSetCursorLocation(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
ifcopenshell.api.run("context.add_context", ifc, context_type="Model")
unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", prefix="MILLI")
ifcopenshell.api.run("unit.assign_unit", ifc, units=[unit])
subject.set_cursor_location([1000.0, 2000.0, 3000.0])
assert list(bpy.context.scene.cursor.location) == [1.0, 2.0, 3.0]
class TestSetIfcTrueNorth(NewFile):
def test_run(self):
subject.set_ifc_true_north()
assert round(float(bpy.context.scene.BIMGeoreferenceProperties.true_north_abscissa), 3) == 0.0
assert round(float(bpy.context.scene.BIMGeoreferenceProperties.true_north_ordinate), 3) == 1.0
bpy.context.scene.sun_pos_properties.north_offset = math.radians(45)
subject.set_ifc_true_north()
assert round(float(bpy.context.scene.BIMGeoreferenceProperties.true_north_abscissa), 3) == 0.707
assert round(float(bpy.context.scene.BIMGeoreferenceProperties.true_north_ordinate), 3) == 0.707
class TestSetBlenderTrueNorth(NewFile):
def test_run(self):
bpy.context.scene.BIMGeoreferenceProperties.true_north_abscissa = "0.0"
bpy.context.scene.BIMGeoreferenceProperties.true_north_ordinate = "1.0"
subject.set_blender_true_north()
assert bpy.context.scene.sun_pos_properties.north_offset == 0
bpy.context.scene.BIMGeoreferenceProperties.true_north_abscissa = "0.707"
bpy.context.scene.BIMGeoreferenceProperties.true_north_ordinate = "0.707"
subject.set_blender_true_north()
assert round(math.degrees(bpy.context.scene.sun_pos_properties.north_offset)) == 45
class TestXyz2Enh(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
@@ -261,7 +233,7 @@ class TestXyz2Enh(NewFile):
tool.Ifc.set(ifc)
props = bpy.context.scene.BIMGeoreferenceProperties
props.has_blender_offset = True
props.blender_eastings = "1.0"
props.blender_offset_x = "1.0"
assert subject.xyz2enh([0.0, 0.0, 0.0]) == (1.0, 0.0, 0.0)
def test_using_the_map_conversion(self):
@@ -277,7 +249,7 @@ class TestXyz2Enh(NewFile):
def test_applying_both_blender_offset_and_map_conversion(self):
props = bpy.context.scene.BIMGeoreferenceProperties
props.has_blender_offset = True
props.blender_eastings = "1.0"
props.blender_offset_x = "1.0"
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
@@ -301,7 +273,7 @@ class TestEnh2Xyz(NewFile):
tool.Ifc.set(ifc)
props = bpy.context.scene.BIMGeoreferenceProperties
props.has_blender_offset = True
props.blender_eastings = "1.0"
props.blender_offset_x = "1.0"
assert subject.enh2xyz([0.0, 0.0, 0.0]) == (-1.0, 0.0, 0.0)
def test_using_the_map_conversion(self):
@@ -317,7 +289,7 @@ class TestEnh2Xyz(NewFile):
def test_applying_both_blender_offset_and_map_conversion(self):
props = bpy.context.scene.BIMGeoreferenceProperties
props.has_blender_offset = True
props.blender_eastings = "1.0"
props.blender_offset_x = "1.0"
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcProject")
@@ -326,60 +298,3 @@ class TestEnh2Xyz(NewFile):
map_conversion = ifc.by_type("IfcMapConversion")[0]
map_conversion.Northings = 1.0
assert subject.enh2xyz([0.0, 0.0, 0.0]) == (-1.0, -1.0, 0.0)
class TestSetIfcGridNorth(NewFile):
def test_run(self):
props = bpy.context.scene.BIMGeoreferenceProperties
new = props.map_conversion.add()
new.name = "XAxisAbscissa"
new = props.map_conversion.add()
new.name = "XAxisOrdinate"
subject.set_ifc_grid_north()
assert round(float(props.map_conversion.get("XAxisAbscissa").string_value), 3) == 1.0
assert round(float(props.map_conversion.get("XAxisOrdinate").string_value), 3) == 0.0
bpy.context.scene.sun_pos_properties.north_offset = math.radians(-45)
subject.set_ifc_grid_north()
assert round(float(props.map_conversion.get("XAxisAbscissa").string_value), 3) == 0.707
assert round(float(props.map_conversion.get("XAxisOrdinate").string_value), 3) == -0.707
bpy.context.scene.sun_pos_properties.north_offset = math.radians(45)
subject.set_ifc_grid_north()
assert round(float(props.map_conversion.get("XAxisAbscissa").string_value), 3) == 0.707
assert round(float(props.map_conversion.get("XAxisOrdinate").string_value), 3) == 0.707
bpy.context.scene.sun_pos_properties.north_offset = math.radians(135)
subject.set_ifc_grid_north()
assert round(float(props.map_conversion.get("XAxisAbscissa").string_value), 3) == -0.707
assert round(float(props.map_conversion.get("XAxisOrdinate").string_value), 3) == 0.707
bpy.context.scene.sun_pos_properties.north_offset = math.radians(-135)
subject.set_ifc_grid_north()
assert round(float(props.map_conversion.get("XAxisAbscissa").string_value), 3) == -0.707
assert round(float(props.map_conversion.get("XAxisOrdinate").string_value), 3) == -0.707
class TestSetBlenderGridNorth(NewFile):
def test_run(self):
props = bpy.context.scene.BIMGeoreferenceProperties
new = props.map_conversion.add()
new.name = "XAxisAbscissa"
new = props.map_conversion.add()
new.name = "XAxisOrdinate"
props.map_conversion.get("XAxisAbscissa").string_value = "1.0"
props.map_conversion.get("XAxisOrdinate").string_value = "0.0"
subject.set_blender_grid_north()
assert bpy.context.scene.sun_pos_properties.north_offset == 0
props.map_conversion.get("XAxisAbscissa").string_value = "0.707"
props.map_conversion.get("XAxisOrdinate").string_value = "-0.707"
subject.set_blender_grid_north()
assert round(math.degrees(bpy.context.scene.sun_pos_properties.north_offset)) == -45
props.map_conversion.get("XAxisAbscissa").string_value = "0.707"
props.map_conversion.get("XAxisOrdinate").string_value = "0.707"
subject.set_blender_grid_north()
assert round(math.degrees(bpy.context.scene.sun_pos_properties.north_offset)) == 45
props.map_conversion.get("XAxisAbscissa").string_value = "-0.707"
props.map_conversion.get("XAxisOrdinate").string_value = "0.707"
subject.set_blender_grid_north()
assert round(math.degrees(bpy.context.scene.sun_pos_properties.north_offset)) == 135
props.map_conversion.get("XAxisAbscissa").string_value = "-0.707"
props.map_conversion.get("XAxisOrdinate").string_value = "-0.707"
subject.set_blender_grid_north()
assert round(math.degrees(bpy.context.scene.sun_pos_properties.north_offset)) == -135