diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index 3eebe56587..77cb4eb88c 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -246,6 +246,9 @@ double DrawProjGroup::calculateAutomaticScale() const arrangeViewPointers(viewPtrs); double width, height; minimumBbViews(viewPtrs, width, height); //get 1:1 bbxs + // if Page.keepUpdated is false, and DrawViews have never been executed, + // bb's will be 0x0 and this routine will return 0!!! + // if we return 1.0, AutoScale will sort itself out once bb's are non-zero. double bbFudge = 1.2; width *= bbFudge; height *= bbFudge; @@ -269,6 +272,10 @@ double DrawProjGroup::calculateAutomaticScale() const double scaleFudge = 0.80; float working_scale = scaleFudge * std::min(scale_x, scale_y); double result = DrawUtil::sensibleScale(working_scale); + if (!(result > 0.0)) { + Base::Console().Log("DPG - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),result); + result = 1.0; + } return result; } diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp index ace8c85b80..7a10f6e1ed 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp @@ -183,6 +183,10 @@ double DrawProjGroupItem::getScale(void) const auto pgroup = getPGroup(); if (pgroup != nullptr) { result = pgroup->Scale.getValue(); + if (!(result > 0.0)) { + Base::Console().Log("DPGI - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),Scale.getValue()); + result = 1.0; //kludgy protective fix. autoscale sometimes serves up 0.0! + } } return result; } diff --git a/src/Mod/TechDraw/App/DrawUtil.cpp b/src/Mod/TechDraw/App/DrawUtil.cpp index f89b085ac6..ab3c69e13b 100644 --- a/src/Mod/TechDraw/App/DrawUtil.cpp +++ b/src/Mod/TechDraw/App/DrawUtil.cpp @@ -400,6 +400,9 @@ Base::Vector3d DrawUtil::closestBasis(Base::Vector3d v) double DrawUtil::sensibleScale(double working_scale) { double result = 1.0; + if (!(working_scale > 0.0)) { + return result; + } //which gives the largest scale for which the min_space requirements can be met, but we want a 'sensible' scale, rather than 0.28457239... //eg if working_scale = 0.115, then we want to use 0.1, similarly 7.65 -> 5, and 76.5 -> 50 diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index abc2fb46ef..a421df2d74 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -249,6 +249,10 @@ void DrawView::setPosition(double x, double y) double DrawView::getScale(void) const { auto result = Scale.getValue(); + if (!(result > 0.0)) { + result = 1.0; + Base::Console().Log("DrawView - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),Scale.getValue()); + } return result; } diff --git a/src/Mod/TechDraw/App/GeometryObject.cpp b/src/Mod/TechDraw/App/GeometryObject.cpp index 5cb36e492e..899ebdd570 100644 --- a/src/Mod/TechDraw/App/GeometryObject.cpp +++ b/src/Mod/TechDraw/App/GeometryObject.cpp @@ -626,12 +626,16 @@ TopoDS_Shape TechDrawGeometry::mirrorShape(const TopoDS_Shape &input, if (input.IsNull()) { return transShape; } - try { // Make tempTransform scale the object around it's centre point and // mirror about the Y axis gp_Trsf tempTransform; - tempTransform.SetScale(inputCenter, scale); + //BRepBuilderAPI_Transform will loop forever if asked to use 0.0 as scale + if (!(scale > 0.0)) { + tempTransform.SetScale(inputCenter, 1.0); + } else { + tempTransform.SetScale(inputCenter, scale); + } gp_Trsf mirrorTransform; mirrorTransform.SetMirror( gp_Ax2(inputCenter, gp_Dir(0, -1, 0)) ); tempTransform.Multiply(mirrorTransform);