Simple concatenated text in openscad to freecad issue

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Posts: 34
Joined: Sun May 09, 2021 1:14 am

Simple concatenated text in openscad to freecad issue

Postby Yuri » Mon May 24, 2021 11:45 pm

I tried to find an answer online but couldn't.


Code: Select all

OS: Windows 10 Version 2004
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24276 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: a88db11e0a908f6e38f92bfc5187b13ebe470438
Python version: 3.8.6+
Qt version: 5.15.1
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/Canada (en_CA)
and in 0.184 too in the same system
The code below from OpenScad

Code: Select all

         module Test(Sym = false, Left = 40, Rgt = 10){  
          text(valor, size = 2, halign = "center", valign = "center"); valor = (Sym) ? str(Left,"/", Left): str(Left, "/", Rgt);} 
          Test(Sym = false, Left = 40, Rgt = 10);   
produces a 1 mm extrusion of the text 40/10.
When I attempt to open it in FC 0.191 and 0.184 I get:

Code: Select all

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files\FreeCAD 0.19\Mod\OpenSCAD\", line 119, in open
  File "C:\Program Files\FreeCAD 0.19\Mod\OpenSCAD\", line 177, in processcsg
    result = parser.parse(
  File "C:\Program Files\FreeCAD 0.19\bin\lib\site-packages\ply\", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "C:\Program Files\FreeCAD 0.19\bin\lib\site-packages\ply\", line 1120, in parseopt_notrack
  File "C:\Program Files\FreeCAD 0.19\Mod\OpenSCAD\", line 1220, in p_text_action
    t = addString(t,'script',p)
  File "C:\Program Files\FreeCAD 0.19\Mod\OpenSCAD\", line 1203, in addString
    return(t + ', ' +s+' = "'+p[3][s]+'"')
<class 'KeyError'>: 'script'
Would it be doable to obtain this text in FC as is in scad?

By the way, how do one make a one time contribution? Why is that option not available on your donations page?
Posts: 34
Joined: Sun May 09, 2021 1:14 am

Re: Simple concatenated text in openscad to freecad issue

Postby Yuri » Wed May 26, 2021 6:51 pm

For the text to be properly imported by FC 0.191 there must be at least 1 letter in the text. The position of the letter does not seem to matter. Punctuation and/or other symbols without a letter will break the import.

Thus 40I10 is properly fetched by FC which puts out a fire. Then the next fire comes: if I have a compound object and then try to subtract the text as in engraving, I get a resulting shape is invalid and an asterisk in the tree.

This fire was put out by subtracting the text to a primary ("primitive") first object and doing the rest of the compound object later.