From 415b0dce25e8da5b298bd0554a781ff437ae1197 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 11 Jun 2020 14:15:04 +0200 Subject: [PATCH] Draft: Allow to define rounding value in DraftVecUtils.rounded --- src/Mod/Draft/DraftVecUtils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/DraftVecUtils.py b/src/Mod/Draft/DraftVecUtils.py index 87fbfbf7d5..9467b8c364 100644 --- a/src/Mod/Draft/DraftVecUtils.py +++ b/src/Mod/Draft/DraftVecUtils.py @@ -703,8 +703,9 @@ def isColinear(vlist): return True -def rounded(v): - """Return a vector rounded to the `precision` in the parameter database. +def rounded(v,d=None): + """Return a vector rounded to the `precision` in the parameter database + or to the given decimals value Each of the components of the vector is rounded to the decimal precision set in the parameter database. @@ -713,6 +714,7 @@ def rounded(v): ---------- v : Base::Vector3 The input vector. + d : (Optional) the number of decimals to round to Returns ------- @@ -722,6 +724,8 @@ def rounded(v): in the parameter database. """ p = precision() + if d: + p = d return Vector(round(v.x, p), round(v.y, p), round(v.z, p))