From 5bfe90b2aa988ea117026c0372cf4eeaedbe9141 Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Sun, 6 Mar 2022 23:35:37 -0500 Subject: [PATCH] [Sketcher] Check for b-spline before starting knot insertion "mode" The DrawSketchHandler will otherwise give confusing error messages. --- src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index f387e93616..302c967104 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -1205,8 +1205,16 @@ void CmdSketcherInsertKnot::activated(int iMsg) // TODO: Ensure GeoId is for the BSpline and not for it's internal geometry int GeoId = std::atoi(SubNames[0].substr(4,4000).c_str()) - 1; + const Part::Geometry * geo = Obj->getGeometry(GeoId); - ActivateBSplineHandler(getActiveGuiDocument(), new DrawSketchHandlerBSplineInsertKnot(Obj, GeoId)); + if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) + ActivateBSplineHandler(getActiveGuiDocument(), new DrawSketchHandlerBSplineInsertKnot(Obj, GeoId)); + else { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong selection"), + QObject::tr("Please select a b-spline curve to insert a knot (not a knot on it). " + "If the curve is not a b-spline, please convert it into one first.")); + } getSelection().clearSelection(); }