From 656c0116bea5c7b929143539fce2097c6c3f6b57 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 12 Oct 2015 14:29:00 +0300 Subject: [PATCH] FIx for the python scripts: with and without nested transactions the current feature must be correctly set in the end. --- src/Model/Model_Document.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 28fda6f31..9a22410ec 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -341,6 +341,19 @@ bool Model_Document::finishOperation() bool isNestedClosed = !myDoc->HasOpenCommand() && !myNestedNum.empty(); static std::shared_ptr aSession = std::static_pointer_cast(Model_Session::get()); + // do it before flashes to enable and recompute nesting features correctly + if (myNestedNum.empty() || (isNestedClosed && myNestedNum.size() == 1)) { + // if all nested operations are closed, make current the higher level objects (to perform + // it in the python scripts correctly): sketch become current after creation ofsub-elements + FeaturePtr aCurrent = currentFeature(false); + CompositeFeaturePtr aMain, aNext = ModelAPI_Tools::compositeOwner(aCurrent); + while(aNext.get()) { + aMain = aNext; + aNext = ModelAPI_Tools::compositeOwner(aMain); + } + if (aMain.get() && aMain != aCurrent) + setCurrentFeature(aMain, false); + } myObjs->synchronizeBackRefs(); Events_Loop* aLoop = Events_Loop::loop(); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); -- 2.39.2