I am reviving this old thread due to the work I'm currently working on trying to make some small improvements to the Spreadsheet module. See here.
Code: Select all
import Part doc = FreeCAD.newDocument("MyDoc") feat = doc.addObject("Part::Box", "BoxName WithSpace" print(feat.Name) # prints out "BoxName_WithSpace"
I don't know if this is done by Part, or by more core functionality, but yes, it seems to be a mechanism to get valid internal names of objects, which can only be alphanumeric, and the underscore.ezzieyguywuf wrote: ↑Tue Dec 03, 2019 3:08 am...
It seems that the Part workbench has elected to silently allow users to create objects with invalid names, but in the background replaces spaces with underscores.
This is actually quite counter-intuitive, as the tree display still shows the space rather than issuing an error, but I guess that's off-topic...
The <<double signs>> syntax looks fine to me because it is somewhat intuitive (delimiters help establish the scope), but if you think it could be handled better then please let us know.In short: should the ExpressionParser be updated to handle spaces more gracefully? Or is the <<Name With Space>> syntax sufficient?
If so, should we update the Gui elements (and indeed, the python api...) which accept spaces without error and throw an error, since the name is technically invalid without the double-bracket escape?
This is an issue if the same name is used with underscore and space. It seems to the user to be different, bit internally it isn't.
I'm with chrisb on this one, I don't think it's wise to hold the users' hands in this regards. If they do something wrong they should be told about it and not allowed to move on.chrisb wrote: ↑Tue Dec 03, 2019 4:31 pmThis is an issue if the same name is used with underscore and space. It seems to the user to be different, bit internally it isn't.
I'm not a friend of automatisms, which try to be smarter than the user. In many cases it is possible, but in corner cases things become very obscure and cumbersome.
+1 I agree with this.
I'm supposed to be working on the Spreadsheet module. But as I'm finding out, the Spreadsheet module in and of itself is pretty robust, it's the ExpressionParser that seems to be causing the issues/"bugs" that are being reported as "spreadsheet module" bugs.
Okay, then you have my support as well. Let's void spaces in expressions. Unfortunately, a lot of Windows users are used to write spaces in file names, directory names, etc., so they need to learn the Linux way, which is using underscores.
LOL. You are!...so maybe I am working on Expressions