mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix #3757. Adding objects in offset models now correctly stores georeferenced coordinates.
This commit is contained in:
@@ -748,6 +748,7 @@ class IfcImporter:
|
|||||||
# positionally significant and is left alone. This handles
|
# positionally significant and is left alone. This handles
|
||||||
# scenarios where often spatial elements are left at 0,0,0 and
|
# scenarios where often spatial elements are left at 0,0,0 and
|
||||||
# everything else is at map coordinates.
|
# everything else is at map coordinates.
|
||||||
|
obj.BIMObjectProperties.blender_offset_type = "NOT_APPLICABLE"
|
||||||
return mathutils.Matrix(matrix.tolist())
|
return mathutils.Matrix(matrix.tolist())
|
||||||
elif obj.data and obj.data.get("has_cartesian_point_offset", None):
|
elif 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"
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ class BIMObjectProperties(PropertyGroup):
|
|||||||
collection: PointerProperty(type=bpy.types.Collection)
|
collection: PointerProperty(type=bpy.types.Collection)
|
||||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||||
blender_offset_type: EnumProperty(
|
blender_offset_type: EnumProperty(
|
||||||
items=[(o, o, "") for o in ["NONE", "OBJECT_PLACEMENT", "CARTESIAN_POINT"]],
|
items=[(o, o, "") for o in ["NONE", "OBJECT_PLACEMENT", "CARTESIAN_POINT", "NOT_APPLICABLE"]],
|
||||||
name="Blender Offset",
|
name="Blender Offset",
|
||||||
default="NONE",
|
default="NONE",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ def edit_object_placement(
|
|||||||
return
|
return
|
||||||
geometry.clear_cache(element)
|
geometry.clear_cache(element)
|
||||||
geometry.clear_scale(obj)
|
geometry.clear_scale(obj)
|
||||||
|
geometry.get_blender_offset_type(obj)
|
||||||
ifc.run("geometry.edit_object_placement", product=element, matrix=surveyor.get_absolute_matrix(obj))
|
ifc.run("geometry.edit_object_placement", product=element, matrix=surveyor.get_absolute_matrix(obj))
|
||||||
geometry.record_object_position(obj)
|
geometry.record_object_position(obj)
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import blenderbim.bim.import_ifc
|
|||||||
from math import radians, pi
|
from math import radians, pi
|
||||||
from mathutils import Vector, Matrix
|
from mathutils import Vector, Matrix
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from typing import Union, Iterable
|
from typing import Union, Iterable, Optional
|
||||||
|
|
||||||
|
|
||||||
class Geometry(blenderbim.core.tool.Geometry):
|
class Geometry(blenderbim.core.tool.Geometry):
|
||||||
@@ -982,3 +982,11 @@ class Geometry(blenderbim.core.tool.Geometry):
|
|||||||
def delete_opening_object_placement(cls, placement):
|
def delete_opening_object_placement(cls, placement):
|
||||||
model = tool.Ifc.get()
|
model = tool.Ifc.get()
|
||||||
ifcopenshell.util.element.remove_deep2(model, placement)
|
ifcopenshell.util.element.remove_deep2(model, placement)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_blender_offset_type(cls, obj: bpy.types.Object) -> Optional[str]:
|
||||||
|
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||||
|
if props.has_blender_offset:
|
||||||
|
if (result := obj.BIMObjectProperties.blender_offset_type) == "NONE":
|
||||||
|
result = obj.BIMObjectProperties.blender_offset_type = "OBJECT_PLACEMENT"
|
||||||
|
return result
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Surveyor(blenderbim.core.tool.Surveyor):
|
|||||||
def get_absolute_matrix(cls, obj):
|
def get_absolute_matrix(cls, obj):
|
||||||
matrix = np.array(obj.matrix_world)
|
matrix = np.array(obj.matrix_world)
|
||||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||||
if props.has_blender_offset and obj.BIMObjectProperties.blender_offset_type == "OBJECT_PLACEMENT":
|
if props.has_blender_offset and obj.BIMObjectProperties.blender_offset_type != "NOT_APPLICABLE":
|
||||||
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
matrix = np.array(
|
matrix = np.array(
|
||||||
ifcopenshell.util.geolocation.local2global(
|
ifcopenshell.util.geolocation.local2global(
|
||||||
|
|||||||
Reference in New Issue
Block a user