[solved] Type.Error - Sketching is impossible

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!
RM.
Posts: 3
Joined: Wed Feb 08, 2017 4:12 am

[solved] Type.Error - Sketching is impossible

Post by RM. »

Bug-Ticket: https://freecadweb.org/tracker/view.php?id=2891#c8233

OS: Debian GNU/Linux 9.0 (stretch)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.
Build type: None
Python version: 2.7.13
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

Kernel: Linux 4.9.2-2-amd64

Installed via: apt-get install freecad


short description:

If i click on "Create a new sketch", i receive everytime the following error message:

Traceback (most recent call last):
File "<string>", line 1, in <module>
<type 'exceptions.TypeError'>: Either three floats, tuple or Vector expected

and i can't create anything in the sketcher. For example, if i wan't to draw a line it put's the error message:

Failed to add line: Either three floats, tuple or Vector expected
Failed to add line: ('invalid token', ('<string>', 1, 99, 'App.ActiveDocument.Sketch.addGeometry(Part.Line(App.Vector(0,000000,0,000000,0),App.Vector(2,003810,1,106270,0)),False)\n'))

or the error message if i wan't to draw a circle:

Failed to add circle: Either three floats, tuple or Vector expected


Steps To Reproduce
1) Start FreeCAD
2) Start Sketcher
3) Click on "Create new sketch" <---the "typeError"-Exception appears
4) Click on "Line" or "Circle"
5) Draw a "Line" or "Circle" <---the "Failed to add"-Error message appears
Last edited by RM. on Wed Feb 08, 2017 11:56 pm, edited 1 time in total.
chrisb
Veteran
Posts: 53920
Joined: Tue Mar 17, 2015 9:14 am

Re: [bug] Type.Error - Sketching is impossible

Post by chrisb »

From which repository do you install?
Please try deleting your config files, i.e. the directory ~/.FreeCAD.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
RM.
Posts: 3
Joined: Wed Feb 08, 2017 4:12 am

Re: [bug] Type.Error - Sketching is impossible

Post by RM. »

1) my repository configuration is:

Code: Select all

#/etc/apt/sources.list
deb http://ftp.de.debian.org/debian/ testing main contrib non-free
deb-src http://ftp.de.debian.org/debian/ testing main contrib non-free
2) same error, if i delete both config file

Code: Select all

.FreeCAD/system.cfg
.FreeCAD/user.cfg
RM.
Posts: 3
Joined: Wed Feb 08, 2017 4:12 am

Re: [bug] Type.Error - Sketching is impossible

Post by RM. »

solved.

It was the locale problem (point vs. comma)

workaround-script, to start freeCAD:

Code: Select all

#!/bin/bash
export LC_ALL=C
freecad $1 $2 $3 $4 $5
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: [solved] Type.Error - Sketching is impossible

Post by NormandC »

wmayer,

My system's decimal separator is a comma as well. How come I've never had this issue?

OS: Ubuntu 14.04.5 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6707 (Git)
Build type: None
Branch: releases/FreeCAD-0-16
Hash: 5465bc47c95db45e0be85dc0e2872419efadce0f
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

EDIT:

Code: Select all

$ locale
LANG=fr_CA.UTF-8
LANGUAGE=fr_CA:fr
LC_CTYPE="fr_CA.UTF-8"
LC_NUMERIC="fr_CA.UTF-8"
LC_TIME="fr_CA.UTF-8"
LC_COLLATE="fr_CA.UTF-8"
LC_MONETARY="fr_CA.UTF-8"
LC_MESSAGES="fr_CA.UTF-8"
LC_PAPER="fr_CA.UTF-8"
LC_NAME="fr_CA.UTF-8"
LC_ADDRESS="fr_CA.UTF-8"
LC_TELEPHONE="fr_CA.UTF-8"
LC_MEASUREMENT="fr_CA.UTF-8"
LC_IDENTIFICATION="fr_CA.UTF-8"
LC_ALL=
wmayer
Founder
Posts: 20242
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [solved] Type.Error - Sketching is impossible

Post by wmayer »

My system's decimal separator is a comma as well. How come I've never had this issue?
Here it's said that
LC_ALL
This variable determines the values for all locale categories. The value of the LC_ALL environment variable has precedence over any of the other environment variables starting with LC_ (LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME) and the LANG environment variable.
Now on Ubuntu systems LC_ALL is not set so that LC_NUMERIC and others take effect. To make sure that for C functions used inside FreeCAD the right locale is used we set at the beginning of the main() function LC_NUMERIC to "C".

On Debian systems it seems that LC_ALL is set so that our change LC_NUMERIC=C alone is useless.

In v0.17, however, we don't get the point vs. comma problem at all and I assume it's due to the change git commit 3c269f4cc.
wmayer
Founder
Posts: 20242
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [solved] Type.Error - Sketching is impossible

Post by wmayer »

I stumbled across this interesting comment of the Qt documentation which proves that Qt is causing all the trouble.
On Unix/Linux Qt is configured to use the system locale settings by default. This can cause a conflict when using POSIX functions, for instance, when converting between data types such as floats and strings, since the notation may differ between locales. To get around this problem, call the POSIX function setlocale(LC_NUMERIC,"C") right after initializing QApplication, QGuiApplication or QCoreApplication to reset the locale that is used for number formatting to "C"-locale.
(FYI, this applies to all previous Qt versions, too -- not just Qt5.)

QCoreApplication internally calls setlocale(LC_ALL,"") which causes to take effect the system settings and that's why the call of LC_NUMERIC=C in the main() function (which is called long before QCoreApplication) is useless when the system environment variable LC_ALL is set (and defines a language using a comma as decimal separator).
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [solved] Type.Error - Sketching is impossible

Post by Kunda1 »

wmayer wrote:I stumbled across this interesting comment of the Qt documentation which proves that Qt is causing all the trouble.
On Unix/Linux Qt is configured to use the system locale settings by default. This can cause a conflict when using POSIX functions, for instance, when converting between data types such as floats and strings, since the notation may differ between locales. To get around this problem, call the POSIX function setlocale(LC_NUMERIC,"C") right after initializing QApplication, QGuiApplication or QCoreApplication to reset the locale that is used for number formatting to "C"-locale.
(FYI, this applies to all previous Qt versions, too -- not just Qt5.)

QCoreApplication internally calls setlocale(LC_ALL,"") which causes to take effect the system settings and that's why the call of LC_NUMERIC=C in the main() function (which is called long before QCoreApplication) is useless when the system environment variable LC_ALL is set (and defines a language using a comma as decimal separator).
Score :)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: [solved] Type.Error - Sketching is impossible

Post by ulrich1a »

wmayer wrote:On Debian systems it seems that LC_ALL is set so that our change LC_NUMERIC=C alone is useless.
At least my Debian did not set LC_ALL. But it could be, that it is different with other configurations.
But now commit http://github.com/FreeCAD/FreeCAD/commit/6c2a7b4 causes a problem with FEM, see here: https://forum.freecadweb.org/viewtopic.php?f=18&t=20600

How can I check, if the new conditional code was compiled?

Ulrich
Post Reply