(Bug?) FreeCAD changes a starting "0" (zero) into an underscore "_" in a file name.

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!
vocx
Posts: 921
Joined: Thu Oct 18, 2018 9:18 pm

(Bug?) FreeCAD changes a starting "0" (zero) into an underscore "_" in a file name.

Postby vocx » Thu Apr 25, 2019 1:36 am

To keep files organized I sometimes name my files with an initial number like 01_something.FCstd, 02_something_else.FCstd, 03_third.FCstd, etc.

However, when I open such file in FreeCAD the file name is changed to _1_something.FCstd, that is, the initial zero is replaced by an underscore.

This name is visible in the search view, and also in the Python console. Everything works as usual, the file works normally, when you save the file, the file is saved to the original name (with an initial zero); it just so happens that the string is shown as starting with an underscore inside FreeCAD.

For example, this is a file called 03_turbulent.FCstd. The operations recorded in the Python console give the impression that I'm using a file named _3_turbulent.FCstd.
FreeCAD_filename_starting_with_0_search.png
FreeCAD_filename_starting_with_0_search.png (6.62 KiB) Viewed 90 times
FreeCAD_filename_starting_with_0.png
FreeCAD_filename_starting_with_0.png (60.85 KiB) Viewed 90 times
This is a very benign bug, but I find it strange. My initial thought was that FreeCAD changes a file name starting with zero (0) to avoid interpreting it for an octal number or something like that. I wonder what code handles processing of the file name.

As we know, every object inside FreeCAD is an object under the document's name. So maybe the code that initially creates the ActiveDocument object parses the name of the file, assigns the Name attribute, and then uses this attribute everywhere in the code. I think for the graphical user interface, the original string of the file name should be used.

Code: Select all

print(App.ActiveDocument.Name)
_3_turbulent

App.ActiveDocument.object1 # _3_turbulent.object1
App.ActiveDocument.object2 # _3_turbulent.object2
App.ActiveDocument.OpenFOAM # _3_turbulent.OpenFOAM
# etc.
I believe this happens with every version of FreeCAD that I've tried.

Code: Select all

OS: Ubuntu 18.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.1.
Build type: Release
Python version: 3.6.7
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)