From 1188f7d7a1db89d01f1d80f6b60aa9a8883dd307 Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Fri, 26 Nov 2021 15:26:02 +0100 Subject: [PATCH] [Sketcher] Allow to autoconstraint slot horizontal/vertical --- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index c064f96b42..26bb0f6ebe 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -7090,7 +7090,7 @@ public: setPositionText(onSketchPos, text); sketchgui->drawEdit(EditCurve); - if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2d(0.f, 0.f))) { + if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2d(dx, dy), AutoConstraint::VERTEX_NO_TANGENCY)) { renderSuggestConstraintsCursor(sugConstr2); return; } @@ -7144,6 +7144,9 @@ public: try { Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Add slot")); + + AutoConstraint lastCons = sugConstr2.back(); + ostringstream snapCon = ostringstream(""); if (SnapMode == SNAP_MODE_Straight) { snapCon << "conList.append(Sketcher.Constraint('"; @@ -7154,7 +7157,17 @@ public: snapCon << "Vertical"; } snapCon << "'," << firstCurve + 2 << "))\n"; + + // If horizontal/vertical already applied because of snap, do not duplicate with Autocontraint + if (lastCons.Type == Sketcher::Horizontal || lastCons.Type == Sketcher::Vertical) + sugConstr2.pop_back(); } + else { + // If horizontal/vertical Autoconstraint suggested, applied it on first line (rather than last arc) + if (lastCons.Type == Sketcher::Horizontal || lastCons.Type == Sketcher::Vertical) + sugConstr2.back().GeoId = firstCurve + 2; + } + Gui::Command::doCommand(Gui::Command::Doc, "geoList = []\n" "geoList.append(Part.ArcOfCircle(Part.Circle(App.Vector(%f, %f, 0), App.Vector(0, 0, 1), %f), %f, %f))\n"