Change symbol of TUnit descendant

Hi, is there an easy way to change the symbol that used in the TUnit descendant (for example, TMicron "μ" from Physix.Units.Derived unit)? These classes are marked sealed and their methods are final. I need to change the symbol because the script engine (PascalScript) does not support Unicode characters.

I don't want to make changes directly to the source code, maybe there is a way to "special" inheritance or somehow quickly override the corresponding method?

The option to remove the old class from the assembly, create and register a new class is also acceptable. How can I do that?

Vitalii,
as the classes marked with sealed and methods are final there is no way to override
the symbol without modifying the source code of these classes.

Removing the class from the assembly and creating a new one is possible.
Most of the unit classes registered in Physix.Measurement.Assembly unit.
You can remove any unit from the registration. But it only works if you use exe project.
If you use packages the system automatically finds all classes in the loaded packages.
In this case, you need to remove the source code of the unit class.

For creating new units see documentation http://www.tmssoftware.biz/download/manuals/TMS%20PHYSICS%20Delphi%20Development.pdf (page 14).

Thanks for your answer, Sergey.
A question for the developers (TMS team): is it possible to add any global method or procedure to change the text properties of TUnit descendants (in particular, the Symbol property)? In order to change them at the application level. This is important not only for the reason I wrote about above, but also for localization. We create a product for users from different countries, and I would like to use the units of measurement specific to a specific region (for example, "кН", "м", "хв" for Ukraine instead of "kN", "m", "min").

So far, the only solution I see is creating a dictionary — translating the engine's "native" units into the required ones, and vice versa.

Vitalii,

Unfortunately, there is no global mechanism to change the symbols for now.

And the only solution for localization is creating a converter: string<->unit.

The base where you can start is TUnitConverter from Physix.Units.Converter.pas.

This class is not sealed and has several protected methods to override where you

can replace the symbols with the required one. So, you can write a descendant of the class

for realizing a localization engine.

1 Like

I got it, Sergey! Thanks)