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