Close #2451. Implement georeferenced elevations in drawings.

This commit is contained in:
Dion Moult
2023-02-02 22:55:39 +11:00
parent 18ba805a15
commit f77d2f449d
2 changed files with 19 additions and 2 deletions
@@ -23,6 +23,7 @@ import blf
import bgl import bgl
import math import math
import bmesh import bmesh
import ifcopenshell
import blenderbim.tool as tool import blenderbim.tool as tool
import blenderbim.bim.module.drawing.helper as helper import blenderbim.bim.module.drawing.helper as helper
from functools import reduce from functools import reduce
@@ -1150,6 +1151,7 @@ class PlanLevelDecorator(LevelDecorator):
""" """
def draw_labels(self, context, obj, splines): def draw_labels(self, context, obj, splines):
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
region = context.region region = context.region
region3d = context.region_data region3d = context.region_data
for verts in splines: for verts in splines:
@@ -1160,7 +1162,10 @@ class PlanLevelDecorator(LevelDecorator):
dir = p1 - p0 dir = p1 - p0
if dir.length < 1: if dir.length < 1:
continue continue
text = "RL " + self.format_value(context, verts[-1].z) z = verts[-1].z / unit_scale
z = ifcopenshell.util.geolocation.auto_z2e(tool.Ifc.get(), z)
z *= unit_scale
text = "RL " + self.format_value(context, z)
self.draw_label(context, text, p0, dir, gap=8, center=False) self.draw_label(context, text, p0, dir, gap=8, center=False)
@@ -1233,6 +1238,7 @@ class SectionLevelDecorator(LevelDecorator):
""" """
def draw_labels(self, context, obj, splines): def draw_labels(self, context, obj, splines):
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
region = context.region region = context.region
region3d = context.region_data region3d = context.region_data
for verts in splines: for verts in splines:
@@ -1245,7 +1251,10 @@ class SectionLevelDecorator(LevelDecorator):
dir = p1 - p0 dir = p1 - p0
if dir.length < 1: if dir.length < 1:
continue continue
text = "RL " + self.format_value(context, verts[-1].z) z = verts[-1].z / unit_scale
z = ifcopenshell.util.geolocation.auto_z2e(tool.Ifc.get(), z)
z *= unit_scale
text = "RL " + self.format_value(context, z)
self.draw_label(context, text, p0 + dir.normalized() * 16, -dir, gap=16, center=False) self.draw_label(context, text, p0 + dir.normalized() * 16, -dir, gap=16, center=False)
@@ -196,6 +196,10 @@ class SvgWriter:
if bpy.context.scene.unit_settings.system == "IMPERIAL": if bpy.context.scene.unit_settings.system == "IMPERIAL":
rl = helper.format_distance(rl) rl = helper.format_distance(rl)
else: else:
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
rl /= unit_scale
rl = ifcopenshell.util.geolocation.auto_z2e(tool.Ifc.get(), rl)
rl *= unit_scale
rl = "{:.3f}m".format(rl) rl = "{:.3f}m".format(rl)
text_style = { text_style = {
"font-size": annotation.Annotator.get_svg_text_size(2.5), "font-size": annotation.Annotator.get_svg_text_size(2.5),
@@ -600,6 +604,10 @@ class SvgWriter:
if bpy.context.scene.unit_settings.system == "IMPERIAL": if bpy.context.scene.unit_settings.system == "IMPERIAL":
rl = helper.format_distance(rl) rl = helper.format_distance(rl)
else: else:
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
rl /= unit_scale
rl = ifcopenshell.util.geolocation.auto_z2e(tool.Ifc.get(), rl)
rl *= unit_scale
rl = "{:.3f}m".format(rl) rl = "{:.3f}m".format(rl)
if projected_points[0].x > projected_points[-1].x: if projected_points[0].x > projected_points[-1].x:
text_anchor = "end" text_anchor = "end"