From: dbv Date: Wed, 29 Mar 2017 13:35:11 +0000 (+0300) Subject: Issue #2044: Error detection in the parametric API X-Git-Tag: V_2.7.0~145 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b9872d0ff661c85e58fab02c832461c8030e84d2;p=modules%2Fshaper.git Issue #2044: Error detection in the parametric API Set attribute invalid flag when selection with bad name passed. --- diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 9ebc85259..d6c3cf17c 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -664,6 +664,9 @@ void Model_AttributeSelection::selectSubShape( } setValue(aCont, aShapeToBeSelected); } + + setInvalidIfFalse(selectionLabel(), false); + reset(); } int Model_AttributeSelection::Id() diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index e446cff41..61becae78 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include //-------------------------------------------------------------------------------------- @@ -50,6 +51,11 @@ void ModelHighAPI_Selection::fillAttribute( return; case VT_TypeSubShapeNamePair: theAttribute->selectSubShape(myTypeSubShapeNamePair.first, myTypeSubShapeNamePair.second); + if(theAttribute->isInvalid()) { + FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner()); + aFeature->setError( + std::string("Error: attribute \"") + theAttribute->id() + std::string("\" is invalid.")); + } return; } } diff --git a/src/PythonAPI/CMakeLists.txt b/src/PythonAPI/CMakeLists.txt index f68c87258..109e19e3b 100644 --- a/src/PythonAPI/CMakeLists.txt +++ b/src/PythonAPI/CMakeLists.txt @@ -33,10 +33,12 @@ ADD_UNIT_TESTS( TestFeatures.py TestFeaturesExtrusion.py #TestFeaturesRevolution.py - + TestPrimitivesBox.py TestMakeBrick1.py TestMakeBrick2.py TestPlatine.py + + Test2044.py ) diff --git a/src/PythonAPI/Test/Test2044.py b/src/PythonAPI/Test/Test2044.py new file mode 100644 index 000000000..1d8442da4 --- /dev/null +++ b/src/PythonAPI/Test/Test2044.py @@ -0,0 +1,22 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY")) +SketchLine_1 = Sketch_1.addLine(-184.375, -81.25, -71.87500000000006, 206.2500000000001) +SketchLine_2 = Sketch_1.addLine(-71.87500000000006, 206.2500000000001, 281.2500000000001, 178.125) +SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint()) +SketchLine_3 = Sketch_1.addLine(281.2500000000001, 178.125, 184.3750000000001, -109.375) +SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint()) +SketchLine_4 = Sketch_1.addLine(184.3750000000001, -109.375, -184.375, -81.25) +SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint()) +SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_4.endPoint()) +model.do() +Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection("EDGE", "PartSet/OZ"), 50, 0) +model.do() +Extrusion_1.setDirection(model.selection("EDGE", "OX")) +model.do() +print Extrusion_1.feature().error() +model.end()