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.
vocx
Posts: 3354
Joined: Thu Oct 18, 2018 9:18 pm

Should every Unit have an App::Property?

Postby vocx » Fri Oct 25, 2019 3:21 pm

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.
To support the documentation effort, and code development, your donation is appreciated: paypal.
User avatar
yorik
Site Admin
Posts: 11712
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

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

Postby yorik » Mon Nov 04, 2019 3:14 pm

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
Posts: 3354
Joined: Thu Oct 18, 2018 9:18 pm

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

Postby vocx » Mon Nov 04, 2019 3:42 pm

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.
To support the documentation effort, and code development, your donation is appreciated: paypal.
User avatar
DeepSOIC
Posts: 7485
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

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

Postby DeepSOIC » Mon Nov 04, 2019 4:21 pm

There is a generic PropertyQuantity, which can have any unit, and possibly can enforce it. It lacks proper python interface.
User avatar
yorik
Site Admin
Posts: 11712
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

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

Postby yorik » Sun Nov 17, 2019 4:26 pm

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

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

Postby mfasano » Mon Nov 18, 2019 8:19 pm

I would think density would be the property you want.

would the material editor work for this?