From ba6fb8fb8e6b3195f61c47620dad85b813fd567c Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Sat, 18 Dec 2021 16:23:25 -0600 Subject: [PATCH] OpenSCAD: Handle missing script element from text() --- .../OpenSCAD/OpenSCADTest/app/test_importCSG.py | 14 +++++++++++++- src/Mod/OpenSCAD/importCSG.py | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Mod/OpenSCAD/OpenSCADTest/app/test_importCSG.py b/src/Mod/OpenSCAD/OpenSCADTest/app/test_importCSG.py index 24dda152a2..f784ffcf9a 100644 --- a/src/Mod/OpenSCAD/OpenSCADTest/app/test_importCSG.py +++ b/src/Mod/OpenSCAD/OpenSCADTest/app/test_importCSG.py @@ -128,7 +128,19 @@ class TestImportCSG(unittest.TestCase): self.assertTrue (text is not None) FreeCAD.closeDocument(doc.Name) except Exception: - pass # We may not have the DXF importer available + return # We may not have the DXF importer available + + # Try a number with a set script: + doc = self.utility_create_scad("text(\"2\",script=\"latin\");","two_text") + text = doc.getObject("text") + self.assertTrue (text is not None) + FreeCAD.closeDocument(doc.Name) + + # Leave off the script (which is supposed to default to "latin") + doc = self.utility_create_scad("text(\"1\");","one_text") + text = doc.getObject("text") + self.assertTrue (text is not None) + FreeCAD.closeDocument(doc.Name) def test_import_polygon_nopath(self): doc = self.utility_create_scad("polygon(points=[[0,0],[100,0],[130,50],[30,50]]);","polygon_nopath") diff --git a/src/Mod/OpenSCAD/importCSG.py b/src/Mod/OpenSCAD/importCSG.py index 9007750f34..9ed133023c 100644 --- a/src/Mod/OpenSCAD/importCSG.py +++ b/src/Mod/OpenSCAD/importCSG.py @@ -1204,7 +1204,10 @@ def p_text_action(p) : t = addString(t,'font',p) t = addString(t,'direction',p) t = addString(t,'language',p) - t = addString(t,'script',p) + if "script" in p[3]: + t = addString(t,'script',p) + else: + t += ', script="latin"' t = addString(t,'halign',p) t = addString(t,'valign',p) t = addValue(t,'$fn',p)