mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
extend #6777 to have elevation print out as well.
This commit is contained in:
@@ -1205,22 +1205,11 @@ class PlanLevelDecorator(BaseDecorator):
|
||||
|
||||
def get_text():
|
||||
abs_z = verts[0].z
|
||||
z = abs_z
|
||||
|
||||
if element:
|
||||
spatial_container = ifcopenshell.util.element.get_container(element)
|
||||
|
||||
if spatial_container:
|
||||
container_obj = tool.Ifc.get_object(spatial_container)
|
||||
|
||||
if container_obj:
|
||||
spatial_container_z = container_obj.matrix_world.translation.z
|
||||
z = abs_z - spatial_container_z
|
||||
z = helper.get_relative_z(obj, element, abs_z)
|
||||
|
||||
rl = self.format_value(context, z)
|
||||
text = "{}{}".format("" if z < 0 else "+", rl)
|
||||
return text
|
||||
|
||||
self.draw_dimension_text(
|
||||
context,
|
||||
get_text,
|
||||
|
||||
@@ -539,3 +539,26 @@ def add_newline_between_words(text: str, newline_at: int) -> str:
|
||||
start = space_index + 1 # Skip the space itself
|
||||
|
||||
return "\n".join(result)
|
||||
|
||||
|
||||
def get_relative_z(obj: bpy.types.Object, element, abs_z: float) -> float:
|
||||
"""Return relative Z of an element, accounting for its spatial container.
|
||||
|
||||
Args:
|
||||
obj: The Blender object representing the element.
|
||||
element: The IFC entity for the object.
|
||||
abs_z: The absolute Z value in world coordinates.
|
||||
|
||||
Returns:
|
||||
Relative Z value if the element is inside a spatial container,
|
||||
otherwise the absolute Z.
|
||||
"""
|
||||
z = abs_z
|
||||
if element:
|
||||
spatial_container = ifcopenshell.util.element.get_container(element)
|
||||
if spatial_container:
|
||||
container_obj = tool.Ifc.get_object(spatial_container)
|
||||
if container_obj:
|
||||
spatial_container_z = container_obj.matrix_world.translation.z
|
||||
z = abs_z - spatial_container_z
|
||||
return z
|
||||
|
||||
@@ -1012,7 +1012,9 @@ class SvgWriter:
|
||||
|
||||
# TODO: allow metric to be configurable
|
||||
def get_text():
|
||||
z = (matrix_world @ points[0].co.xyz).z
|
||||
abs_z = (matrix_world @ points[0].co.xyz).z
|
||||
z = helper.get_relative_z(obj, element, abs_z)
|
||||
|
||||
rl = helper.format_distance(
|
||||
z,
|
||||
precision=self.precision,
|
||||
|
||||
Reference in New Issue
Block a user