Sketch.ExpressionEngine: Failed to parse expression.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- adrianinsaval
- Veteran
- Posts: 5553
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Sketch.ExpressionEngine: Failed to parse expression.
what about the behavior when renaming a constrain/setting to reference? separate issue or the same? I think there's an existing issue for the reference constrain but I can't find it... perhaps when renaming/setting to reference the contrain the expressions can be evaluated and raise an error/warning?
Re: Sketch.ExpressionEngine: Failed to parse expression.
I think it is not matter if you edit or create new one. However, I think there should be more tests done by someone who know FreeCAD code to make sure if the bug is not related to something bigger. If this is not like it depends on something else, because this is strange behavior the single word is sometimes working and sometimes not. This is also not related to structure, because it exists without Pad, or Array.adrianinsaval wrote: ↑Wed Mar 16, 2022 8:42 pm what about the behavior when renaming a constrain/setting to reference? separate issue or the same? I think there's an existing issue for the reference constrain but I can't find it... perhaps when renaming/setting to reference the contrain the expressions can be evaluated and raise an error/warning?
This is strange but looks like the open file part should be checked more deeply in relation of XML parsing.
EDIT: Also what is strange, the values are correctly calculated, so the expressions are calculated correctly, this only loses expressions, they are even removed from the XML file content during reopen. So, if you want to keep expressions for testing purposes, you have to save the file just after close. If you reopen the file you lost expressions from testing file.
Thanks
Darek
github.com/dprojects
workbench for woodworking is available at: github.com/dprojects/Woodworking
- adrianinsaval
- Veteran
- Posts: 5553
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Sketch.ExpressionEngine: Failed to parse expression.
Like I said, I was not able to use a constrain with space in the name in an expression directly, only by renaming an existing constrain. And I am not able to make Bottom fail, with or without other invalid names around. Provide an example if you have it.dprojects wrote: ↑Wed Mar 16, 2022 8:59 pm I think it is not matter if you edit or create new one. However, I think there should be more tests done by someone who know FreeCAD code to make sure if the bug is not related to something bigger. If this is not like it depends on something else, because this is strange behavior the single word is sometimes working and sometimes not.
Eitherway, I was just asking if a separate issue should be created for the behavior when renaming. I did not say this was the only problem.
Re: Sketch.ExpressionEngine: Failed to parse expression.
So, this is strange. I can add any name, for new constraints and also with edit. It only not allow to add duplicated name.adrianinsaval wrote: ↑Wed Mar 16, 2022 9:28 pm Like I said, I was not able to use a constrain with space in the name in an expression directly, only by renaming an existing constrain. And I am not able to make Bottom fail, with or without other invalid names around. Provide an example if you have it.
Eitherway, I was just asking if a separate issue should be created for the behavior when renaming. I did not say this was the only problem.
What OS and FreeCAD version you have? Maybe this is related to version or OS? or python version library? XML parse or Qt?
Thanks
Darek
github.com/dprojects
workbench for woodworking is available at: github.com/dprojects/Woodworking
- adrianinsaval
- Veteran
- Posts: 5553
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Sketch.ExpressionEngine: Failed to parse expression.
I can name the constrains however I want new or editing and this survives save an reopen without issues, but I can't input a name with a space in a expression. Here my FreeCAD info:
Code: Select all
OS: Windows 10 (10.0)
Word size of FreeCAD: 64-bit
Version: 0.20.27809 (Git)
Build type: Release
Python 3.8.12, Qt 5.12.9, Coin 4.0.0, OCC 7.5.3
Locale: Spanish/Paraguay (es_PY)
Installed mods:
* ArchTextures
* CurvedShapes 1.0.0
* Curves 0.3.0
* Defeaturing
* fasteners 0.3.38
* Glass
* SelectorToolbar
* Silk -831323728.0.0
- adrianinsaval
- Veteran
- Posts: 5553
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Sketch.ExpressionEngine: Failed to parse expression.
Another similar problem with spaces in the name, make two constrains, give one a valid single word name, set the second to a expression with the first and hit ok, edit the second constrain again and give it a spaced name and hit ok, close the file, reopen the file and get failed to parse expression.
Even if the expression itself was valid it fails. Spaces (and maybe special characters? unit identifiers on their own too probably) in constraint names should be forbidden IMO.
(asked realthunder about this stuff since one of his PRs is supposed to address spaces in the name: https://forum.freecadweb.org/viewtopic. ... 05#p580505)
Even if the expression itself was valid it fails. Spaces (and maybe special characters? unit identifiers on their own too probably) in constraint names should be forbidden IMO.
(asked realthunder about this stuff since one of his PRs is supposed to address spaces in the name: https://forum.freecadweb.org/viewtopic. ... 05#p580505)
- Attachments
-
- test.FCStd
- (5.79 KiB) Downloaded 31 times
Re: Sketch.ExpressionEngine: Failed to parse expression.
I tested at:
Code: Select all
FreeCAD_weekly-builds-27936-Linux-Conda_glibc2.12-x86_64.AppImage
Open the attached file and write what left for you, for me left nothing, all expressions was removed.
- Attachments
-
- Test.FCStd
- saved before reopen, see XML zip to see reference
- (8.19 KiB) Downloaded 35 times
Thanks
Darek
github.com/dprojects
workbench for woodworking is available at: github.com/dprojects/Woodworking
Re: Sketch.ExpressionEngine: Failed to parse expression.
I would have no problem in hardcoding these (copied from Expressions): But the names can also be used for documentation, especially with the new possibility of showing them in 3D view. In that case they may never occur in any expression and no problem would occur.adrianinsaval wrote: ↑Wed Mar 16, 2022 10:05 pm Even if the expression itself was valid it fails. Spaces (and maybe special characters? unit identifiers on their own too probably) in constraint names should be forbidden IMO.
The names are given before any expression can reference them and thus it cannot be checked if it is necessary to have an expression-conformant name.
I hardly ever see the usage of documentation names in Sketcher constraints. It should be possible to find a decent replacement name for names which now use one of the forbidden characters. So I think it would indeed be helpful to restrict the names of constraint names.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
- adrianinsaval
- Veteran
- Posts: 5553
- Joined: Thu Apr 05, 2018 5:15 pm
Re: Sketch.ExpressionEngine: Failed to parse expression.
That is not the proper way of providing FreeCAD info as it ommits information that is often relevant (qt, occ and other libraries version, in this particular case I don't think they matter). Proper way is to go to Help->About FreeCAD->Copy to clipboarddprojects wrote: ↑Wed Mar 16, 2022 10:14 pm I tested at:Code: Select all
FreeCAD_weekly-builds-27936-Linux-Conda_glibc2.12-x86_64.AppImage
No expressions left inside the sketch, but notice the issue I mentioned above, even valid expressions using single word named constrains fail to parse if they are used to set the value for a constraint with a space in the name.with the same result, so this might be related to something else, OS or Library version.
Open the attached file and write what left for you, for me left nothing, all expressions was removed.
So if you use top (which is valid) in Botom size test 1 (which isn't) it will fail to parse, the same as if you use Bottom, width in top23_r.
Re: Sketch.ExpressionEngine: Failed to parse expression.
Yes, you are right ! This is why sometimes single word is working and sometimes not. It depends if you use "not valid" name or not. I make little more research on that:adrianinsaval wrote: ↑Wed Mar 16, 2022 10:32 pm No expressions left inside the sketch, but notice the issue I mentioned above, even valid expressions using single word named constrains fail to parse if they are used to set the value for a constraint with a space in the name.
So if you use top (which is valid) in Botom size test 1 (which isn't) it will fail to parse, the same as if you use Bottom, width in top23_r.
If you add only valid names they all survive reopen (no errors at console, after reopen):
Also I make test for 0.18.4 version natively installed at Ubuntu, and this is even more strange. If you add "not valid" name the reference will not be visible but after reopen they exists !
- Attachments
-
- Test_v0_20_before_reopen.FCStd
- (7.84 KiB) Downloaded 35 times
-
- Test_v0_18_4_before_reopen.FCStd
- (6.62 KiB) Downloaded 35 times
-
- Test_v0_18_4_after_reopen.FCStd
- (6.57 KiB) Downloaded 30 times
Thanks
Darek
github.com/dprojects
workbench for woodworking is available at: github.com/dprojects/Woodworking