0000931: Can't change STEP/IGES export units through Python interface
This commit is contained in:
parent
adc0052997
commit
a966534295
|
@ -13,6 +13,8 @@
|
|||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
# include <Interface_Static.hxx>
|
||||
# include <IGESControl_Controller.hxx>
|
||||
# include <STEPControl_Controller.hxx>
|
||||
# include <OSD.hxx>
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
@ -228,6 +230,8 @@ void PartExport initPart()
|
|||
Part::GeomSurfaceOfExtrusion ::init();
|
||||
|
||||
|
||||
IGESControl_Controller::Init();
|
||||
STEPControl_Controller::Init();
|
||||
// set the user-defined units
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part");
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
# include <Handle_Geom_Circle.hxx>
|
||||
# include <Handle_Geom_Plane.hxx>
|
||||
# include <Handle_Geom2d_TrimmedCurve.hxx>
|
||||
# include <Interface_Static.hxx>
|
||||
# include <ShapeUpgrade_ShellSewing.hxx>
|
||||
# include <Standard_ConstructionError.hxx>
|
||||
# include <Standard_DomainError.hxx>
|
||||
|
@ -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"},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user