- std::string aParamName = *it;
- ObjectPtr aParamObj = document()->objectByName(ModelAPI_ResultParameter::group(), aParamName);
- ResultParameterPtr aParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aParamObj);
- if(!aParam.get()) continue;
- AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE());
+ std::string& aVariableName = *it;
+
+ // Parameter with the same name should be searched in the parent document.
+ // For the PartSet assume that the parameter is absent.
+ // Currently there is no way to get parent document, so we get PartSet for all.
+ DocumentPtr aDocument = document();
+ if (data()->name() == aVariableName) {
+ if (aDocument == ModelAPI_Session::get()->moduleDocument())
+ continue;
+ aDocument = ModelAPI_Session::get()->moduleDocument();
+ }
+
+ double aValue;
+ ResultParameterPtr aParamRes;
+ if (!ModelAPI_Tools::findVariable(aVariableName, aValue, aParamRes, aDocument)) continue;
+ aParamsList.push_back(aParamRes);
+