From 41102edf674bbcdc7c5f9397b0a6df4b6c3f1b9e Mon Sep 17 00:00:00 2001 From: Mark Ganson TheMarkster <39143564+mwganson@users.noreply.github.com> Date: Tue, 4 Sep 2018 12:29:05 -0500 Subject: [PATCH] fix bug in draft path array put lnodes.normalize() inside try/except block replace hard-coded 1e-6 with Vector3d::epsilon() in VectorPy::normalize() --- src/Base/VectorPyImp.cpp | 2 +- src/Mod/Draft/Draft.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Base/VectorPyImp.cpp b/src/Base/VectorPyImp.cpp index 6a862e46d4..2b698d7a2a 100644 --- a/src/Base/VectorPyImp.cpp +++ b/src/Base/VectorPyImp.cpp @@ -451,7 +451,7 @@ PyObject* VectorPy::normalize(PyObject *args) if (!PyArg_ParseTuple(args, "")) return 0; VectorPy::PointerType ptr = reinterpret_cast(_pcTwinPointer); - if (ptr->Length() < 1.0e-6) { + if (ptr->Length() < Vector3d::epsilon()) { PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot normalize null vector"); return 0; } diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 939689417f..29cafb7233 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -6037,9 +6037,10 @@ class _PathArray(_DraftObject): b = nullv FreeCAD.Console.PrintLog ("Draft PathArray.orientShape - Cannot calculate Path normal.\n") lnodes = z.cross(b) - if lnodes != nullv: + try: lnodes.normalize() # Can't normalize null vector. - # pathological cases: + except: + pass # pathological cases: if n == nullv: # 1) can't determine normal, don't align. psi = 0.0 theta = 0.0