diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 6eeac89950..74aa65c000 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -9567,6 +9567,12 @@ bool SketchObject::arePointsCoincident(int GeoId1, PointPos PosId1, int GeoId2, return false; } +bool SketchObject::hasBlockConstraint() const +{ + return std::ranges::any_of(Constraints.getValues(), [](auto& c) { + return c->Type == Block; + }); +} void SketchObject::getConstraintIndices(int GeoId, std::vector& constraintList) { diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index f4135ec3c8..d1223f2e75 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -648,6 +648,9 @@ public: ); bool arePointsCoincident(int GeoId1, PointPos PosId1, int GeoId2, PointPos PosId2); + // Returns true if the sketch has 1 or more block constraint + bool hasBlockConstraint() const; + /// returns a list of indices of all constraints involving given GeoId void getConstraintIndices(int GeoId, std::vector& constraintList); diff --git a/src/Mod/Sketcher/Gui/EditDatumDialog.cpp b/src/Mod/Sketcher/Gui/EditDatumDialog.cpp index e4846b4874..e0a041fa6d 100644 --- a/src/Mod/Sketcher/Gui/EditDatumDialog.cpp +++ b/src/Mod/Sketcher/Gui/EditDatumDialog.cpp @@ -418,10 +418,12 @@ void EditDatumDialog::performAutoScale(double newDatum) // if there are external geometries, it is safe to assume that the sketch // was drawn with these geometries as scale references (use <= 2 because // the sketch axis are considered as external geometries) + // if the sketch has blocked geometries, it is considered a scale indicator + // and autoscale is not performed either if ((autoScaleMode == static_cast(SketcherGui::AutoScaleMode::Always) || (autoScaleMode == static_cast(SketcherGui::AutoScaleMode::WhenNoScaleFeatureIsVisible) && !hasVisualFeature(sketch, nullptr, Gui::Application::Instance->activeDocument()))) - && sketch->getExternalGeometryCount() <= 2) { + && sketch->getExternalGeometryCount() <= 2 && !sketch->hasBlockConstraint()) { try { // Handle the case where multiple datum constraints are present but only one is scale // defining e.g. a bunch of angle constraints and a single length constraint