Custom Unit Descriptions

Custom Unit Descriptions - Сообщения

#1 Опубликовано: 06.08.2020 12:28:00
ironwizard

ironwizard

0 сообщений из 2 понравились пользователям.

Группа: User

Hey all,

I've been trying to add some units to Smath that aren't supported natively (specifically unit weight in pcf, linear load in plf, and flow rate in gpm, cfs, etc...) I've been able to successfully add all of this to the units.xml file and they work just fine. The issue I have is that I'm trying to add the descriptions of these units to the language file so that it displays correctly in the dynamic help dialog during use.

I have edited my ENG.lang file as follows:

Цитата

ENG
English
97765104672
iVBORw0KGgoAAAANSUhEUgAAABAAAAALCAIAAAD5gJpuAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHzSURBVHjaYkxOP8IAB//+Mfz7w8Dwi4HhP5CcJb/n/7evb16/APL/gRFQDiAAw3JuAgAIBEDQ/iswEERjGzBQLEru97ll0g0+3HvqMn1SpqlqGsZMsZsIe0SICA5gt5a/AGIEarCPtFh+6N/ffwxA9OvP/7//QYwff/6fZahmePeB4dNHhi+fGb59Y4zyvHHmCEAAAW3YDzQYaJJ93a+vX79aVf58//69fvEPlpIfnz59+vDhw7t37968efP3b/SXL59OnjwIEEAsDP+YgY53b2b89++/awvLn98MDi2cVxl+/vl6mituCtBghi9f/v/48e/XL86krj9XzwEEEENy8g6gu22rfn78+NGs5Ofr16+ZC58+fvyYwX8rxOxXr169fPny+fPn1//93bJlBUAAsQADZMEBxj9/GBxb2P/9+S/R8u3vzxuyaX8ZHv3j8/YGms3w8ycQARmi2eE37t4ACCDGR4/uSkrKAS35B3TT////wADOgLOBIaXIyjBlwxKAAGKRXjCB0SOEaeu+/y9fMnz4AHQxCP348R/o+l+//sMZQBNLEvif3AcIIMZbty7Ly6t9ZmXl+fXj/38GoHH/UcGfP79//BBiYHjy9+8/oUkNAAHEwt1V/vI/KBY/QSISFqM/GBg+MzB8A6PfYC5EFiDAABqgW776MP0rAAAAAElFTkSuQmCC
Andrey Ivashov (78.2%), Anonymous (12%), tivasyk (9.4%), Other (0.3%), Davor Košturić (0.1%)
2019.02.26.10
d54d74e83ab84e518dd54929051f09ed
//717
Save changes in
Author
E-Mail
Web-site

...

On error
Continue
Pause
Interrupt
Unit Weight
Linear Load
Flow Rate

//130
Finds the derivative of expression {0} relative to variable {1}.
X-Y plot.



With my additions and changes highlighted. When I do this, Smath fails to launch. If I remove the unit descriptions (I.e. the lower change in the snippet), Smath will launch just fine. If I launch with my units.xml file pointing to ids past 714 (i.e. for the new descriptions), the dynamic help shows an empty string for those units. Additionally, if I launch with the changed count at the top, Smath will throw an error when attempting to insert a unit, and I won't be able to sort by type of unit (velocity, force, etc...) in the resulting dialogue.

So my question is, what am I doing wrong? What do I need to do to get Smath to accept my additional unit descriptions? I've searched the forums and my best guess is that I'm running afoul of some kind of protection? Is it possible that the long string on line 4 is a hash for verification and my changes mean it's no longer valid?

Thanks,
-Sean
#2 Опубликовано: 07.08.2020 12:40:03
ironwizard

ironwizard

0 сообщений из 2 понравились пользователям.

Группа: User

Sorry, I could have clarified. Flow rate in this case is volumetric, cubic feet per minute and such,

As I said, I have all my units added to the units.xml file and they work just fine. I just can't get the descriptions added to the ENG.lang file to work.
#3 Опубликовано: 07.08.2020 13:04:38
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: Moderator

I think that the lang file are hardwired, no chance for ordinary users to add, you can just modify existing entries.

Thus, using the units.xml file lacks the chance of adding description texts. Also, this approach is non-portable. Your files won't work in an SMath installation without your particular units.xml.

You might use a snippet instead.
These are ordinary SMath files which can be embedded in any other file just by typing their name, usually as collapsed area region. And in ordinary SMath sheets you can define units with descriptions in whatever set of languages.

The advantage is that such files are portable. The disadvantage is that they aren't updated when you update your unit snippet.

This auto-update can be achieved using the plugin-mechanism. It also includes portability, as the dependence on plugin and version is stored in the sm file and any user with an installation lacking this plugin will be offered to download it from the online gallery in the extension manager.

Of course, you can ask Andrey to include your units in the next update. That would be the easiest and most straightforward way for the users.
This, however, would require you to stick to common standards and not to invent arbitrary units of convenience.
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
2 пользователям понравился этот пост
sergio 07.08.2020 13:11:00, frapuano 07.08.2020 14:09:00
#4 Опубликовано: 07.08.2020 17:26:15
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Hi. I agree with Martin. Also, in the standard way to introduce new units in SMath, you can add your own unit description, again, in the standard form.

Clipboard02.jpg


I don't check if you can add different description for different languages.

Best regards.
Alvaro.
#5 Опубликовано: 07.08.2020 21:59:30
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

This document is SS 6179.
If you have red, expect some user of your SS version to doctor.

Inst_Colebrook Pipe Data.sm (71 КиБ) скачан 42 раз(а).
#6 Опубликовано: 12.05.2023 13:16:02
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

74 сообщений из 164 понравились пользователям.

Группа: User

Greetings,

Wrote

So my question is, what am I doing wrong? What do I need to do to get Smath to accept my additional unit descriptions?


Simply do not reference the *.lang file; that is: do not specify an 「id」. Instead, I would advise you to just declare a 「title」 field.

If you inspect the 「Constants.xml」 file, you will notice the constant "ε.0" does not reference an id, but just defines a 「title」 of value "Vacuum permittivity"; the 「title」 field IS the value that is displayed as the SMath unit description.

    <add factor="8.85418781762039" exp="-12" connection="{A^2*s^4}/{kg*m^3}" [h]title="Vacuum permittivity"[/h] lang:rus="Электрическая постоянная">
      <synonym name="ε.0" />
    </add>

    <add factor="2.04548" exp="3" connection="(kg/{s^2*m})^0.5" [h]id="612">[/h]<!-- id='612' : Hildebrand, solubility parameter -->
      <synonym name="hildebrand" />
    </add>
"No matter where you go, there you are." -Buckaroo BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений