diff --git a/src/Mod/Drawing/Gui/Command.cpp b/src/Mod/Drawing/Gui/Command.cpp index 995f02ed6a..7266f780a4 100644 --- a/src/Mod/Drawing/Gui/Command.cpp +++ b/src/Mod/Drawing/Gui/Command.cpp @@ -74,7 +74,11 @@ void CmdDrawingOpen::activated(int iMsg) { // load the file with the module Command::doCommand(Command::Gui, "import Drawing, DrawingGui"); +#if PY_MAJOR_VERSION < 3 Command::doCommand(Command::Gui, "DrawingGui.open(unicode(\"%s\",\"utf-8\"))", (const char*)filename.toUtf8()); +#else + Command::doCommand(Command::Gui, "DrawingGui.open(\"%s\")", (const char*)filename.toUtf8()); +#endif } } @@ -593,7 +597,11 @@ void CmdDrawingSymbol::activated(int iMsg) std::string FeatName = getUniqueObjectName("Symbol"); openCommand("Create Symbol"); doCommand(Doc,"import Drawing"); +#if PY_MAJOR_VERSION < 3 doCommand(Doc,"f = open(unicode(\"%s\",'utf-8'),'r')",(const char*)filename.toUtf8()); +#else + doCommand(Doc,"f = open(\"%s\",'r')",(const char*)filename.toUtf8()); +#endif doCommand(Doc,"svg = f.read()"); doCommand(Doc,"f.close()"); doCommand(Doc,"App.activeDocument().addObject('Drawing::FeatureViewSymbol','%s')",FeatName.c_str()); @@ -649,7 +657,11 @@ void CmdDrawingExportPage::activated(int iMsg) doCommand(Doc,"PageFile = open(App.activeDocument().%s.PageResult,'r')",Sel[0].FeatName); std::string fname = (const char*)fn.toUtf8(); +#if PY_MAJOR_VERSION < 3 doCommand(Doc,"OutFile = open(unicode(\"%s\",'utf-8'),'w')",fname.c_str()); +#else + doCommand(Doc,"OutFile = open(\"%s\",'w')",fname.c_str()); +#endif doCommand(Doc,"OutFile.write(PageFile.read())"); doCommand(Doc,"del OutFile,PageFile"); diff --git a/src/Mod/Raytracing/Gui/Command.cpp b/src/Mod/Raytracing/Gui/Command.cpp index f1baba1440..cf0f6c63e8 100644 --- a/src/Mod/Raytracing/Gui/Command.cpp +++ b/src/Mod/Raytracing/Gui/Command.cpp @@ -260,7 +260,11 @@ void CmdRaytracingWriteView::activated(int) openCommand("Write view"); doCommand(Doc,"import Raytracing,RaytracingGui"); +#if PY_MAJOR_VERSION < 3 doCommand(Doc,"OutFile = open(unicode(\"%s\",\"utf-8\"),\"w\")",cFullName.c_str()); +#else + doCommand(Doc,"OutFile = open(\"%s\",\"w\")",cFullName.c_str()); +#endif try { doCommand(Doc,"result = open(App.getResourceDir()+'Mod/Raytracing/Templates/ProjectStd.pov').read()"); doCommand(Doc,"content = ''"); @@ -550,7 +554,11 @@ void CmdRaytracingExportProject::activated(int) doCommand(Doc,"PageFile = open(App.activeDocument().%s.PageResult,'r')",Sel[0].FeatName); std::string fname = (const char*)fn.toUtf8(); +#if PY_MAJOR_VERSION < 3 doCommand(Doc,"OutFile = open(unicode('%s','utf-8'),'w')",fname.c_str()); +#else + doCommand(Doc,"OutFile = open('%s','w')",fname.c_str()); +#endif doCommand(Doc,"OutFile.write(PageFile.read())"); doCommand(Doc,"del OutFile,PageFile"); diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index fcf295a045..56583ceac9 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -913,7 +913,11 @@ void CmdTechDrawSymbol::activated(int iMsg) { std::string FeatName = getUniqueObjectName("Symbol"); openCommand("Create Symbol"); +#if PY_MAJOR_VERSION < 3 doCommand(Doc,"f = open(unicode(\"%s\",'utf-8'),'r')",(const char*)filename.toUtf8()); +#else + doCommand(Doc,"f = open(\"%s\",'r')",(const char*)filename.toUtf8()); +#endif doCommand(Doc,"svg = f.read()"); doCommand(Doc,"f.close()"); doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewSymbol','%s')",FeatName.c_str());