Pi Tower creation

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!
mario52
Veteran
Posts: 4672
Joined: Wed May 16, 2012 2:13 pm

Re: Pi Tower creation

Post by mario52 »

hi wandererfan
the path for ShapeString not accept caracteres over 128

DraftGui.pickFile: unable to select a font file.<type 'exceptions.UnicodeEncodeError'>
('ascii', u'C:/Tmp/ATest\xe9\xe0\xe8\xf9%/m\xe9m\xe8retyty/\xeatr\xe0\xe7\xe9\xe8\xe8!!\xa3$/arial.ttf', 22, 26, 'ordinal not in range(128)')


i modify this line (Draft 5076)

Code: Select all

#                CharList = Part.makeWireString(obj.String,obj.FontFile,obj.Size,obj.Tracking)
to (obj.FontFile.encode('utf-8'))

Code: Select all

                CharList = Part.makeWireString(obj.String,obj.FontFile.encode('utf-8'),obj.Size,obj.Tracking)
there is no error of characters but does not recognize the path
Traceback (most recent call last):
File "C:\Program Files\FreeCAD 0.14\Mod\Draft\Draft.py", line 5085, in execute
CharList = Part.makeWireString(obj.String,fontes,obj.Size,obj.Tracking)
<class 'Part.OCCError'>: Font file not found: C:/tmp/ATestéàèù%/mémèretyty/êtràçéèè!!£$/arial.ttf


mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
shoogen
Veteran
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Pi Tower creation

Post by shoogen »

mario52 wrote:<class 'Part.OCCError'>: Font file not found: C:/tmp/ATestéàèù%/mémèretyty/êtràçéèè!!£$/arial.ttf
You can try .encode('mcbs') instead of encode('utf-8') as a workaround. This will allow to use 8bit filenames instead of 7bit ones.
mario52
Veteran
Posts: 4672
Joined: Wed May 16, 2012 2:13 pm

Re: Pi Tower creation

Post by mario52 »

hi
i try but

Traceback (most recent call last):
File "C:\Program Files\FreeCAD 0.14\Mod\Draft\Draft.py", line 5078, in execute
CharList = Part.makeWireString(obj.String,obj.FontFile.encode('mcbs'),obj.Size,obj.Tracking)
<type 'exceptions.LookupError'>: unknown encoding: mcbs

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
wandererfan
Veteran
Posts: 6238
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Pi Tower creation

Post by wandererfan »

mario52 wrote:the path for ShapeString not accept caracteres over 128
issue #1947
Error in DraftGui conversion of QFileDialog output to Python unicode object.

wf
User avatar
shoogen
Veteran
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: Pi Tower creation

Post by shoogen »

mario52 wrote:<type 'exceptions.LookupError'>: unknown encoding: mcbs
Sorry mario,
"mbcs"
mario52
Veteran
Posts: 4672
Joined: Wed May 16, 2012 2:13 pm

Re: Pi Tower creation

Post by mario52 »

hi
no problem my macro work fine i replace

Code: Select all

App.Console.PrintMessage(str(PolicePath)+"\n")
to

Code: Select all

App.Console.PrintMessage((PolicePath)+"\n")
and we discovered a bug

to show you an example of mistake I made this line and

Code: Select all

pathh = "C:\tmp\ATestéàèù%\mémèretyty\êtràçéèè!!£$\ARIAL.TTF"
App.Console.PrintMessage((pathh)+"\n")      # not error 
App.Console.PrintMessage(str(pathh)+"\n")  # this line was giving an error (day before yesterday)
and today in the View repport

C: mp\ATestéàèù%\mémèretyty\êtràçéèè!!£$\ARIAL.TTF
C: mp\ATestéàèù%\mémèretyty\êtràçéèè!!£$\ARIAL.TTF

no error ?? and or are \t

==============================================
EDIT: 17/02/2015 16h13
for the error \t must \\t

Code: Select all

pathh = "C:\\tmp\ATestéàèù%\mémèretyty\êtràçéèè!!£$\ARIAL.TTF"
App.Console.PrintMessage((pathh)+"\n")
result
C:\tmp\ATestéàèù%\mémèretyty\êtràçéèè!!£$\ARIAL.TTF
\t is interpreted as a command \t=tab (ex: \r \t \n ..)
==============================================

OS: Windows Vista
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.15.4527 (Git)
Branch: master
Hash: 0da2e4c45a9a259c26abd54c2a35393e1c15696f
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.7.1

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply