Minor issue : dot becomes underscore in part or body name
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Minor issue : dot becomes underscore in part or body name
When renaming a body or a part inside a document. If the name contains a '.' (dot), the dot is replaced by a '_' (underscore) on Linux but remains a '.' (dot) on Windows. Is that intentional? The issue is that if I want to name a body 'body_name_M2.5', I end up with 'body_name_M2_5' on Linux. It is not the end of the world but the name becomes a little less clear.
Any insight from the community is welcome.
Any insight from the community is welcome.
Re: Minor issue : dot becomes underscore in part or body name
The behaviour on Windows and Linux is the same.When renaming a body or a part inside a document. If the name contains a '.' (dot), the dot is replaced by a '_' (underscore) on Linux but remains a '.' (dot) on Windows. Is that intentional?
An object actually has two names: the internal name that is immutable and a user visible name which is called Label. The label is allowed to include any character such as dots or unicode (as ut8-encoded byte string) and the internal name must follow the rules of an identifier and thus has a very limited character set (only alphanumeric characters). All invalid characters are replaced with an underscore.
So, if you use the Python or C++ API and add a new object with addObject(type, name) then "name" will become the internal name but adjusted if needed. If you rename an object per GUI in the tree view then it should accept every character.
Re: Minor issue : dot becomes underscore in part or body name
Thanks for your answer. I makes me realize that there might be some info missing in my initial post:
On Windows 10: FreeCAD 0.17 build 13528
On Ubuntu 18.04 VM: FreeCAD from realthunder's assembly3 branch, compiled from sources.
I assumed that the different OS was the reason for the different behaviour but this is very probably wrong.
I do not know if realthunder tinkered with object naming in his branch, but for sure a dot gets auto-replaced with an underscore when renaming via the UI on the version I compiled on Ubuntu 18.04. If time allows, I will install an 'official' FreeCAD on an Ubuntu VM and see if the issue is still there.
On Windows 10: FreeCAD 0.17 build 13528
On Ubuntu 18.04 VM: FreeCAD from realthunder's assembly3 branch, compiled from sources.
I assumed that the different OS was the reason for the different behaviour but this is very probably wrong.
I do not know if realthunder tinkered with object naming in his branch, but for sure a dot gets auto-replaced with an underscore when renaming via the UI on the version I compiled on Ubuntu 18.04. If time allows, I will install an 'official' FreeCAD on an Ubuntu VM and see if the issue is still there.
Re: Minor issue : dot becomes underscore in part or body name
Did the test. Renaming an object in the model view with a dot works without any problem on a 0.17 FreeCAD on Linux. Must have to do with realthunder's branch
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Re: Minor issue : dot becomes underscore in part or body name
Because 'dot' has a special meaning in my branch. It is used as a separator in sub-object name references. See here for more details.
Re: Minor issue : dot becomes underscore in part or body name
Thanks for the explanation. The reason why is now very clear. Just an idea: wouldn't the use of another character than dot help with mainstream FreeCAD compatibility/later merging?realthunder wrote: ↑Mon Nov 19, 2018 10:27 pm Because 'dot' has a special meaning in my branch. It is used as a separator in sub-object name references. See here for more details.
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Re: Minor issue : dot becomes underscore in part or body name
The sub-object name hierarchy concept does not exist in upstream, so I don't think it matters which character to choose. BTW, in my next release, there will be a new Label2 property for every object. It shows up in the tree view as 'Description'. There will be no restriction in characters there.
Re: Minor issue : dot becomes underscore in part or body name
IMHO there likely won't be Label2 property in upstream FreeCAD anytime soon. Therefore this will likely need to get rethinked. Before upstreaming.
-
- Veteran
- Posts: 2190
- Joined: Tue Jan 03, 2017 10:55 am
Re: Minor issue : dot becomes underscore in part or body name
Any reason against adding another label?
Re: Minor issue : dot becomes underscore in part or body name
For one introducing another label wouldn't resolve the problem with dot and the label. It already is a bit confusing, when explaining to the end users each feature has a (internal) Name and Label. And why. Another label (to workaround the possible dot in the label text issue) real purpose would be what exactly? Use it when you need to use a dot? For description purposes or as a note?
All in all it doesn't make all that much sense to me.