hyphen in object name changed to underscore.

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

hyphen in object name changed to underscore.

Post by keithsloan52 »

I have an FreeCAD python feature that adds a property with

Code: Select all

obj.addProperty("App::PropertyString","name",'GDMLmaterial','name').name = name
The name is being read from an external file and has a hyphen in it. FreeCAD is converting the hyphen to an underscore,
is there anything about this? i.e. something like an escape character?
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: hyphen in object name changed to underscore.

Post by openBrain »

Name in FreeCAD can be only alphanumerical characters + underscore. No other character is supported. First character can't be a digit.
User avatar
onekk
Veteran
Posts: 6205
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: hyphen in object name changed to underscore.

Post by onekk »

Also spaces are converted to underscore in names, so:

"this-name"

"this name"

"this_name"

Are perfect equivalent after this "translation", it is simply a matter to put this in "evidence somewhere", not a big issue.

It as many other thing in FreeCAD "perfecly hidden in great evidence", it only lacks of a little arrow pointing at his behaviour. :D

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply