[Bug 4261] Bad behavior when using '°' unit in expressions

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!
openBrain
Posts: 3920
Joined: Fri Nov 09, 2018 5:38 pm

[Bug 4261] Bad behavior when using '°' unit in expressions

Postby openBrain » Tue Feb 04, 2020 10:38 am

Steps to reproduce :
  1. Create a new document, select PartDesign WB
  2. Add a sketch (you can just let it empty)
  3. Create a DatumPlane (locate it at any position)
  4. Try to enter as expression for DatumPlane/AttachmentOffset/Angle the following :'90°-atan(Sk' => You'll notice first that 'Sketch' is only proposed when you enter the 'k', then that if you select 'Sketch' proposal with down arrow, it is replaced by 'SSketch' in the expression (doubled 'S')
If you use 'deg' instead of '°' in the expression, the 2 issues described aren't present : 'Sketch' is proposed as soon as 'S' is entered, and it is correctly entered in the expressions if you select the proposal with down arrow.

Thx for confirming.

As a sidenote, I get lot more problems with expressions in this file. Expressions using '°' just vanished, and some had the object reference cleared (eg. 'Sketch.Constraints.xxx' was saved as '.Constraints.xxx') but I'm not able to reproduce it ATM.
---
OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19461 (Git)
Build type: Release
Branch: master
Hash: da71719896847b0e2a5716e7afb5d4cb4b326990
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)
Last edited by openBrain on Tue Feb 04, 2020 2:24 pm, edited 1 time in total.
wmayer
Site Admin
Posts: 15724
Joined: Thu Feb 19, 2009 10:32 am

Re: [Bug] Bad behavior when using '°' unit in expressions

Postby wmayer » Tue Feb 04, 2020 1:00 pm

Confirmed. Feel free to create a bug report.
openBrain
Posts: 3920
Joined: Fri Nov 09, 2018 5:38 pm

Re: [Bug] Bad behavior when using '°' unit in expressions

Postby openBrain » Tue Feb 04, 2020 2:24 pm

wmayer wrote:
Tue Feb 04, 2020 1:00 pm
Confirmed. Feel free to create a bug report.
issue #4261. Set it to 'major' severity as ATM I think it could create more severe issues in the expression engine than the one described here at document loading time.
vocx
Posts: 3999
Joined: Thu Oct 18, 2018 9:18 pm

Re: [Bug 4261] Bad behavior when using '°' unit in expressions

Postby vocx » Wed Feb 05, 2020 7:43 am

I found this when testing Draft.

Code: Select all

import FreeCAD as App
value_in_degrees = App.Units.Quantity(45, App.Units.Angle)
round(value_in_degrees)

Code: Select all

Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: type Base.Quantity doesn't define __round__ method
The Draft Dimension tool can create angular dimension objects which use App::PropertyAngles. Internally the code does some rounding, resulting in the above errors. What would be the proper way to solve this? Extend App::PropertyAngle to support __round__()? Or change the Draft code to extract the numeric value?

Code: Select all

#Something like
round(obj.MyAngle.Value)
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.