View Issue Details

IDProjectCategoryView StatusLast Update
0002891SketcherBugpublic2017-04-28 12:21
Reporterrm. Assigned Towmayer  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86_64 OSDebianOS Version9 (stretch)
Product Version0.16 
Fixed in Version0.17 
Summary0002891: Sketching impossible, Type.Error Exception
DescriptionOS: 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


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 Reproduce1) 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
Tagslocale
FreeCAD Information

Relationships

has duplicate 0002899 closedkkremitzki FreeCAD Sketcher and Part design - decimal point values ignored 
related to 0001852 closedshoogen FreeCAD The python interpreter does not recognize the posix locale settings 

Activities

rm.

2017-02-06 16:54

reporter  

FreeCAD.log (9,518 bytes)   
Msg: FreeCAD 0.16, Libs: 0.16R
© Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2015
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

Log: Time = Mon Feb  6 17:50:19 2017
Log: AppDataSkipVendor = true
Log: AppHomePath = /usr/lib/freecad/
Log: AppIcon = freecad
Log: AppTempPath = /tmp/
Log: BinPath = /usr/lib/freecad/bin/
Log: BuildRepositoryURL = https://code.launchpad.net/~vcs-imports/freecad/trunk
Log: BuildRevision = 
Log: BuildRevisionDate = 2017/01/20 19:32:28
Log: BuildVersionMajor = 0
Log: BuildVersionMinor = 16
Log: CopyrightInfo = © Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2015
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##


