mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Fix #4802. Fix ability to edit CARTESIAN_POINT offset meshes in offset models.
This commit is contained in:
@@ -30,6 +30,14 @@ class Surveyor(blenderbim.core.tool.Surveyor):
|
|||||||
props = bpy.context.scene.BIMGeoreferenceProperties
|
props = bpy.context.scene.BIMGeoreferenceProperties
|
||||||
if props.has_blender_offset and obj.BIMObjectProperties.blender_offset_type != "NOT_APPLICABLE":
|
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())
|
||||||
|
if (
|
||||||
|
obj.BIMObjectProperties.blender_offset_type == "CARTESIAN_POINT"
|
||||||
|
and obj.BIMObjectProperties.cartesian_point_offset
|
||||||
|
):
|
||||||
|
offset_x, offset_y, offset_z = map(float, obj.BIMObjectProperties.cartesian_point_offset.split(","))
|
||||||
|
matrix[0][3] -= offset_x
|
||||||
|
matrix[1][3] -= offset_y
|
||||||
|
matrix[2][3] -= offset_z
|
||||||
matrix = np.array(
|
matrix = np.array(
|
||||||
ifcopenshell.util.geolocation.local2global(
|
ifcopenshell.util.geolocation.local2global(
|
||||||
matrix,
|
matrix,
|
||||||
|
|||||||
@@ -787,9 +787,7 @@ class Usecase:
|
|||||||
[uv + 1 for uv in polygon.loop_indices]
|
[uv + 1 for uv in polygon.loop_indices]
|
||||||
)
|
)
|
||||||
|
|
||||||
coordinates = self.file.createIfcCartesianPointList3D(
|
coordinates = self.create_cartesian_point_list_from_vertices(self.settings["geometry"].vertices)
|
||||||
[self.convert_si_to_unit(v.co) for v in self.settings["geometry"].vertices]
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.settings["should_generate_uvs"]:
|
if self.settings["should_generate_uvs"]:
|
||||||
# Blender supports multiple UV layers. We don't. Too bad.
|
# Blender supports multiple UV layers. We don't. Too bad.
|
||||||
@@ -824,9 +822,7 @@ class Usecase:
|
|||||||
ifc_raw_items[polygon.material_index % self.settings["total_items"]].append(
|
ifc_raw_items[polygon.material_index % self.settings["total_items"]].append(
|
||||||
self.file.createIfcIndexedPolygonalFace([v + 1 for v in polygon.vertices])
|
self.file.createIfcIndexedPolygonalFace([v + 1 for v in polygon.vertices])
|
||||||
)
|
)
|
||||||
coordinates = self.file.createIfcCartesianPointList3D(
|
coordinates = self.create_cartesian_point_list_from_vertices(self.settings["geometry"].vertices)
|
||||||
[self.convert_si_to_unit(v.co) for v in self.settings["geometry"].vertices]
|
|
||||||
)
|
|
||||||
items = [self.file.createIfcPolygonalFaceSet(coordinates, self.is_manifold, i) for i in ifc_raw_items if i]
|
items = [self.file.createIfcPolygonalFaceSet(coordinates, self.is_manifold, i) for i in ifc_raw_items if i]
|
||||||
return self.file.createIfcShapeRepresentation(
|
return self.file.createIfcShapeRepresentation(
|
||||||
self.settings["context"],
|
self.settings["context"],
|
||||||
@@ -848,7 +844,12 @@ class Usecase:
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
def create_cartesian_point(self, x, y, z=None):
|
def create_cartesian_point(self, x, y, z=None, is_model_coords=True):
|
||||||
|
if is_model_coords and self.settings["coordinate_offset"]:
|
||||||
|
x += self.settings["coordinate_offset"][0]
|
||||||
|
y += self.settings["coordinate_offset"][1]
|
||||||
|
if z:
|
||||||
|
z += self.settings["coordinate_offset"][2]
|
||||||
x = self.convert_si_to_unit(x)
|
x = self.convert_si_to_unit(x)
|
||||||
y = self.convert_si_to_unit(y)
|
y = self.convert_si_to_unit(y)
|
||||||
if z is None:
|
if z is None:
|
||||||
@@ -856,14 +857,18 @@ class Usecase:
|
|||||||
z = self.convert_si_to_unit(z)
|
z = self.convert_si_to_unit(z)
|
||||||
return self.file.createIfcCartesianPoint((x, y, z))
|
return self.file.createIfcCartesianPoint((x, y, z))
|
||||||
|
|
||||||
def create_cartesian_point_list_from_vertices(self, vertices: list[bpy.types.MeshVertex], is_2d=False):
|
def create_cartesian_point_list_from_vertices(self, vertices: list[bpy.types.MeshVertex], is_2d=False, is_model_coords=True):
|
||||||
|
if is_model_coords and self.settings["coordinate_offset"]:
|
||||||
|
if is_2d:
|
||||||
|
xy_offset = Vector((self.settings["coordinate_offset"][0:2]))
|
||||||
|
return self.file.createIfcCartesianPointList2D([self.convert_si_to_unit(v.co.xy + xy_offset) for v in vertices])
|
||||||
|
xyz_offset = Vector((self.settings["coordinate_offset"][0:3]))
|
||||||
|
return self.file.createIfcCartesianPointList3D([self.convert_si_to_unit(v.co.xyz + xyz_offset) for v in vertices])
|
||||||
if is_2d:
|
if is_2d:
|
||||||
return self.file.createIfcCartesianPointList2D([self.convert_si_to_unit(v.co.xy) for v in vertices])
|
return self.file.createIfcCartesianPointList2D([self.convert_si_to_unit(v.co.xy) for v in vertices])
|
||||||
return self.file.createIfcCartesianPointList3D([self.convert_si_to_unit(v.co) for v in vertices])
|
return self.file.createIfcCartesianPointList3D([self.convert_si_to_unit(v.co) for v in vertices])
|
||||||
|
|
||||||
def convert_si_to_unit(self, co):
|
def convert_si_to_unit(self, co):
|
||||||
if self.settings["coordinate_offset"]:
|
|
||||||
return (co / self.settings["unit_scale"]) + self.settings["coordinate_offset"]
|
|
||||||
return co / self.settings["unit_scale"]
|
return co / self.settings["unit_scale"]
|
||||||
|
|
||||||
def create_annotation2d_representation(self):
|
def create_annotation2d_representation(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user