[BUG?] Negative numbers in feet/inches interpreted wrong

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!
metatheorem
Posts: 3
Joined: Wed Apr 03, 2019 2:13 am

[BUG?] Negative numbers in feet/inches interpreted wrong

Postby metatheorem » Wed Apr 03, 2019 2:14 am

I am seeing some strange behavior when working in feet and inches in the "Building US" units.

FreeCAD is interpreting combined foot/inch values that are negative as expressions and this is giving me incorrect results.

For example, say I want to move an object one foot and four inches in the negative X direction. If I use the Draft Move tool and type this in: -1' 4" for the second point, the program will add these numbers together (-12" + 4"), moving only eight inches (-8"). I can even observe this happening by moving the focus to/from the entry field.

Is this a known issue? Is there a way to force the program not to interpret these entries as expressions?

Thanks

OS: Linux
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.Unknown
Build type: Unknown
Python version: 2.7.15
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.9.1.oce-0.18
Locale: English/UnitedStates (en_US)
openBrain
Posts: 3891
Joined: Fri Nov 09, 2018 5:38 pm

Re: [BUG?] Negative numbers in feet/inches interpreted wrong

Postby openBrain » Wed Apr 03, 2019 2:15 pm

Confirmed here with latest 0.18 under Windows 7.
This behavior exists :
  • Whatever is the base unit selected => You can enter -1'4" value when working in mKs, you'll get the same result
  • Whatever is the unit used in the value => You can enter -1m500mm and get same kind of result
The only way at now is entering -1'-4" but doesn't sound very natural.

@metatheorem : as a sidenote, you can read from this thread if you'd like to compile with Qt5 and OCCT7+ ;)
chrisb
Posts: 24230
Joined: Tue Mar 17, 2015 9:14 am

Re: [BUG?] Negative numbers in feet/inches interpreted wrong

Postby chrisb » Wed Apr 03, 2019 3:30 pm

openBrain wrote:
Wed Apr 03, 2019 2:15 pm
The only way at now is entering -1'-4" but doesn't sound very natural.
This doesn't work either, because it is parsed twice: once when entering the value and a second time when confirming the dialog.
openBrain
Posts: 3891
Joined: Fri Nov 09, 2018 5:38 pm

Re: [BUG?] Negative numbers in feet/inches interpreted wrong

Postby openBrain » Wed Apr 03, 2019 4:10 pm

chrisb wrote:
Wed Apr 03, 2019 3:30 pm
]This doesn't work either, because it is parsed twice: once when entering the value and a second time when confirming the dialog.
Ouch. I admit that I just tried by changing a position in the comboview. Indeed the case described by OP is another one. ;)
I can't try now but what about using something like -(1'4") ?
chrisb
Posts: 24230
Joined: Tue Mar 17, 2015 9:14 am

Re: [BUG?] Negative numbers in feet/inches interpreted wrong

Postby chrisb » Wed Apr 03, 2019 4:33 pm

openBrain wrote:
Wed Apr 03, 2019 4:10 pm
I can't try now but what about using something like -(1'4") ?
I see you had all the ideas which I had :) , but no, brackets are not accepted by the input field :cry: .
openBrain
Posts: 3891
Joined: Fri Nov 09, 2018 5:38 pm

Re: [BUG?] Negative numbers in feet/inches interpreted wrong

Postby openBrain » Wed Apr 03, 2019 5:55 pm

I tried some various things and can't find a decent workaround. Definitely sounds as a real bug...
Geoplace
Posts: 39
Joined: Tue Feb 26, 2019 9:49 pm

Re: [BUG?] Negative numbers in feet/inches interpreted wrong

Postby Geoplace » Thu Apr 04, 2019 10:25 pm

metatheorem
Posts: 3
Joined: Wed Apr 03, 2019 2:13 am

Re: [BUG?] Negative numbers in feet/inches interpreted wrong

Postby metatheorem » Thu Apr 04, 2019 10:51 pm

I've opened a bug for this: https://www.freecadweb.org/tracker/view.php?id=3925.

@openBrain: Thanks, I'm working off of a repo build right now, but will probably build if I find the time soon...
realthunder
Posts: 1536
Joined: Tue Jan 03, 2017 10:55 am

Re: [BUG?] Negative numbers in feet/inches interpreted wrong

Postby realthunder » Thu Feb 27, 2020 3:42 am

The problem is resolved by this PR. When you type the text, remember to separate the unit string and the following number with a space. This is crucial, or else and string and number together will be recognized as an identifier. For example 1m10mm, will be recognized as 1 and m10mm.

unit.gif
unit.gif (205.4 KiB) Viewed 135 times
Try Assembly3 (latest version 0.11) along with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
openBrain
Posts: 3891
Joined: Fri Nov 09, 2018 5:38 pm

Re: [BUG?] Negative numbers in feet/inches interpreted wrong

Postby openBrain » Sat Mar 21, 2020 2:18 pm

realthunder wrote:
Thu Feb 27, 2020 3:42 am
The problem is resolved by this PR.
Hi @realthunder. Actually I have a doubt that your PR solves the exact problem discussed here. Could you have a look at this thread (and maybe if you're comfortable with parser things you can be of help there) ? Thanks.