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

Forum rules
and Helpful information

Posts: 3956
Joined: Thu Oct 18, 2018 9:18 pm


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 (6.62 KiB) Viewed 144 times
FreeCAD_filename_starting_with_0.png (60.85 KiB) Viewed 144 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


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)
Always add the important information to your posts if you need help.
To support the documentation effort, and code development, your donation is appreciated: paypal.