View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004037 | Expressions | Feature | public | 2019-06-25 23:36 | 2021-02-06 06:30 |
Reporter | uwestoehr | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 0.18 | ||||
Target Version | 0.20 | ||||
Summary | 0004037: rewrite unit handling so that unit prefixes will be recognized | ||||
Description | Currently we have the case that the expression parser knows units with prefixes, e.g. "mA". For other units like e.g. "j", it does not know any prefix. To overcome this, the expression parser must be rewritten so that it recognizes these prefixes: n, mu/µ, m, k, M, G and connects them automatically to the unit that follows directly on the prefix letter. So "ncd" will be recognized as "we have 'n' -> nano (10^-9), the next letter is 'c' which could be part of a known unit that begins with 'c', the next letter is 'd' so we know we have the unit "cd" with the prefix 'n'. However "n A" will be recognized as "we have 'n' -> nano (10^-9), the next letter is ' ' (space), so we don't have a unit connected to the prefix letter 'n' and we issue an error. This method would lead to - consistent handling of all units - support for unit prefixes for all units | ||||
Additional Information | Forum thread: https://forum.freecadweb.org/viewtopic.php?f=38&t=37164 The idea was approved as useful by @berndhahnebach | ||||
Tags | expressions, units | ||||
FreeCAD Information | |||||
|
https://en.wikipedia.org/wiki/Unit_prefix |
|
Be very careful to side effects ! I'd not want that 'min' unit being considered as "milli-inch" instead of the correct "minute". ;) |
|
> I'd not want that 'min' unit being considered as "milli-inch" Yes, the procedure should be 1. read the whole given unit and if it is known like "min" then nothing is done and the unit is taken as it is 2.1 if the unit is unknown, check if it begins with a known letter of unit prefixes 2.2 if yes, read the unit beginning with the second character and if this is a known unit, use it multiplied with the factor according to the read unit prefix 3. if 1. and 2. did not lead to a known unit, deny the unit and issue an error message |
|
I think a better approach is perhaps to hard-code a set of given prefixes to units that they are compatible with. For example, “milli”, “kilo”, etc, are commonly accepted with metric units. Not so much for imperial- I’ve never heard of a milli-inch |
|
This ticket has been migrated to GitHub as issue 5955. |
Date Modified | Username | Field | Change |
---|---|---|---|
2019-06-25 23:36 | uwestoehr | New Issue | |
2019-06-25 23:36 | uwestoehr | Tag Attached: expressions | |
2019-06-25 23:36 | uwestoehr | Tag Attached: units | |
2019-06-25 23:36 | uwestoehr | Additional Information Updated | |
2019-06-25 23:36 | uwestoehr | Additional Information Updated | |
2019-06-26 20:20 | berndhahnebach | Note Added: 0013313 | |
2019-06-30 14:15 | openBrain | Note Added: 0013321 | |
2019-07-01 09:07 | uwestoehr | Note Added: 0013326 | |
2019-11-29 13:40 | ezzieyguywuf | Note Added: 0013851 | |
2021-02-06 06:30 | abdullah | Target Version | => 0.20 |