Linked constraints don't work with spaces.

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Posts: 23
Joined: Fri Nov 16, 2018 2:00 am

Linked constraints don't work with spaces.

Postby rainharvester » Mon Nov 26, 2018 3:17 pm

Attached is a simple file.
The height of the square is "GlobalHeight".
The width of the square is "GlobalHeight + 10mm"

Change the name of the height to "Global Height" (add a space). No error is given.
Click on the width. Click on the blue function circle. You will correctly see : Constraints.<<Global Height>> + 10mm
Click bottom-most "OK".
Click on the width again. Click on the blue function circle. You will see : Constraints.Global Height + 10mm (notice the "<< >>" is gone. Why?!)

Sometimes when you save the file (save-close-load-modify-height then repeat x2), this "Failed to parse expression isn't seen". Also, I didn't change the expression, the program did. It removed the "<< >>" to break the link.

Also, if the user originally uses a space in "Global Height", the program gives no indication that "<< >>" is necessary when adding the constraint, and even recommends the name "Constraints.Global Height" ( ie no "<< >>").

These bugs can get very confusing when many objects are linked and no error message are given (unless you click everything looking for an error). In the case of Bug#2, no error is ever given (the program silently modifies your files).
Can someone verify so I can submit this bug? Thanks.
(3.48 KiB) Downloaded 9 times
- aka 'TheRainHarvester" on youtube.
Posts: 17440
Joined: Tue Mar 17, 2015 9:14 am

Re: Linked constraints don't work with spaces.

Postby chrisb » Mon Nov 26, 2018 11:03 pm

I think this has been discussed here before, perhaps there is already a tracker entry, but I don't know if it is really a bug.
I never have these issues because I never ever use names with spaces or non ascii characters, but I can understand that others use this.
However, there is no need to allow this in expressions as well. So an error message should be enough if spaces occur in expressions. The generic message "Failed to parse expression" might be too general.
Posts: 1939
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Linked constraints don't work with spaces.

Postby Jee-Bee » Tue Nov 27, 2018 6:42 am

In my opinion the only possible bug is that expressions accept spaces...
However the result would be that some users link to expressions that don't exist and complain about that...

One thing i have checked when you give a cell in libre office a name with spaces it don't accept it too. I didn't check but i'm quite sure that excel don't accept it too. python/ Matlab/ octave don't accept a space in a variable too. Sound almost like logic :shock:

I checked There is nothing said about no spaces, but all examples don't contain spaces also the expresion properties like CenterOfMass.
Last point i want to make... I'm quite sure even if there was written that an expression can't contain spaces. Almost nobody reads it.