static PyObject * importer(PyObject *self, PyObject *args) { char* Name; char* DocName=0; if (!PyArg_ParseTuple(args, "et|s","utf-8",&Name,&DocName)) return NULL; std::string EncodedName = std::string(Name); PyMem_Free(Name); PY_TRY { App::Document *pcDoc = 0; if (DocName) pcDoc = App::GetApplication().getDocument(DocName); else pcDoc = App::GetApplication().getActiveDocument(); if (!pcDoc) { pcDoc = App::GetApplication().newDocument(DocName); } MeshObject mesh; if (mesh.load(EncodedName.c_str())) { Base::FileInfo file(EncodedName.c_str()); unsigned long segmct = mesh.countSegments(); if (segmct > 1) { for (unsigned long i=0; i<segmct; i++) { std::auto_ptr<MeshObject> segm(mesh.meshFromSegment(mesh.getSegment(i).getIndices())); Mesh::Feature *pcFeature = static_cast<Mesh::Feature *> (pcDoc->addObject("Mesh::Feature", file.fileNamePure().c_str())); pcFeature->Label.setValue(file.fileNamePure().c_str()); pcFeature->Mesh.swapMesh(*segm); pcFeature->purgeTouched(); } } else { Mesh::Feature *pcFeature = static_cast<Mesh::Feature *> (pcDoc->addObject("Mesh::Feature", file.fileNamePure().c_str())); pcFeature->Label.setValue(file.fileNamePure().c_str()); pcFeature->Mesh.swapMesh(mesh); pcFeature->purgeTouched(); } } } PY_CATCH; Py_Return; }