0000832: Original color STEP model lost in import

This commit is contained in:
wmayer 2012-09-29 15:50:17 +02:00
parent bcddb1e950
commit f403295ca7
5 changed files with 30 additions and 21 deletions

View File

@ -480,20 +480,24 @@ private:
};
/* module functions */
static PyObject * importer(PyObject *self, PyObject *args)
{
const char* Name;
const char* DocName;
if (!PyArg_ParseTuple(args, "ss",&Name,&DocName))
char* Name;
char* DocName=0;
if (!PyArg_ParseTuple(args, "s|s",&Name,&DocName))
return 0;
PY_TRY {
//Base::Console().Log("Insert in Part with %s",Name);
Base::FileInfo file(Name);
App::Document *pcDoc = App::GetApplication().getDocument(DocName);
App::Document *pcDoc = 0;
if (DocName) {
pcDoc = App::GetApplication().getDocument(DocName);
}
if (!pcDoc) {
pcDoc = App::GetApplication().newDocument(DocName);
pcDoc = App::GetApplication().newDocument("Unnamed");
}
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
@ -561,6 +565,11 @@ static PyObject * importer(PyObject *self, PyObject *args)
Py_Return;
}
static PyObject * open(PyObject *self, PyObject *args)
{
return importer(self, args);
}
static PyObject * exporter(PyObject *self, PyObject *args)
{
PyObject* object;
@ -946,6 +955,8 @@ static PyObject * ocaf(PyObject *self, PyObject *args)
/* registration table */
struct PyMethodDef ImportGui_Import_methods[] = {
{"open" ,open ,METH_VARARGS,
"open(string) -- Open the file and create a new document."},
{"insert" ,importer ,METH_VARARGS,
"insert(string,string) -- Insert the file into the given document."},
{"export" ,exporter ,METH_VARARGS,

View File

@ -29,5 +29,5 @@
# Append the open handler
#FreeCAD.addImportType("STEP 214 (*.step *.stp)","ImportGui")
FreeCAD.addExportType("STEP 214 (*.step *.stp)","ImportGui")
#FreeCAD.addExportType("STEP 214 (*.step *.stp)","ImportGui")
#FreeCAD.addExportType("IGES files (*.iges *.igs)","ImportGui")

View File

@ -125,7 +125,7 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
//Handle_XSControl_TransferReader tr = ws->TransferReader();
std::map<int, Quantity_Color> hash_col;
ReadColors(aReader.WS(), hash_col);
//ReadColors(aReader.WS(), hash_col);
//ReadNames(aReader.WS());
for (Standard_Integer i=1; i<=nbs; i++) {

View File

@ -446,11 +446,9 @@ CmdPartImport::CmdPartImport()
void CmdPartImport::activated(int iMsg)
{
QStringList filter;
filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)");
filter << QObject::tr("STEP (*.stp *.step)");
filter << QObject::tr("STEP AP203 (*.stp *.step)");
filter << QObject::tr("IGES (*.igs *.iges)");
filter << QObject::tr("BREP (*.brp *.brep)");
filter << QObject::tr("All Files (*.*)");
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
if (!fn.isEmpty()) {
@ -459,9 +457,7 @@ void CmdPartImport::activated(int iMsg)
if (!pDoc) return; // no document
openCommand("Import Part");
QString ext = QFileInfo(fn).suffix().toLower();
if (ext == QLatin1String("step") ||
ext == QLatin1String("stp") ||
ext == QLatin1String("iges") ||
if (ext == QLatin1String("iges") ||
ext == QLatin1String("igs")) {
doCommand(Doc, "import ImportGui");
doCommand(Doc, "ImportGui.insert(\"%s\",\"%s\")", (const char*)fn.toUtf8(), pDoc->getName());
@ -507,20 +503,16 @@ CmdPartExport::CmdPartExport()
void CmdPartExport::activated(int iMsg)
{
QStringList filter;
filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)");
filter << QObject::tr("STEP (*.stp *.step)");
filter << QObject::tr("STEP AP203 (*.stp *.step)");
filter << QObject::tr("IGES (*.igs *.iges)");
filter << QObject::tr("BREP (*.brp *.brep)");
filter << QObject::tr("All Files (*.*)");
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
if (!fn.isEmpty()) {
App::Document* pDoc = getDocument();
if (!pDoc) return; // no document
QString ext = QFileInfo(fn).suffix().toLower();
if (ext == QLatin1String("step") ||
ext == QLatin1String("stp") ||
ext == QLatin1String("iges") ||
if (ext == QLatin1String("iges") ||
ext == QLatin1String("igs")) {
Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui");
}

View File

@ -43,6 +43,12 @@ ParGrp.SetString("WorkBenchName", "Part Design")
ParGrp.SetString("WorkBenchModule", "PartWorkbench.py")
FreeCAD.addImportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part")
FreeCAD.addExportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part")
#FreeCAD.addImportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part")
#FreeCAD.addExportType("CAD formats (*.igs *.iges *.step *.stp *.brep *.brp)","Part")
FreeCAD.addImportType("BREP format (*.brep *.brp)","Part")
FreeCAD.addExportType("BREP format (*.brep *.brp)","Part")
FreeCAD.addImportType("IGES format (*.iges *.igs)","Part")
FreeCAD.addExportType("IGES format (*.iges *.igs)","Part")
FreeCAD.addImportType("STEP AP214 format (*.step *.stp)","ImportGui")
FreeCAD.addExportType("STEP AP214 format (*.step *.stp)","ImportGui")