From 6557f3d1944604fb80a7c7219a43f22529849f64 Mon Sep 17 00:00:00 2001 From: Jeremy Wright Date: Fri, 12 Dec 2014 17:10:48 -0500 Subject: [PATCH] Fixed a bug with a blank filename being set for the previous filename and appended the script's directory to sys.path to enable the use of project directories later. --- CadQuery/Gui/Command.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CadQuery/Gui/Command.py b/CadQuery/Gui/Command.py index 9329d17..687baa9 100644 --- a/CadQuery/Gui/Command.py +++ b/CadQuery/Gui/Command.py @@ -118,6 +118,8 @@ class CadQueryOpenScript(): # return True def Activated(self): + import sys + mw = FreeCADGui.getMainWindow() #Try to keep track of the previous path used to open as a convenience to the user @@ -132,10 +134,13 @@ class CadQueryOpenScript(): filename = QtGui.QFileDialog.getOpenFileName(mw, mw.tr("Open CadQuery Script"), self.previousPath, mw.tr("CadQuery Files (*.py)")) - self.previousPath = filename[0] - #Make sure the user didn't click cancel if filename[0]: + self.previousPath = filename[0] + + #Append this script's directory to sys.path + sys.path.append(os.path.dirname(filename[0])) + #We've created a library that FreeCAD can use as well to open CQ files ImportCQ.open(filename[0])