mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Fix imperial unit conversion for plan and section level decorators
Level annotations were incorrectly converting feet to meters and back, causing values like 3ft to display as 9'10". Updated format_value() to accept in_unit_length parameter and pass it to format_distance(), since Blender's Z coordinates are already in project units. - Add in_unit_length parameter to BaseDecorator.format_value() - Set in_unit_length=True in PlanLevelDecorator.draw_labels() - Set in_unit_length=True in SectionLevelDecorator.draw_labels()
This commit is contained in:
@@ -489,7 +489,7 @@ class BaseDecorator:
|
||||
self.draw_label(context, text=text, line_no=line_number_start, multiline=True, **draw_label_kwargs)
|
||||
|
||||
@cache
|
||||
def format_value(self, context, value, suppress_zero_inches=False, custom_unit=None):
|
||||
def format_value(self, context, value, suppress_zero_inches=False, custom_unit=None, in_unit_length=False):
|
||||
drawing_pset_data = DrawingsData.data["active_drawing_pset_data"]
|
||||
precision = drawing_pset_data.get("MetricPrecision", None)
|
||||
if not precision:
|
||||
@@ -502,6 +502,7 @@ class BaseDecorator:
|
||||
decimal_places=decimal_places,
|
||||
suppress_zero_inches=suppress_zero_inches,
|
||||
custom_unit=custom_unit,
|
||||
in_unit_length=in_unit_length,
|
||||
)
|
||||
|
||||
def draw_asterisk(self, context: bpy.types.Context, pos: Vector, rotation: float = 0.0, scale: float = 1.0) -> None:
|
||||
@@ -1203,7 +1204,7 @@ class PlanLevelDecorator(BaseDecorator):
|
||||
abs_z = verts[0].z
|
||||
z = helper.get_relative_z(obj, element, abs_z)
|
||||
|
||||
rl = self.format_value(context, z)
|
||||
rl = self.format_value(context, z, in_unit_length=True)
|
||||
text = "{}{}".format("" if z < 0 else "+", rl)
|
||||
return text
|
||||
|
||||
@@ -1276,7 +1277,7 @@ class SectionLevelDecorator(BaseDecorator):
|
||||
|
||||
def get_text():
|
||||
z = verts[0].z
|
||||
rl = self.format_value(context, z)
|
||||
rl = self.format_value(context, z, in_unit_length=True)
|
||||
text = "RL {}{}".format("" if z < 0 else "+", rl)
|
||||
return text
|
||||
|
||||
@@ -1291,7 +1292,6 @@ class SectionLevelDecorator(BaseDecorator):
|
||||
)
|
||||
break # support only 1 label
|
||||
|
||||
|
||||
class BreakDecorator(BaseDecorator):
|
||||
"""Decorator for breakline objects
|
||||
- first edge of a mesh with zigzag thingy in the middle
|
||||
|
||||
Reference in New Issue
Block a user