Log: Debug = 0
Log: DocPath = /usr/lib/freecad/doc/
Log: ExeName = FreeCAD
Log: ExeVendor = FreeCAD
Log: ExeVersion = 0.16
Log: LoggingFile = 1
Log: LoggingFileName = /home/rm/.FreeCAD/FreeCAD.log
Log: MaintainerUrl = http://www.freecadweb.org/wiki/index.php?title=Main_Page
Log: PATH = /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/bin:/usr/bin:/bin:/usr/local/java/bin:/home/rm/skripte:/usr/local/ApacheDirectoryStudio
Log: PYTHONPATH = 
Log: PythonSearchPath = :/usr/bin/../lib/python2.7:/usr/bin/../lib/python2.7/plat-x86_64-linux-gnu:/usr/bin/../lib/python2.7/lib-tk:/usr/bin/../lib/python2.7/lib-old:/usr/bin/../lib/python2.7/lib-dynload
Log: RunMode = Gui
Log: SplashAlignment = Bottom|Left
Log: SplashInfoColor = #c8c8c8
Log: SplashScreen = freecadsplash
Log: SplashTextColor = #ffffff
Log: StartWorkbench = StartWorkbench
Log: SystemParameter = /home/rm/.FreeCAD/system.cfg
Log: UserAppData = /home/rm/.FreeCAD/
Log: UserHomePath = /home/rm
Log: UserParameter = /home/rm/.FreeCAD/user.cfg
Log: Verbose = 
Log: Create Application
Log: Run App init script
Log: Init: starting App::FreeCADInit.py
Log: Log: Init:   Searching for modules...
Log: Init:      Initializing /usr/lib/freecad/Mod/Sketcher... done
Log: Init:      Initializing /usr/lib/freecad/Mod/ReverseEngineering... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Image... done
Log: Init:      Initializing /usr/lib/freecad/Mod/PartDesign... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Ship(Init.py not found)... ignore
Log: Init:      Initializing /usr/lib/freecad/Mod/Plot(Init.py not found)... ignore
Log: Init:      Initializing /usr/lib/freecad/Mod/MeshPart... done
Log: Init:      Initializing /usr/lib/freecad/Mod/OpenSCAD... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Fem... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Spreadsheet... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Start... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Points... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Draft... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Test... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Import... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Complete... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Web... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Material... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Raytracing... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Mesh... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Path... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Arch... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Robot... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Part... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Idf... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Inspection... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Drawing... done
Log: Using /usr/lib/freecad/Mod as module path!
Log: Using /usr/lib/freecad/Mod as module path!
Log: System path after init:
Log:    /usr/lib/freecad/bin
Log:    /usr/lib/freecad/Mod/Sketcher
Log:    /usr/lib/freecad/Mod/ReverseEngineering
Log:    /usr/lib/freecad/Mod/Image
Log:    /usr/lib/freecad/Mod/PartDesign
Log:    /usr/lib/freecad/Mod/Ship
Log:    /usr/lib/freecad/Mod/Plot
Log:    /usr/lib/freecad/Mod/MeshPart
Log:    /usr/lib/freecad/Mod/OpenSCAD
Log:    /usr/lib/freecad/Mod/Fem
Log:    /usr/lib/freecad/Mod/Spreadsheet
Log:    /usr/lib/freecad/Mod/Start
Log:    /usr/lib/freecad/Mod/Points
Log:    /usr/lib/freecad/Mod/Draft
Log:    /usr/lib/freecad/Mod/Test
Log:    /usr/lib/freecad/Mod/Import
Log:    /usr/lib/freecad/Mod/Complete
Log:    /usr/lib/freecad/Mod/Web
Log:    /usr/lib/freecad/Mod/Material
Log:    /usr/lib/freecad/Mod/Raytracing
Log:    /usr/lib/freecad/Mod/Mesh
Log:    /usr/lib/freecad/Mod/Path
Log:    /usr/lib/freecad/Mod/Arch
Log:    /usr/lib/freecad/Mod/Robot
Log:    /usr/lib/freecad/Mod/Part
Log:    /usr/lib/freecad/Mod/Idf
Log:    /usr/lib/freecad/Mod/Inspection
Log:    /usr/lib/freecad/Mod/Drawing
Log:    /usr/local/bin
Log:    /usr/bin
Log:    /bin
Log:    /usr/local/games
Log:    /usr/games
Log:    /usr/local/bin
Log:    /usr/bin
Log:    /bin
Log:    /usr/local/java/bin
Log:    /home/rm/skripte
Log:    /usr/local/ApacheDirectoryStudio
Log: Init: App::FreeCADInit.py done
Log: Init: Creating Gui::Application and QApplication
Log: Local server 'FreeCAD' started
Log: OpenGL version 3.0 or higher is present
Log: Run Gui init script
Log: Init: Running FreeCADGuiInit.py start script...
Log: Init:   Searching modules...
Log: Init:      Initializing /usr/lib/freecad/Mod/Sketcher... done
Log: Init:      Initializing /usr/lib/freecad/Mod/ReverseEngineering... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Image... done
Log: Init:      Initializing /usr/lib/freecad/Mod/PartDesign... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Ship... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Plot... done
Log: Init:      Initializing /usr/lib/freecad/Mod/MeshPart... done
Log: Init:      Initializing /usr/lib/freecad/Mod/OpenSCAD... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Fem... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Spreadsheet... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Start... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Points... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Draft... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Test... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Import... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Complete... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Web... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Material... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Raytracing... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Mesh... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Path... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Arch... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Robot... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Part... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Idf(InitGui.py not found)... ignore
Log: Init:      Initializing /usr/lib/freecad/Mod/Inspection... done
Log: Init:      Initializing /usr/lib/freecad/Mod/Drawing... done
Log: Init: Loading FreeCAD GUI
Log: Init: Running FreeCADGuiInit.py start script... done
Log: Init: Activating default workbench StartWorkbench
Log: Loading GUI of Web module... done
Log: Loading GUI of Start module... done
Log: Loading Start module... done
Log: Init: Showing main window
Log: Main window restored
Log: Show main window
Log: Toolbars restored
Log: Couldn't connect to spacenav daemon
Log: Init: Entering event loop
Log: Init: Processing command line files
Log: Active view is Unnamed : 1[*] (at 0x561c01beb5a0)
Log: Active document is Unnamed (at 0x561c01ee9650)
Log: Module: Part
Log: Loading Part module... done
Log: Loading GUI of Part module... done
Log: Loading Sketcher module... done
Log: Loading GUI of Sketcher module... done
Err: Traceback (most recent call last):
  File "<string>", line 1, in <module>
<type 'exceptions.TypeError'>: Either three floats, tuple or Vector expected
Log: Active view is Unnamed : 1[*] (at 0x561c01beb5a0)
Log: Active view is Unnamed : 1[*] (at 0x561c01beb5a0)
Log: Sel : Clear selection
Log: Sketcher::setUpSketch()-T:0
Log: Sketcher::Solve()-DogLeg-T:0
Err: Failed to add line: ('invalid token', ('<string>', 1, 68, 'App.ActiveDocument.Sketch.addGeometry(Part.Line(App.Vector(-2,013087,1,291808,0),App.Vector(1,001905,0,572848,0)),False)\n'))
Err: Failed to add circle: Either three floats, tuple or Vector expected
Log: Sel : Clear selection
Log: Sel : Add Selection "Unnamed.Sketch.(null)(0,000000,0,000000,0,000000)"
Log: Sel : Clear selection
Log: No active document
Log: Hide main window
Log: Active view is Start page (at 0x561c01db7860)
Log: Finish: Event loop left
Log: Destruct Gui::Application
Log: Couldn't disconnect from spacenav daemon
Log: FreeCAD terminating...
Log: Saving system parameter...
Log: Saving system parameter...done
Log: Saving user parameter...
Log: Saving user parameter...done
FreeCAD.log (9,518 bytes)   

