return anUsedParameters;
}
-std::list<ResultParameterPtr> findVariables(const std::set<std::string>& theParameters)
+std::list<ResultParameterPtr> findVariables(const std::set<std::string>& theParameters,
+ const DocumentPtr& theDocument)
{
std::list<ResultParameterPtr> aResult;
std::set<std::string>::const_iterator aParamIt = theParameters.cbegin();
ResultParameterPtr aParam;
// theSearcher is not needed here: in expressions
// of features the parameters history is not needed
- if (ModelAPI_Tools::findVariable(FeaturePtr(), aName, aValue, aParam))
+ if (ModelAPI_Tools::findVariable(FeaturePtr(), aName, aValue, aParam, theDocument))
aResult.push_back(aParam);
}
return aResult;
AttributeIntegerPtr anAttribute =
std::dynamic_pointer_cast<ModelAPI_AttributeInteger>(anAttr);
std::set<std::string> anUsedParameters = anAttribute->usedParameters();
- std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters);
+ std::list<ResultParameterPtr> aParameters =
+ findVariables(anUsedParameters, owner()->document());
aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
} else if (aType == ModelAPI_AttributeDouble::typeId()) { // double attribute
AttributeDoublePtr anAttribute =
std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(anAttr);
std::set<std::string> anUsedParameters = anAttribute->usedParameters();
- std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters);
+ std::list<ResultParameterPtr> aParameters =
+ findVariables(anUsedParameters, owner()->document());
aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
} else if (aType == GeomDataAPI_Point::typeId()) { // point attribute
AttributePointPtr anAttribute =
std::dynamic_pointer_cast<GeomDataAPI_Point>(anAttr);
std::set<std::string> anUsedParameters = usedParameters(anAttribute);
- std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters);
+ std::list<ResultParameterPtr> aParameters =
+ findVariables(anUsedParameters, owner()->document());
aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
} else if (aType == GeomDataAPI_Point2D::typeId()) { // point attribute
AttributePoint2DPtr anAttribute =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr);
std::set<std::string> anUsedParameters = usedParameters(anAttribute);
- std::list<ResultParameterPtr> aParameters = findVariables(anUsedParameters);
+ std::list<ResultParameterPtr> aParameters =
+ findVariables(anUsedParameters, owner()->document());
aReferenced.insert(aReferenced.end(), aParameters.begin(), aParameters.end());
} else
continue; // nothing to do, not reference
# Initialization of the test
#=========================================================================
from ModelAPI import *
-# from GeomDataAPI import *
-# from GeomAlgoAPI import *
__updated__ = "2014-12-26"
# Creation and activation of documents
#=========================================================================
aSession = ModelAPI_Session.get()
-# TODO: enable this assertion:
assert(aSession.moduleDocument())
assert(aSession.moduleDocument().id() == 0)
assert(aSession.moduleDocument().kind() == "PartSet")
TestParameterRename.py
TestParameterChangeValue.py
Test1806.py
+ Test2392.py
)
--- /dev/null
+## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+param_d1 = model.addParameter(partSet, "d1", "5", "Chain roller diameter")
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+model.addParameter(Part_1_doc, "z", "25", "Number of teeth of the asterisk")
+model.addParameter(Part_1_doc, "Lambda", "1.8", "Engagement chracteristic")
+model.addParameter(Part_1_doc, "K", "0.565", "Tooth height coefficient")
+model.addParameter(Part_1_doc, "De", "d1*Lambda*(K+1./tan(pi/z))", "External diameter")
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchCircle_1 = Sketch_1.addCircle(0, 0, 38.16365)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
+SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], "De/2")
+model.end()
+
+# due to the scenario, change the active document
+model.begin()
+from ModelAPI import *
+aSession = ModelAPI_Session.get()
+aSession.setActiveDocument(partSet, False)
+model.do()
+# change the parameter value
+param_d1.setValue(8.51)
+model.do()
+# make the part document active back
+aSession.setActiveDocument(Part_1_doc, False)
+model.end()
+
+# check the circle radius value
+assert(SketchCircle_1.radius().value() == 64.9545)
+
+assert(model.checkPythonDump())