From a966534295f9b011d5f0c5d7f7ba6e632c506304 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 9 Jul 2013 19:02:53 +0200 Subject: [PATCH] 0000931: Can't change STEP/IGES export units through Python interface --- src/Mod/Part/App/AppPart.cpp | 4 ++++ src/Mod/Part/App/AppPartPy.cpp | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index 76ed19154..3244d0b43 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -13,6 +13,8 @@ #ifndef _PreComp_ # include # include +# include +# include # include # include #endif @@ -228,6 +230,8 @@ void PartExport initPart() Part::GeomSurfaceOfExtrusion ::init(); + IGESControl_Controller::Init(); + STEPControl_Controller::Init(); // set the user-defined units Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part"); diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index e9286a326..ffcf4ec16 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -58,6 +58,7 @@ # include # include # include +# include # include # include # include @@ -1250,6 +1251,34 @@ static PyObject * makeLoft(PyObject *self, PyObject *args) #endif } +static PyObject * exportUnits(PyObject *self, PyObject *args) +{ + char* unit=0; + if (!PyArg_ParseTuple(args, "|s", &unit)) + return NULL; + if (unit) { + if (strcmp(unit,"M") == 0 || strcmp(unit,"MM") == 0 || strcmp(unit,"IN") == 0) { + if (!Interface_Static::SetCVal("write.iges.unit",unit)) { + PyErr_SetString(PyExc_RuntimeError, "Failed to set 'write.iges.unit'"); + return 0; + } + if (!Interface_Static::SetCVal("write.step.unit",unit)) { + PyErr_SetString(PyExc_RuntimeError, "Failed to set 'write.step.unit'"); + return 0; + } + } + else { + PyErr_SetString(PyExc_ValueError, "Wrong unit"); + return 0; + } + } + + Py::Dict dict; + dict.setItem("write.iges.unit", Py::String(Interface_Static::CVal("write.iges.unit"))); + dict.setItem("write.step.unit", Py::String(Interface_Static::CVal("write.step.unit"))); + return Py::new_reference_to(dict); +} + static PyObject * toPythonOCC(PyObject *self, PyObject *args) { PyObject *pcObj; @@ -1587,10 +1616,13 @@ struct PyMethodDef Part_methods[] = { {"makeLoft" ,makeLoft,METH_VARARGS, "makeLoft(list of wires) -- Create a loft shape."}, - + {"makeWireString" ,makeWireString ,METH_VARARGS, "makeWireString(string,fontdir,fontfile,height,[track]) -- Make list of wires in the form of a string's characters."}, + {"exportUnits" ,exportUnits ,METH_VARARGS, + "exportUnits([string=MM|M|IN]) -- Set units for exporting STEP/IGES files and returns the units."}, + {"cast_to_shape" ,cast_to_shape,METH_VARARGS, "cast_to_shape(shape) -- Cast to the actual shape type"},