Improved the open and close script functionality to help ensure a better and more integrated workflow.
This commit is contained in:
parent
544faacaf2
commit
3d3f640dae
|
@ -75,18 +75,7 @@ class CadQueryCloseScript:
|
||||||
if filename is not None:
|
if filename is not None:
|
||||||
ExportCQ.save(filename)
|
ExportCQ.save(filename)
|
||||||
|
|
||||||
# Close the matching 3D view if it's open
|
Shared.closeActiveCodeWindow()
|
||||||
if cqCodePane.file.path is not None:
|
|
||||||
docname = os.path.splitext(os.path.basename(cqCodePane.file.path))[0]
|
|
||||||
|
|
||||||
try:
|
|
||||||
FreeCAD.closeDocument(docname)
|
|
||||||
except:
|
|
||||||
# Assume that the document has already been closed
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Clear our script and whatever was rendered by it out
|
|
||||||
cqCodePane.file.close()
|
|
||||||
|
|
||||||
class CadQueryExecuteExample:
|
class CadQueryExecuteExample:
|
||||||
exFile = None
|
exFile = None
|
||||||
|
@ -214,9 +203,6 @@ class CadQueryOpenScript:
|
||||||
|
|
||||||
# Make sure the user didn't click cancel
|
# Make sure the user didn't click cancel
|
||||||
if filename[0]:
|
if filename[0]:
|
||||||
# We need to close any file that's already open in the editor window
|
|
||||||
CadQueryCloseScript().Activated()
|
|
||||||
|
|
||||||
self.previousPath = filename[0]
|
self.previousPath = filename[0]
|
||||||
|
|
||||||
# Append this script's directory to sys.path
|
# Append this script's directory to sys.path
|
||||||
|
|
|
@ -45,9 +45,7 @@ def getActiveCodePane():
|
||||||
return cqCodePane
|
return cqCodePane
|
||||||
|
|
||||||
|
|
||||||
def getActiveCodeWindow():
|
def closeActiveCodeWindow():
|
||||||
"""Gets the currently active code window (that holds the pane), even if the associated 3D view window has focus"""
|
|
||||||
|
|
||||||
mw = FreeCADGui.getMainWindow()
|
mw = FreeCADGui.getMainWindow()
|
||||||
mdi = mw.findChild(QtGui.QMdiArea)
|
mdi = mw.findChild(QtGui.QMdiArea)
|
||||||
|
|
||||||
|
@ -59,11 +57,11 @@ def getActiveCodeWindow():
|
||||||
subList = mdi.subWindowList()
|
subList = mdi.subWindowList()
|
||||||
|
|
||||||
for sub in subList:
|
for sub in subList:
|
||||||
if sub.windowTitle() == mdiWin.windowTitle() + ".py":
|
if sub.windowTitle() == mdiWin.windowTitle().split(" ")[0] + ".py":
|
||||||
mdiWin = sub
|
sub.close()
|
||||||
|
return
|
||||||
return mdiWin
|
|
||||||
|
|
||||||
|
mdiWin.close()
|
||||||
|
|
||||||
def setActiveWindowTitle(title):
|
def setActiveWindowTitle(title):
|
||||||
"""Sets the title of the currently active MDI window, as long as it is a scripting window"""
|
"""Sets the title of the currently active MDI window, as long as it is a scripting window"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user