Minor issue : dot becomes underscore in part or body name

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
gflorent
Posts: 49
Joined: Fri Aug 10, 2018 10:05 am
Location: France
Contact:

Minor issue : dot becomes underscore in part or body name

Post by gflorent »

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.
wmayer
Founder
Posts: 20242
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Minor issue : dot becomes underscore in part or body name

Post by wmayer »

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 behaviour on Windows and Linux is the same.

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.
User avatar
gflorent
Posts: 49
Joined: Fri Aug 10, 2018 10:05 am
Location: France
Contact:

Re: Minor issue : dot becomes underscore in part or body name

Post by gflorent »

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.
User avatar
gflorent
Posts: 49
Joined: Fri Aug 10, 2018 10:05 am
Location: France
Contact:

Re: Minor issue : dot becomes underscore in part or body name

Post by gflorent »

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
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Minor issue : dot becomes underscore in part or body name

Post by realthunder »

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.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
User avatar
gflorent
Posts: 49
Joined: Fri Aug 10, 2018 10:05 am
Location: France
Contact:

Re: Minor issue : dot becomes underscore in part or body name

Post by gflorent »

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.
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
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Minor issue : dot becomes underscore in part or body name

Post by realthunder »

gflorent wrote: Tue Nov 20, 2018 7:01 pm 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?
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.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Minor issue : dot becomes underscore in part or body name

Post by triplus »

IMHO there likely won't be Label2 property in upstream FreeCAD anytime soon. Therefore this will likely need to get rethinked. Before upstreaming.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: Minor issue : dot becomes underscore in part or body name

Post by realthunder »

triplus wrote: Tue Nov 20, 2018 11:00 pm IMHO there likely won't be Label2 property in upstream FreeCAD anytime soon. Therefore this will likely need to get rethinked. Before upstreaming.
Any reason against adding another label?
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Minor issue : dot becomes underscore in part or body name

Post by triplus »

realthunder wrote: Wed Nov 21, 2018 4:31 am Any reason against adding another label?
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.
Post Reply