Added SaveCopy command
This command saves a copy of the current document under a new name, without modifying the document itself. Available in menu File -> Save a Copy or from python with FreeCAD.ActiveDocument.saveCopy(filename)
This commit is contained in:
@@ -88,6 +88,25 @@ PyObject* DocumentPy::saveAs(PyObject * args)
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* DocumentPy::saveCopy(PyObject * args)
|
||||
{
|
||||
char* fn;
|
||||
if (!PyArg_ParseTuple(args, "s", &fn)) // convert args: Python->C
|
||||
return NULL; // NULL triggers exception
|
||||
if (!getDocumentPtr()->saveCopy(fn)) {
|
||||
PyErr_Format(PyExc_ValueError, "Object attribute 'FileName' is not set");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Base::FileInfo fi(fn);
|
||||
if (!fi.isReadable()) {
|
||||
PyErr_Format(PyExc_IOError, "No such file or directory: '%s'", fn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
|
||||
PyObject* DocumentPy::load(PyObject * args)
|
||||
{
|
||||
char* filename=0;
|
||||
|
||||
Reference in New Issue
Block a user