Finished fixing dash support in filenames.
This commit is contained in:
parent
a198182e15
commit
0661191ff8
|
@ -104,7 +104,7 @@ class CadQueryCloseScript:
|
|||
|
||||
Shared.closeActiveCodeWindow()
|
||||
|
||||
class CadQueryExecuteExample:
|
||||
class CadQueryOpenExample:
|
||||
exFile = None
|
||||
|
||||
def __init__(self, exFile):
|
||||
|
|
11
Helpers.py
11
Helpers.py
|
@ -1,4 +1,5 @@
|
|||
# (c) 2014-2016 Jeremy Wright Apache 2.0 License
|
||||
import sys
|
||||
|
||||
def show(cqObject, rgba=(204, 204, 204, 0.0)):
|
||||
import FreeCAD
|
||||
|
@ -24,14 +25,20 @@ def show(cqObject, rgba=(204, 204, 204, 0.0)):
|
|||
docname = os.path.splitext(os.path.basename(cqCodePane.file.path))[0]
|
||||
|
||||
# Make sure we replace any troublesome characters
|
||||
for ch in ['&', '#', '.', '-', '$', '%', ',', ' ']:
|
||||
for ch in ['&', '#', '.', '$', '%', ',', ' ']:
|
||||
if ch in docname:
|
||||
docname = docname.replace(ch, "")
|
||||
|
||||
# Translate dashes so that they can be safetly used since theyare common
|
||||
if '-' in docname:
|
||||
docname = docname.replace('-', "__")
|
||||
|
||||
# If the matching 3D view has been closed, we need to open a new one
|
||||
try:
|
||||
FreeCAD.getDocument(docname)
|
||||
except:
|
||||
except NameError:
|
||||
# FreeCAD.Console.PrintError("Could not find the model document or invalid characters were used in the filename.\r\n")
|
||||
|
||||
FreeCAD.newDocument(docname)
|
||||
|
||||
ad = FreeCAD.activeDocument()
|
||||
|
|
|
@ -118,6 +118,6 @@ FreeCADGui.addCommand('CadQueryClearOutput', CadQueryClearOutput())
|
|||
# Step through and add an Examples submenu item for each example
|
||||
dirs = CadQueryWorkbench.ListExamples()
|
||||
for curFile in dirs:
|
||||
FreeCADGui.addCommand(curFile, CadQueryExecuteExample(curFile))
|
||||
FreeCADGui.addCommand(curFile, CadQueryOpenExample(curFile))
|
||||
|
||||
FreeCADGui.addWorkbench(CadQueryWorkbench())
|
||||
|
|
12
Shared.py
12
Shared.py
|
@ -14,6 +14,10 @@ def clearActiveDocument():
|
|||
return
|
||||
winName = currentWin.windowTitle().split(" ")[0].split('.')[0]
|
||||
|
||||
# Translate dashes so that they can be safetly used since theyare common
|
||||
if '-' in winName:
|
||||
winName= winName.replace('-', "__")
|
||||
|
||||
try:
|
||||
doc = FreeCAD.getDocument(winName)
|
||||
|
||||
|
@ -35,11 +39,17 @@ def getActiveCodePane():
|
|||
# If our current subwindow doesn't contain a script, we need to find the one that does
|
||||
mdiWin = mdi.currentSubWindow()
|
||||
if mdiWin == None: return None # We need to warn the caller that there is no code pane
|
||||
|
||||
windowTitle = mdiWin.windowTitle()
|
||||
|
||||
if mdiWin == 0 or ".py" not in mdiWin.windowTitle():
|
||||
if '__' in mdiWin.windowTitle():
|
||||
windowTitle = mdiWin.windowTitle().replace("__", '-')
|
||||
|
||||
subList = mdi.subWindowList()
|
||||
|
||||
for sub in subList:
|
||||
if sub.windowTitle() == mdiWin.windowTitle().split(" ")[0] + ".py":
|
||||
if sub.windowTitle() == windowTitle.split(" ")[0] + ".py":
|
||||
mdiWin = sub
|
||||
|
||||
winName = mdiWin.windowTitle().split('.')[0]
|
||||
|
|
Loading…
Reference in New Issue
Block a user