We now can do cartesian point offsets regardless if there is a false session origin or not.

For example, it doesn't matter if you have a false origin set or not, there can still be scenarios where local verts are far away.
This commit is contained in:
Dion Moult
2024-06-19 23:33:16 +10:00
parent 88c8bcf119
commit 4738528e69
2 changed files with 26 additions and 30 deletions
+1 -6
View File
@@ -1369,13 +1369,8 @@ class IfcImporter:
mesh = bpy.data.meshes.new(tool.Loader.get_mesh_name(geometry)) mesh = bpy.data.meshes.new(tool.Loader.get_mesh_name(geometry))
props = bpy.context.scene.BIMGeoreferenceProperties if geometry.verts and tool.Loader.is_point_far_away(
if (
props.has_blender_offset
and geometry.verts
and tool.Loader.is_point_far_away(
(geometry.verts[0], geometry.verts[1], geometry.verts[2]), is_meters=True (geometry.verts[0], geometry.verts[1], geometry.verts[2]), is_meters=True
)
): ):
# Shift geometry close to the origin based off that first vert it found # Shift geometry close to the origin based off that first vert it found
verts_array = np.array(geometry.verts) verts_array = np.array(geometry.verts)
+6 -5
View File
@@ -666,8 +666,6 @@ class Loader(blenderbim.core.tool.Loader):
@classmethod @classmethod
def apply_blender_offset_to_matrix_world(cls, obj: bpy.types.Object, matrix: np.ndarray) -> Matrix: def apply_blender_offset_to_matrix_world(cls, obj: bpy.types.Object, matrix: np.ndarray) -> Matrix:
props = bpy.context.scene.BIMGeoreferenceProperties
if props.has_blender_offset:
if ( if (
not obj.data not obj.data
and tool.Cad.is_x(matrix[0][3], 0) and tool.Cad.is_x(matrix[0][3], 0)
@@ -680,7 +678,8 @@ class Loader(blenderbim.core.tool.Loader):
# everything else is at map coordinates. # everything else is at map coordinates.
obj.BIMObjectProperties.blender_offset_type = "NOT_APPLICABLE" obj.BIMObjectProperties.blender_offset_type = "NOT_APPLICABLE"
return Matrix(matrix.tolist()) return Matrix(matrix.tolist())
elif obj.data and obj.data.get("has_cartesian_point_offset", None):
if obj.data and obj.data.get("has_cartesian_point_offset", None):
obj.BIMObjectProperties.blender_offset_type = "CARTESIAN_POINT" obj.BIMObjectProperties.blender_offset_type = "CARTESIAN_POINT"
if cartesian_point_offset := obj.data.get("cartesian_point_offset", None): if cartesian_point_offset := obj.data.get("cartesian_point_offset", None):
obj.BIMObjectProperties.cartesian_point_offset = cartesian_point_offset obj.BIMObjectProperties.cartesian_point_offset = cartesian_point_offset
@@ -689,7 +688,10 @@ class Loader(blenderbim.core.tool.Loader):
matrix[0][3] = offset_xyz[0] matrix[0][3] = offset_xyz[0]
matrix[1][3] = offset_xyz[1] matrix[1][3] = offset_xyz[1]
matrix[2][3] = offset_xyz[2] matrix[2][3] = offset_xyz[2]
else:
props = bpy.context.scene.BIMGeoreferenceProperties
if props.has_blender_offset:
if obj.BIMObjectProperties.blender_offset_type == "NONE":
obj.BIMObjectProperties.blender_offset_type = "OBJECT_PLACEMENT" obj.BIMObjectProperties.blender_offset_type = "OBJECT_PLACEMENT"
matrix = ifcopenshell.util.geolocation.global2local( matrix = ifcopenshell.util.geolocation.global2local(
matrix, matrix,
@@ -699,7 +701,6 @@ class Loader(blenderbim.core.tool.Loader):
float(props.blender_x_axis_abscissa), float(props.blender_x_axis_abscissa),
float(props.blender_x_axis_ordinate), float(props.blender_x_axis_ordinate),
) )
return Matrix(matrix.tolist()) return Matrix(matrix.tolist())
@classmethod @classmethod