From c319b4f7f0e87e891f18f8ebe5a41744f7b7979d Mon Sep 17 00:00:00 2001 From: Jeremy Mack Wright Date: Sun, 31 Jul 2016 23:36:22 -0400 Subject: [PATCH] Added a safety feature to remove bad characters from the file name before trying to create or update the 3D document view. --- CadQuery/Gui/Command.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CadQuery/Gui/Command.py b/CadQuery/Gui/Command.py index 3a15105..1e7f716 100644 --- a/CadQuery/Gui/Command.py +++ b/CadQuery/Gui/Command.py @@ -166,7 +166,12 @@ class CadQueryExecuteScript: docname = os.path.splitext(os.path.basename(cqCodePane.file.path))[0] - #If the matching 3D view has been closed, we need to open a new one + # Make sure we replace any troublesome characters + for ch in ['&', '#', '.', '-', '$', '%', ',', ' ']: + if ch in docname: + docname = docname.replace(ch, "") + + # If the matching 3D view has been closed, we need to open a new one try: FreeCAD.getDocument(docname) except: