Skip to content

Commit cb95539

Browse files
committed
reuse get_cartesian_point_offset
1 parent 7b78ebc commit cb95539

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/bonsai/bonsai/tool/surveyor.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,21 @@
2323
import bonsai.core.tool
2424
import bonsai.tool as tool
2525
import numpy as np
26+
import numpy.typing as npt
2627
from mathutils import Matrix
2728

2829

2930
class Surveyor(bonsai.core.tool.Surveyor):
3031
@classmethod
31-
def get_absolute_matrix(cls, obj: bpy.types.Object) -> Matrix:
32+
def get_absolute_matrix(cls, obj: bpy.types.Object) -> npt.NDArray[np.float64]:
33+
M_TRANSLATION = (slice(0, 3), 3)
3234
matrix = np.array(obj.matrix_world)
3335
props = bpy.context.scene.BIMGeoreferenceProperties
3436
if props.has_blender_offset and obj.BIMObjectProperties.blender_offset_type != "NOT_APPLICABLE":
3537
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
36-
if (
37-
obj.BIMObjectProperties.blender_offset_type == "CARTESIAN_POINT"
38-
and obj.BIMObjectProperties.cartesian_point_offset
39-
):
40-
offset_x, offset_y, offset_z = map(float, obj.BIMObjectProperties.cartesian_point_offset.split(","))
41-
matrix[0][3] -= offset_x
42-
matrix[1][3] -= offset_y
43-
matrix[2][3] -= offset_z
38+
coordinate_offset = tool.Geometry.get_cartesian_point_offset(obj)
39+
if coordinate_offset is not None:
40+
matrix[M_TRANSLATION] -= coordinate_offset
4441
matrix = np.array(
4542
ifcopenshell.util.geolocation.local2global(
4643
matrix,

0 commit comments

Comments
 (0)