Skip to content

Commit

Permalink
Gui: add support to get exporting options before writing a file
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Oct 4, 2022
1 parent 359ec60 commit 4d719d5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Gui/Application.cpp
Expand Up @@ -694,17 +694,21 @@ void Application::exportTo(const char* FileName, const char* DocName, const char

std::stringstream str;
std::set<App::DocumentObject*> unique_objs;
str << "__objs__=[]" << std::endl;
for (auto it = sel.begin(); it != sel.end(); ++it) {
if (unique_objs.insert(*it).second) {
str << "__objs__ = []\n";
for (auto it : sel) {
if (unique_objs.insert(it).second) {
str << "__objs__.append(FreeCAD.getDocument(\"" << DocName << "\").getObject(\""
<< (*it)->getNameInDocument() << "\"))" << std::endl;
<< it->getNameInDocument() << "\"))\n";
}
}

str << "import " << Module << std::endl;
str << Module << ".export(__objs__,u\"" << unicodepath << "\")" << std::endl;
//str << "del __objs__" << std::endl;
// check for additional export options
str << "import " << Module << '\n';
str << "if hasattr(" << Module << ", \"exportOptions\"):\n"
<< " options = " << Module << ".exportOptions(u\"" << unicodepath << "\")\n"
<< " " << Module << ".export(__objs__, u\"" << unicodepath << "\", options)\n"
<< "else:\n"
<< " " << Module << ".export(__objs__, u\"" << unicodepath << "\")\n";

std::string code = str.str();
// the original file name is required
Expand Down

0 comments on commit 4d719d5

Please sign in to comment.