From 07eced129a94fbf888f64e21ecf6d2f5b6977092 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:01:59 +0200 Subject: [PATCH] Draft: Fix annotation scale to label issue. The scale_to_label function did not handle scale 5:1, 10:1 or 20:1 properly. --- .../Draft/draftutils/init_draft_statusbar.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Mod/Draft/draftutils/init_draft_statusbar.py b/src/Mod/Draft/draftutils/init_draft_statusbar.py index 5d41b8b6a1..67a700b113 100644 --- a/src/Mod/Draft/draftutils/init_draft_statusbar.py +++ b/src/Mod/Draft/draftutils/init_draft_statusbar.py @@ -97,14 +97,22 @@ def scale_to_label(scale): """ transform a float number into a 1:X or X:1 scale and return it as label """ - f = 1/scale - f = round(f,2) - f = f.as_integer_ratio() - if f[1] == 1 or f[0] == 1: - label = str(f[1]) + ":" + str(f[0]) - return label + f = round(scale, 2) + if f == 1.0: + return "1:1" + elif f > 1.0: + f = f.as_integer_ratio() + if f[1] == 1: + return str(f[0]) + ":1" + else: + return str(scale) else: - return str(scale) + f = round(1/scale, 2) + f = f.as_integer_ratio() + if f[1] == 1: + return "1:" + str(f[0]) + else: + return str(scale) def label_to_scale(label): """