From 273e0f0b71f852ed8edb1b3a749134680d033756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Rheinl=C3=A4nder?= Date: Wed, 4 Dec 2013 20:40:37 +0100 Subject: [PATCH] Fixed bug that did not allow selecting datum planes as external references in sketches --- src/Mod/Sketcher/App/SketchObject.cpp | 5 +++-- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 74344feba..d156b8032 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1707,10 +1707,11 @@ bool SketchObject::isExternalAllowed(App::Document *pDoc, App::DocumentObject *p { // Externals outside of the Document are NOT allowed if (this->getDocument() != pDoc) - return false; + return false; + // Note: Checking for the body of the support doesn't work when the support are the three base planes App::DocumentObject *support = this->Support.getValue(); - Part::BodyBase* body = Part::BodyBase::findBodyOf(support); + Part::BodyBase* body = Part::BodyBase::findBodyOf(this); if (body != NULL) { if (Part::BodyBase::findBodyOf(pObj) != body) { // Selection outside of body not allowed if flag is not set diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 067c3069e..75714e31d 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -4478,8 +4478,8 @@ namespace SketcherGui { if (!sketch->isExternalAllowed(pDoc, pObj)) return false; - App::DocumentObject *support = sketch->Support.getValue(); - Part::BodyBase* body = Part::BodyBase::findBodyOf(support); + // Note: its better to search the support of the sketch in case the sketch support is a base plane + Part::BodyBase* body = Part::BodyBase::findBodyOf(sketch); if ((body != NULL) && (Part::BodyBase::findBodyOf(pObj) == body) && body->isAfterTip(pObj)) // Don't allow selection after the Tip feature in the same body return false; @@ -4491,7 +4491,10 @@ namespace SketcherGui { (element.size() > 6 && element.substr(0,6) == "Vertex") || (element.size() > 4 && element.substr(0,4) == "Face")) { return true; - } + } + if (pObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) || + pObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) + return true; return false; } };