Kunda1

2017-02-07 02:18

administrator   ~0008227

Can't reproduce on
OS: "Manjaro Linux"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.Unknown
Build type: Release
Python version: 2.7.13
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.9.1

Kunda1

2017-02-07 18:09

administrator   ~0008233

Op please post to a forum thread and bidirectionally link ticket <=> thread

wmayer

2017-02-08 12:23

administrator   ~0008236

The relevant line is this:

Err: Failed to add line: ('invalid token', ('<string>', 1, 68, 'App.ActiveDocument.Sketch.addGeometry(Part.Line(App.Vector(-2,013087,1,291808,0),App.Vector(1,001905,0,572848,0)),False)\n'))
where an App.Vector is created with

App.Vector(-2,013087,1,291808,0)
When you look closely you will realize that it also uses a comma for the decimal separator. This explains the Python exception because from Python point of view it looks like 5 floats.

What are your locale settings?

wmayer

2017-02-08 12:39

administrator   ~0008237

The relevant calls are:
DrawSketchHandlerLine::releaseButton: https://github.com/FreeCAD/FreeCAD/blob/releases/FreeCAD-0-16/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp#L245
Command::doCommand: https://github.com/FreeCAD/FreeCAD/blob/releases/FreeCAD-0-16/src/Gui/Command.cpp#L434

Hard to say in which of these two functions the decimal separator is converted to a comma.

wmayer

2017-02-08 18:05

administrator   ~0008242

Based on http://stackoverflow.com/questions/1449805/how-to-format-a-number-from-1123456789-to-1-123-456-789-in-c I found a simple example to demonstrate the problem.

This example works correctly independent of the environment variable LANG because it's set to C by the program.

#include <stdio.h>
#include <locale.h>
#include <stdlib.h>

int main(void)
{
    putenv("LANG=C");
    setlocale(LC_NUMERIC, "");
    printf("App.Vector(%f,%f,0)\n", 12.45, 1.65);
    return 0;
}

If "putenv" is removed then the behaviour depends on the value of LANG. If it's set to a language that uses comma as decimal separator as e.g. German (i.e. LANG=de_DE.UTF-8)

#include <stdio.h>
#include <locale.h>
#include <stdlib.h>

int main(void)
{
    setlocale(LC_NUMERIC, "");
    printf("App.Vector(%f,%f,0)\n", 12.45, 1.65);
    return 0;
}
then it creates the output App.Vector(12,450000,1,650000,0)

It looks like this change is causing the regression https://github.com/FreeCAD/FreeCAD/commit/f32caef40c6eb0a1a634906244f3389c77d2f5ab

A workaround is to write a simple bash script that sets LANG to C and then starts FreeCAD. It could look like this:

#!/bin/bash

export LANG=C
./freecad $1 $2 $3 $4 $5
Then do "chmod u+x freecad.sh" to make it executable. As a last step you should change your starter icon to point to the bash script.

wmayer

2017-02-08 18:07

administrator   ~0008243

Won't change the code but a workaround is offered.

rm.

2017-02-08 18:51

reporter   ~0008245

Last edited: 2017-02-08 18:52

i tried the script-workaround, but i get the same problem.

#locale -a
C
C.UTF-8
de_DE.utf8
POSIX

#locale
LANG=C
LANGUAGE=de_DE@euro.ISO-8859-1
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=de_DE.UTF-8

#cat ./freecad.sh
#!/bin/bash
export LANG=C
freecad $1 $2 $3 $4 $5

#chmod 0700 freecad.sh

#./freecad.sh
FreeCAD 0.16, Libs: 0.16R
© Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2015
  ##### #### ### ####
  # # # # # #
  # ## #### #### # # # # #
  #### # # # # # # # ##### # #
  # # #### #### # # # # #
  # # # # # # # # # ## ## ##
  # # #### #### ### # # #### ## ## ##

