From: sbh Date: Thu, 27 Nov 2014 09:02:37 +0000 (+0300) Subject: Resolve cast and import errors in Box.py X-Git-Tag: V_0.7.0_rc1~57^2~3^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FBR_PYTHON_PLUGIN;p=modules%2Fshaper.git Resolve cast and import errors in Box.py --- diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index 27a03156c..0cfe43246 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -134,13 +134,12 @@ void Config_ModuleReader::loadPlugin(const std::string thePluginName) void Config_ModuleReader::loadScript(const std::string theFileName) { - std::string aPythonFile = theFileName + ".py"; /* aquire python thread */ PyGILState_STATE gstate = PyGILState_Ensure(); - PyObject* module = PyImport_ImportModule(aPythonFile.c_str()); + PyObject* module = PyImport_ImportModule(theFileName.c_str()); if (!module) { - std::string anErrorMsg = "An error occured while loading " + aPythonFile; + std::string anErrorMsg = "An error occured while importing " + theFileName; //Get detailed error message: if (PyErr_Occurred()) { PyObject *ptype, *pvalue, *ptraceback; diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index 5043bcfe1..5c97aeb4c 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -135,6 +135,7 @@ template std::shared_ptr shared_ptr_cast(std::shared_ptr %template(modelAPI_CompositeFeature) shared_ptr_cast; %template(modelAPI_Feature) shared_ptr_cast; // Result casts +%template(modelAPI_Result) shared_ptr_cast; %template(modelAPI_ResultConstruction) shared_ptr_cast; %template(modelAPI_ResultBody) shared_ptr_cast; %template(modelAPI_ResultPart) shared_ptr_cast; diff --git a/src/PythonFeaturesPlugin/PythonFeaturesPlugin_Box.py b/src/PythonFeaturesPlugin/PythonFeaturesPlugin_Box.py index d08cf3d95..b150690de 100644 --- a/src/PythonFeaturesPlugin/PythonFeaturesPlugin_Box.py +++ b/src/PythonFeaturesPlugin/PythonFeaturesPlugin_Box.py @@ -62,20 +62,23 @@ class PythonFeaturesPlugin_Box(ModelAPI.ModelAPI_Feature): aWidth = self.real(self.WIDTH_ID()).value() aLength = self.real(self.LENGTH_ID()).value() aHeight = self.real(self.HEIGHT_ID()).value() - aHeightFeature = None - aHeightFeatureResult = ModelAPI.modelAPI_ResultBody(self.reference(self.HEIGHT_REF_ID()).value()) - if aHeightFeatureResult is not None: - aHeightFeature = aHeightFeatureResult.document().feature(aHeightFeatureResult) - aWidthFeature = ModelAPI.modelAPI_Feature(self.reference(self.WIDTH_REF_ID()).value()) - aLengthFeature = ModelAPI.modelAPI_Feature(self.reference(self.LENGTH_REF_ID()).value()) + aWidthRefValue = self.reference(self.WIDTH_REF_ID()).value() + aLengthRefValue = self.reference(self.LENGTH_REF_ID()).value() + aHeightRefValue = self.reference(self.HEIGHT_REF_ID()).value() aResult = None - if not all((aWidthFeature, aLengthFeature, aLengthFeature)): + if not all((aWidthRefValue, aLengthRefValue, aHeightRefValue)): aResult = extrusion.getBody(self.makeBox(aLength, aWidth, aHeight)) else: + aHeightProxyResult = ModelAPI.modelAPI_Result(aHeightRefValue) + aWidthFeature = ModelAPI.modelAPI_Feature(aWidthRefValue) + aLengthFeature = ModelAPI.modelAPI_Feature(aLengthRefValue) + aHeightResult = ModelAPI.modelAPI_ResultBody(aHeightProxyResult) aWidthFeature.real("ConstraintValue").setValue(aWidth) aLengthFeature.real("ConstraintValue").setValue(aLength) - aHeightFeature.real("extrusion_size").setValue(aHeight) - aResult = extrusion.getBody(aHeightFeature) + if aHeightResult is not None: + aHeightFeature = aHeightResult.document().feature(aHeightResult) + aHeightFeature.real("extrusion_size").setValue(aHeight) + aResult = extrusion.getBody(aHeightFeature) self.setResult(aResult) def makeBox(self, aWidth, aLength, aHeight):