[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

Postby RM. » Wed Feb 08, 2017 4:15 am

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
Posts: 16953
Joined: Tue Mar 17, 2015 9:14 am

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

Postby chrisb » Wed Feb 08, 2017 6:21 am

From which repository do you install?
Please try deleting your config files, i.e. the directory ~/.FreeCAD.
RM.
Posts: 3
Joined: Wed Feb 08, 2017 4:12 am

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

Postby RM. » Wed Feb 08, 2017 6:55 pm

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
wmayer
Site Admin
Posts: 14479
Joined: Thu Feb 19, 2009 10:32 am

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

Postby wmayer » Wed Feb 08, 2017 8:00 pm

RM.
Posts: 3
Joined: Wed Feb 08, 2017 4:12 am

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

Postby RM. » Wed Feb 08, 2017 11:55 pm

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
Posts: 18534
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

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

Postby NormandC » Thu Feb 09, 2017 12:35 am

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
Site Admin
Posts: 14479
Joined: Thu Feb 19, 2009 10:32 am

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

Postby wmayer » Thu Feb 09, 2017 8:50 am

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
Site Admin
Posts: 14479
Joined: Thu Feb 19, 2009 10:32 am

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

Postby wmayer » Thu Feb 09, 2017 11:34 am

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
Posts: 4812
Joined: Thu Jan 05, 2017 9:03 pm

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

Postby Kunda1 » Thu Feb 09, 2017 12:01 pm

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 :)
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
ulrich1a
Posts: 1872
Joined: Sun Jul 07, 2013 12:08 pm

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

Postby ulrich1a » Sat Feb 11, 2017 6:59 pm

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