[Solved] Auto-completion in edition of formulas

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
plgarcia
Posts: 310
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

[Solved] Auto-completion in edition of formulas

Post by plgarcia »

As simple example to illustrate this error, I wanted to have the cone always pointing at the opposite corner from the origin of the cube.

The formulas I implemented for the position of the cone are Cube.Length + Cube.Placement.Base.x, and their equivalent for y and z axis. And it works fine as show Image 1 and image 2.

The problem I found is the completion that is incomplete.

As shown in image 3, the completion works fine as long as the formula is composed of one element, to file Placement.Base.x in the example.

But when the formula is the addition of two elements (and I believe when more complex also) as shown in image 4, the completion does not work for the second element of the formula and shows errors.

No error appears when the formula is complete and correct as shown in image 5.



Freecad version Windows (the latest)
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12196 (Git)
Build type: Release
Branch: master
Hash: 6f2d59540a9b1647eeb9b95ca0fffdc1439f2a87
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: French/France (fr_FR)


regards
Attachments
image5.png
image5.png (6.81 KiB) Viewed 2171 times
image4.png
image4.png (12.9 KiB) Viewed 2171 times
image3.png
image3.png (15.74 KiB) Viewed 2171 times
image1.png
image1.png (8.84 KiB) Viewed 2171 times
image2.png
image2.png (9.21 KiB) Viewed 2171 times
Last edited by plgarcia on Wed Dec 06, 2017 11:43 am, edited 1 time in total.
chrisb
Veteran
Posts: 51227
Joined: Tue Mar 17, 2015 9:14 am

Re: Auto-completion in edition of formulas

Post by chrisb »

This is a well known issue. The workaround is to enter the last formula first. When you proceed with further formulae from the start of the input field you again have the autocompletion.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
plgarcia
Posts: 310
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: Auto-completion in edition of formulas

Post by plgarcia »

Yes that is what I am doing.
I cut the beginning of the field, then use the completion and finally paste the beginning of the formula I cut before.
But that is quite a pain.
I reported the bug:
https://www.freecadweb.org/tracker/view.php?id=3197
chrisb
Veteran
Posts: 51227
Joined: Tue Mar 17, 2015 9:14 am

Re: Auto-completion in edition of formulas

Post by chrisb »

You are pretty fast reporting a bug, but I think it is rather a feature request. See the bug reporting guidelines, especially the definition of a bug.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
plgarcia
Posts: 310
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: Auto-completion in edition of formulas

Post by plgarcia »

Call it feature request if you want. That is a function available that is not fully working.
For me it is the defintion of a bug, but I classified it as cosmetic as we have a workaround.
Regards
SparkyCola
Posts: 22
Joined: Mon May 29, 2017 11:29 pm

Re: Auto-completion in edition of formulas

Post by SparkyCola »

So I assigned the request to myself and have quite some progress to show:
phpBB [video]

There are still some small tweaks necessary like not showing a suggestion after a space (and some more characters like +-*/). If there's anything that might be missing, do tell.
User avatar
Kunda1
Veteran
Posts: 13447
Joined: Thu Jan 05, 2017 9:03 pm

Re: Auto-completion in edition of formulas

Post by Kunda1 »

Nice!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
plgarcia
Posts: 310
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: Auto-completion in edition of formulas

Post by plgarcia »

Good progress.
In figure 6 I show the formulas I put on place on a simple example. That is one finger of a hand. Each phalanx makes the same angle with the previous phalanx, and its start position is the end position of the previous.
Note that the current builds have an error in manipulating the angles. There are other problems and I am waiting to have a build that handles properly the angles to investigate then a bit further.
Capture6.JPG
Capture6.JPG (100.63 KiB) Viewed 1989 times
May I suggest that only the labels of the objects are presented as they are the only references the user knows.
This needs a conversion from name to label when editing if the name is used in a formula.
As shown in figure Cut02, or Cylinder001 are not references for object known by the user as they have been renamed.
Capture5.JPG
Capture5.JPG (62.73 KiB) Viewed 1989 times
plgarcia
Posts: 310
Joined: Wed Jun 17, 2015 9:47 pm
Location: Near Paris (France)

Re: Auto-completion in edition of formulas

Post by plgarcia »

When saving the formula it would be great to use only names and not labels. Labels can be changed and therefore an inconsistency can be introduced when changing a label.

But for edition the label is the reference that makes sense for the users. So when editing the conversion from name to label would be convenient.

In short edited with labels, and saved with names.
Jee-Bee
Veteran
Posts: 2569
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Auto-completion in edition of formulas

Post by Jee-Bee »

For just trowing a clup in the Hencoop (Dutch saying). I would say that the names are the logic of the software and the label is the logic of the user... For most users is the label more easy to remember or to lookup...
Post Reply