0000832: Original color STEP model lost in import
This commit is contained in:
parent
bcddb1e950
commit
f403295ca7
|
@ -480,20 +480,24 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
/* module functions */
|
/* module functions */
|
||||||
|
|
||||||
static PyObject * importer(PyObject *self, PyObject *args)
|
static PyObject * importer(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
const char* Name;
|
char* Name;
|
||||||
const char* DocName;
|
char* DocName=0;
|
||||||
if (!PyArg_ParseTuple(args, "ss",&Name,&DocName))
|
if (!PyArg_ParseTuple(args, "s|s",&Name,&DocName))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
PY_TRY {
|
PY_TRY {
|
||||||
//Base::Console().Log("Insert in Part with %s",Name);
|
//Base::Console().Log("Insert in Part with %s",Name);
|
||||||
Base::FileInfo file(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) {
|
if (!pcDoc) {
|
||||||
pcDoc = App::GetApplication().newDocument(DocName);
|
pcDoc = App::GetApplication().newDocument("Unnamed");
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
|
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
|
||||||
|
@ -561,6 +565,11 @@ static PyObject * importer(PyObject *self, PyObject *args)
|
||||||
Py_Return;
|
Py_Return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject * open(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
return importer(self, args);
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject * exporter(PyObject *self, PyObject *args)
|
static PyObject * exporter(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject* object;
|
PyObject* object;
|
||||||
|
@ -946,6 +955,8 @@ static PyObject * ocaf(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
/* registration table */
|
/* registration table */
|
||||||
struct PyMethodDef ImportGui_Import_methods[] = {
|
struct PyMethodDef ImportGui_Import_methods[] = {
|
||||||
|
{"open" ,open ,METH_VARARGS,
|
||||||
|
"open(string) -- Open the file and create a new document."},
|
||||||
{"insert" ,importer ,METH_VARARGS,
|
{"insert" ,importer ,METH_VARARGS,
|
||||||
"insert(string,string) -- Insert the file into the given document."},
|
"insert(string,string) -- Insert the file into the given document."},
|
||||||
{"export" ,exporter ,METH_VARARGS,
|
{"export" ,exporter ,METH_VARARGS,
|
||||||
|
|
|
@ -29,5 +29,5 @@
|
||||||
|
|
||||||
# Append the open handler
|
# Append the open handler
|
||||||
#FreeCAD.addImportType("STEP 214 (*.step *.stp)","ImportGui")
|
#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")
|
#FreeCAD.addExportType("IGES files (*.iges *.igs)","ImportGui")
|
||||||
|
|
|
@ -125,7 +125,7 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
|
||||||
//Handle_XSControl_TransferReader tr = ws->TransferReader();
|
//Handle_XSControl_TransferReader tr = ws->TransferReader();
|
||||||
|
|
||||||
std::map<int, Quantity_Color> hash_col;
|
std::map<int, Quantity_Color> hash_col;
|
||||||
ReadColors(aReader.WS(), hash_col);
|
//ReadColors(aReader.WS(), hash_col);
|
||||||
//ReadNames(aReader.WS());
|
//ReadNames(aReader.WS());
|
||||||
|
|
||||||
for (Standard_Integer i=1; i<=nbs; i++) {
|
for (Standard_Integer i=1; i<=nbs; i++) {
|
||||||
|
|
|
@ -446,11 +446,9 @@ CmdPartImport::CmdPartImport()
|
||||||
void CmdPartImport::activated(int iMsg)
|
void CmdPartImport::activated(int iMsg)
|
||||||
{
|
{
|
||||||
QStringList filter;
|
QStringList filter;
|
||||||
filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)");
|
filter << QObject::tr("STEP AP203 (*.stp *.step)");
|
||||||
filter << QObject::tr("STEP (*.stp *.step)");
|
|
||||||
filter << QObject::tr("IGES (*.igs *.iges)");
|
filter << QObject::tr("IGES (*.igs *.iges)");
|
||||||
filter << QObject::tr("BREP (*.brp *.brep)");
|
filter << QObject::tr("BREP (*.brp *.brep)");
|
||||||
filter << QObject::tr("All Files (*.*)");
|
|
||||||
|
|
||||||
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
|
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
|
||||||
if (!fn.isEmpty()) {
|
if (!fn.isEmpty()) {
|
||||||
|
@ -459,9 +457,7 @@ void CmdPartImport::activated(int iMsg)
|
||||||
if (!pDoc) return; // no document
|
if (!pDoc) return; // no document
|
||||||
openCommand("Import Part");
|
openCommand("Import Part");
|
||||||
QString ext = QFileInfo(fn).suffix().toLower();
|
QString ext = QFileInfo(fn).suffix().toLower();
|
||||||
if (ext == QLatin1String("step") ||
|
if (ext == QLatin1String("iges") ||
|
||||||
ext == QLatin1String("stp") ||
|
|
||||||
ext == QLatin1String("iges") ||
|
|
||||||
ext == QLatin1String("igs")) {
|
ext == QLatin1String("igs")) {
|
||||||
doCommand(Doc, "import ImportGui");
|
doCommand(Doc, "import ImportGui");
|
||||||
doCommand(Doc, "ImportGui.insert(\"%s\",\"%s\")", (const char*)fn.toUtf8(), pDoc->getName());
|
doCommand(Doc, "ImportGui.insert(\"%s\",\"%s\")", (const char*)fn.toUtf8(), pDoc->getName());
|
||||||
|
@ -507,20 +503,16 @@ CmdPartExport::CmdPartExport()
|
||||||
void CmdPartExport::activated(int iMsg)
|
void CmdPartExport::activated(int iMsg)
|
||||||
{
|
{
|
||||||
QStringList filter;
|
QStringList filter;
|
||||||
filter << QObject::tr("All CAD Files (*.stp *.step *.igs *.iges *.brp *.brep)");
|
filter << QObject::tr("STEP AP203 (*.stp *.step)");
|
||||||
filter << QObject::tr("STEP (*.stp *.step)");
|
|
||||||
filter << QObject::tr("IGES (*.igs *.iges)");
|
filter << QObject::tr("IGES (*.igs *.iges)");
|
||||||
filter << QObject::tr("BREP (*.brp *.brep)");
|
filter << QObject::tr("BREP (*.brp *.brep)");
|
||||||
filter << QObject::tr("All Files (*.*)");
|
|
||||||
|
|
||||||
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
|
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
|
||||||
if (!fn.isEmpty()) {
|
if (!fn.isEmpty()) {
|
||||||
App::Document* pDoc = getDocument();
|
App::Document* pDoc = getDocument();
|
||||||
if (!pDoc) return; // no document
|
if (!pDoc) return; // no document
|
||||||
QString ext = QFileInfo(fn).suffix().toLower();
|
QString ext = QFileInfo(fn).suffix().toLower();
|
||||||
if (ext == QLatin1String("step") ||
|
if (ext == QLatin1String("iges") ||
|
||||||
ext == QLatin1String("stp") ||
|
|
||||||
ext == QLatin1String("iges") ||
|
|
||||||
ext == QLatin1String("igs")) {
|
ext == QLatin1String("igs")) {
|
||||||
Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui");
|
Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,12 @@ ParGrp.SetString("WorkBenchName", "Part Design")
|
||||||
ParGrp.SetString("WorkBenchModule", "PartWorkbench.py")
|
ParGrp.SetString("WorkBenchModule", "PartWorkbench.py")
|
||||||
|
|
||||||
|
|
||||||
FreeCAD.addImportType("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.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")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user