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:
@@ -1001,6 +1001,24 @@ bool Document::saveAs(const char* file)
|
||||
return save();
|
||||
}
|
||||
|
||||
bool Document::saveCopy(const char* file)
|
||||
{
|
||||
std::string originalFileName = this->FileName.getStrValue();
|
||||
std::string originalLabel = this->Label.getStrValue();
|
||||
Base::FileInfo fi(file);
|
||||
if (this->FileName.getStrValue() != file) {
|
||||
this->FileName.setValue(file);
|
||||
this->Label.setValue(fi.fileNamePure());
|
||||
this->Uid.touch(); // this forces a rename of the transient directory
|
||||
bool result = save();
|
||||
this->FileName.setValue(originalFileName);
|
||||
this->Label.setValue(originalLabel);
|
||||
this->Uid.touch();
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save the document under the name it has been opened
|
||||
bool Document::save (void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user