Traceback (most recent call last):
  File "<string>", line 1, in <module>
<type 'exceptions.TypeError'>: Either three floats, tuple or Vector expected
Failed to add point: Either three floats, tuple or Vector expected
Failed to add point: Either three floats, tuple or Vector expected
Failed to add arc: ('invalid token', ('<string>', 1, 147, 'App.ActiveDocument.Sketch.addGeometry(Part.ArcOfCircle(Part.Circle(App.Vector(-1,799719,0,990309,0),App.Vector(0,0,1),0,742978),-0,494364,-0,038740),False)\n'))
Failed to add circle: ('invalid token', ('<string>', 1, 109, 'App.ActiveDocument.Sketch.addGeometry(Part.Circle(App.Vector(-1,618819,0,994948,0),App.Vector(0,0,1),1,038443),False)\n'))

wmayer

2017-02-08 20:22

administrator   ~0008246

OK, it seems that you only have to set LC_ALL=C

Then LANG doesn't need to be changed any more because LC_ALL will overwrite the handling with numbers.
Inside our main() function we only explicitly set LC_NUMERIC=C but apparently this is not sufficient if LC_ALL is set to de_DE.UTF-8

wmayer

2017-02-08 20:34

administrator   ~0008247

I found the reason: http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html
The point is that LC_ALL overwrites the LC_NUMERIC value so it's not sufficient to only reset the latter if the former is already set.

So, this means you have two options:
1. set LC_ALL=C
2. set LC_ALL= and LC_NUMERIC=C

rm.

2017-02-08 23:53

reporter   ~0008248

Last edited: 2017-02-08 23:54

solved.

It was the locale problem (point vs. comma)

workaround-script, to start freeCAD:

#!/bin/bash
export LC_ALL=C
freecad $1 $2 $3 $4 $5

Kunda1

2017-04-28 12:21

administrator   ~0008796

Changed status from 'no change required' to 'fixed'

Related Changesets

FreeCAD: master 6c2a7b47

2017-02-09 11:46:58

wmayer

Details Diff
issue 0002891: Sketching impossible, Type.Error Exception Affected Issues
0002891
mod - src/Gui/Application.cpp Diff File
mod - src/Main/MainGui.cpp Diff File

Issue History

Date Modified Username Field Change
2017-02-06 16:49 rm. New Issue
2017-02-06 16:54 rm. File Added: FreeCAD.log
2017-02-06 18:24 Kunda1 Tag Attached: exception
2017-02-07 02:18 Kunda1 Note Added: 0008227
2017-02-07 18:09 Kunda1 Note Added: 0008233
2017-02-07 18:09 Kunda1 Status new => feedback
2017-02-08 12:23 wmayer Note Added: 0008236
2017-02-08 12:39 wmayer Note Added: 0008237
2017-02-08 18:05 wmayer Note Added: 0008242
2017-02-08 18:07 wmayer Note Added: 0008243
2017-02-08 18:07 wmayer Status feedback => resolved
2017-02-08 18:07 wmayer Resolution open => won't fix
2017-02-08 18:07 wmayer Assigned To => wmayer
2017-02-08 18:51 rm. Note Added: 0008245
2017-02-08 18:51 rm. Status resolved => feedback
2017-02-08 18:51 rm. Resolution won't fix => reopened
2017-02-08 18:52 rm. Note Edited: 0008245
2017-02-08 20:22 wmayer Note Added: 0008246
2017-02-08 20:34 wmayer Note Added: 0008247
2017-02-08 23:53 rm. Note Added: 0008248
2017-02-08 23:53 rm. Status feedback => assigned
2017-02-08 23:53 rm. Note Edited: 0008248
2017-02-08 23:54 rm. Note Edited: 0008248
2017-02-09 03:35 Kunda1 Tag Attached: locale
2017-02-09 03:35 Kunda1 Tag Detached: exception
2017-02-09 08:31 wmayer Status assigned => closed
2017-02-09 08:31 wmayer Resolution reopened => no change required
2017-02-09 11:47 wmayer Changeset attached => FreeCAD Master master 6c2a7b47
2017-02-10 10:04 wmayer Relationship added related to 0001852
2017-02-15 02:34 Kunda1 Relationship added has duplicate 0002899
2017-04-28 12:21 Kunda1 Resolution no change required => fixed
2017-04-28 12:21 Kunda1 Fixed in Version => 0.17
2017-04-28 12:21 Kunda1 Note Added: 0008796