From 0647aa4539c149a65cad99096fc81c8f7a5c54e6 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 16 Jan 2019 11:22:23 +0300 Subject: [PATCH] Make model.end() in unit-tests set current feature to the last feature of the active document. --- src/ModelAPI/Test/Test2401.py | 2 -- src/ModelAPI/Test/TestFeatureSelection_2.py | 3 --- src/ModelAPI/Test/TestSelectionScope.py | 1 - src/ModelHighAPI/ModelHighAPI_Services.cpp | 9 +++++++++ src/SketchPlugin/Test/Test2654.py | 3 --- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ModelAPI/Test/Test2401.py b/src/ModelAPI/Test/Test2401.py index 80869d143..e5b4456c5 100644 --- a/src/ModelAPI/Test/Test2401.py +++ b/src/ModelAPI/Test/Test2401.py @@ -77,8 +77,6 @@ model.do() SketchLine_8 = Sketch_1.addLine(0, 3, 8, 3) SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_8.startPoint()) SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_8.endPoint()) -model.do() -Part_1_doc.setCurrentFeature(Fill_1.feature(), True) model.end() # check that the plane is located as previously diff --git a/src/ModelAPI/Test/TestFeatureSelection_2.py b/src/ModelAPI/Test/TestFeatureSelection_2.py index e1d41a397..b9a47dd3a 100644 --- a/src/ModelAPI/Test/TestFeatureSelection_2.py +++ b/src/ModelAPI/Test/TestFeatureSelection_2.py @@ -56,9 +56,6 @@ model.do() # update the parameter N => number of sketch contours is changed Param_N.setValue(4) -Part_1_doc.setCurrentFeature(None, True) -model.do() -Part_1_doc.setCurrentFeature(Cut_1.feature(), True) model.end() assert(Cut_1.result().numberOfSubs() == 4) diff --git a/src/ModelAPI/Test/TestSelectionScope.py b/src/ModelAPI/Test/TestSelectionScope.py index f8a754dc8..b11a40e30 100644 --- a/src/ModelAPI/Test/TestSelectionScope.py +++ b/src/ModelAPI/Test/TestSelectionScope.py @@ -71,7 +71,6 @@ Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "[Extrusion model.do() # make sketch_2 cut the whole top face of the initial extrusion, so, one of the cylinder becomes invalid lenParam.setValue(100) -Part_1_doc.setCurrentFeature(Cylinder_2.feature(), True) model.do() # update selection of cylinder base points model.selection("VERTEX", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_6)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)]").fillAttribute(Cylinder_1.basePoint()) diff --git a/src/ModelHighAPI/ModelHighAPI_Services.cpp b/src/ModelHighAPI/ModelHighAPI_Services.cpp index 20e21e1b4..443b861ad 100644 --- a/src/ModelHighAPI/ModelHighAPI_Services.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Services.cpp @@ -103,6 +103,15 @@ void begin() void end() { + // some operations make the current feature not the last one (like "galeries" change parameters) + DocumentPtr anActive = ModelAPI_Session::get()->activeDocument(); + int aSize = anActive->size("Features"); + if (aSize > 0) { + FeaturePtr aLastFeat = + std::dynamic_pointer_cast(anActive->object("Features", aSize - 1)); + anActive->setCurrentFeature(aLastFeat, true); + } + ModelAPI_Session::get()->finishOperation(); // to update data tree in the end of dumped script execution ModelAPI_EventCreator::get()->sendReordered(FeaturePtr()); diff --git a/src/SketchPlugin/Test/Test2654.py b/src/SketchPlugin/Test/Test2654.py index f78931992..540142fd0 100644 --- a/src/SketchPlugin/Test/Test2654.py +++ b/src/SketchPlugin/Test/Test2654.py @@ -178,9 +178,6 @@ assert(Split_1.feature().error() != "") Part_1_doc.removeFeature(Split_1.feature()) model.do() model.checkSketch(Sketch_2, 0) - -Part_1_doc.setCurrentFeature(Extrusion_2.feature(), True) - model.end() assert(model.checkPythonDump()) -- 2.39.2