Should every Unit have an App::Property?

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

Should every Unit have an App::Property?

Post by vocx »

In this thread FreeCAD as pre-post procesor for MBDyn developers are trying to implement a graphical interface for a body dynamics solver.

One of the properties that a scripted object could have is Mass. The author realizes that there is no App::PropertyMass, but there are properties for other physical quantities

Code: Select all

App::PropertyDistance
App::PropertyLength
App::PropertySpeed
App::PropertyAcceleration
App::PropertyForce
App::PropertyPressure
These are defined in src/App/PropertyUnits.h.

These all seem to be based on App::PropertyQuantity, which are just derived from App::PropertyFloat (a numeric value).

My question is, since those properties above use Units, shouldn't there be an App::Property for every single unit defined in src/Base/Unit.h? Or why do some units have an App::Property but most do not? Is there are reason for this?
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Should every Unit have an App::Property?

Post by yorik »

Not for every unit, because in a same field you must be able to write inches or centimeters.
But I would say for every unit type yes. Lengths, weights, areas.. Basically one that cannot be converted to another and where you would want the user to specifically have to use a certain unit and not another.
But to me this can come as the need arises, no need to rush to add complexity before it's actually needed by someone.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Should every Unit have an App::Property?

Post by vocx »

yorik wrote: Mon Nov 04, 2019 3:14 pm ...
But to me this can come as the need arises, no need to rush to add complexity before it's actually needed by someone.
I agree. There is no need to add complexity. But that's why I asked this question.

As mentioned in the thread, FreeCAD as pre-post procesor for MBDyn, the developer could use an App::PropertyMass property, but this currently does not exist. So the question is, should there be a Mass property? Why not expose more properties (or property types) already so that if somebody needs them, they can use them?
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Should every Unit have an App::Property?

Post by DeepSOIC »

There is a generic PropertyQuantity, which can have any unit, and possibly can enforce it. It lacks proper python interface.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Should every Unit have an App::Property?

Post by yorik »

In any case, a PropertyMass seems a good idea to me...
User avatar
mfasano
Posts: 122
Joined: Wed Apr 11, 2018 12:31 pm

Re: Should every Unit have an App::Property?

Post by mfasano »

I would think density would be the property you want.

would the material editor work for this?
Post Reply