Units for data entry

Thank you, devbisme!

pint looks very interesting! I’m trying to do only length and area conversions suitable with pcbnew, with no dependencies to install for the average KiCad user.

If I get to the point of figuring out how to teach others how to install dependencies, I’ll take a look at pint!

If you are going so far as to implement three notations for nanometer and micrometer, you could as well implement ‘thou’ for 1 mil.

Hi,

I do not know for what that is going to be used, but if you list Mils and Inches as well as Microns and Millimeters ¿ what about Centimeter ?

I just ask because 1 Inch equals 2.54cm :slight_smile:

regards Rainer

Thanks ikletti and rsfoto! cm and thou are added!

“m” is for meter, not for milli meter.
centimeter [cm] is often used by “common people” but not much by engineers. They tend to stick to exponents with multiples of 3.
And cm is in lower case. not Centi…

Also, have you considered a default unit for cases the user does not explicitly specify a unit?
The most logical is probably to copy the settings from “Set units to mm/Inch” in the left margin when in EEschem / PcbNew. Maybe “guess” them from the locale when it is for external tools

1 Like

Thank you! Yes, I forgot the *1000 for ‘m’. I know the “centi”, “milli”, and “nano” are not really proper (they’re only prefixes), but I’ve included them just in case. I changed the code to generate the squared values automatically. The non-squared list is now:

'':1,
'nm':1,
'nano':1,
'nanometer':1,
'nanometers':1,
'um':pcbnew.IU_PER_MM/1000.0,
'micron':pcbnew.IU_PER_MM/1000.0,
'microns':pcbnew.IU_PER_MM/1000.0,
'micrometer':pcbnew.IU_PER_MM/1000.0,
'micrometers':pcbnew.IU_PER_MM/1000.0,
'mm':pcbnew.IU_PER_MM,
'millimeter':pcbnew.IU_PER_MM,
'millimeters':pcbnew.IU_PER_MM,
'milli':pcbnew.IU_PER_MM,
'm':pcbnew.IU_PER_MM*1000,
'meter':pcbnew.IU_PER_MM*1000,
'meters':pcbnew.IU_PER_MM*1000,
'thou':pcbnew.IU_PER_MILS,
'mil':pcbnew.IU_PER_MILS,
'mils':pcbnew.IU_PER_MILS,
'cm':pcbnew.IU_PER_MM*10,
'centi':pcbnew.IU_PER_MM*10,
'centimeter':pcbnew.IU_PER_MM*10,
'centimeters':pcbnew.IU_PER_MM*10,
'in':pcbnew.IU_PER_MILS*1000.0,
'inch':pcbnew.IU_PER_MILS*1000.0,
'inches':pcbnew.IU_PER_MILS*1000.0,
"'":pcbnew.IU_PER_MILS*1000.0*12, # feet
'"':pcbnew.IU_PER_MILS*1000.0, # inches

further food for thought:

eagle binary formats use 0.1 micron units

kicad legacy uses decimils, dmil, 0.1mil, and

pcb-rnd / gEDA PCB uses centimils, cmil, 0.01mil, for element dimensions in the absence of units in […] brackets, .

otherwise your list would cover most use cases.

pcb-rnd and gEDA PCB define these units in the units.h file:

http://igor2.repo.hu/cgi-bin/minisvn.cgi?cmd=cat&repo=pcb-rnd&path=trunk/src/unit.h

Cheers,

Erich.

This will be used for data entry and file formats for dealing with dimensions in KiCad.

Hmmm… This increases the ambiguity of the lonely “centi”, “nano”, and “milli”. I think I’ll remove those and maybe add the kicad legacy, and gEDA default format. The routine that will use this conversion will have a “default units” field and it’d be REALLY good to be able to specify those defaults with a unit. I’ll change the routine to accept a number as a default as well.

The routine I am developing is nominally for design rule files. But I will likely use it for text box entries in KiPadCheck.

As also suggested, the default for text boxes will be derived from the “inch/mm” user selection.

erichVK5, thanks for the link to pcb-rnd code! I’ve added “dmil” and “cmil” to the definitions.

Thanks for all the feedback! It’s being incorporated into KiPadCheck.

The units list is now:

conversion = {
'':1,
'nm':1,
'nanometer':1,
'nanometers':1,
'um':pcbnew.IU_PER_MM/1000.0,
'micron':pcbnew.IU_PER_MM/1000.0,
'microns':pcbnew.IU_PER_MM/1000.0,
'micrometer':pcbnew.IU_PER_MM/1000.0,
'micrometers':pcbnew.IU_PER_MM/1000.0,
'decimicron':pcbnew.IU_PER_MM/10000.0,
'decimicrons':pcbnew.IU_PER_MM/10000.0,
'du':pcbnew.IU_PER_MM/10000.0,
'dus':pcbnew.IU_PER_MM/10000.0,
'dum':pcbnew.IU_PER_MM/10000.0,
'dums':pcbnew.IU_PER_MM/10000.0,
'mm':pcbnew.IU_PER_MM,
'millimeter':pcbnew.IU_PER_MM,
'millimeters':pcbnew.IU_PER_MM,
'm':pcbnew.IU_PER_MM*1000,
'meter':pcbnew.IU_PER_MM*1000,
'meters':pcbnew.IU_PER_MM*1000,
'km':pcbnew.IU_PER_MM*1000000,
'kilometer':pcbnew.IU_PER_MM*1000000,
'kilometers':pcbnew.IU_PER_MM*1000000,
'thou':pcbnew.IU_PER_MILS,
'mil':pcbnew.IU_PER_MILS,
'mils':pcbnew.IU_PER_MILS,
'dmil':pcbnew.IU_PER_MILS/10.0,
'dmils':pcbnew.IU_PER_MILS/10.0,
'decimil':pcbnew.IU_PER_MILS/10.0,
'decimils':pcbnew.IU_PER_MILS/10.0,
'cmil':pcbnew.IU_PER_MILS/100.0,
'cmils':pcbnew.IU_PER_MILS/100.0,
'centimil':pcbnew.IU_PER_MILS/100.0,
'centimils':pcbnew.IU_PER_MILS/100.0,
'cm':pcbnew.IU_PER_MM*10,
'centimeter':pcbnew.IU_PER_MM*10,
'centimeters':pcbnew.IU_PER_MM*10,
'in':pcbnew.IU_PER_MILS*1000.0,
'inch':pcbnew.IU_PER_MILS*1000.0,
'inches':pcbnew.IU_PER_MILS*1000.0,
'"':pcbnew.IU_PER_MILS*1000.0, # inches
"'":pcbnew.IU_PER_MILS*1000.0*12, # feet
'feet':pcbnew.IU_PER_MILS*1000.0*12,
'foot':pcbnew.IU_PER_MILS*1000.0*12,
}
# squared versions of measurements (three types: 2, **2, ^2)
1 Like

Metre is the correct spelling in many countries, hence “Metric”

1 Like

Is ‘metre’ also used with all the SI prefixes too
(nanometre, centimetre, millimetre)?

1 Like

I’ve added all units with ‘meter’ spelled ‘metre’ as well, including plurals.

Thanks!

1 Like

[quote=“HiGreg, post:17, topic:7281”]
I’ve added all units with ‘meter’ spelled ‘metre’ as well, including plurals.
[/quote]Isn’t this the job of a “translation package”?
I wouldn’t like it if this whole list gets sucked into a pull down menu and the menu won’t fit on the schreen because it has a gazillion options for the same.

I don’t expect it to be a pull down. It is simply for text entry by users.

You don’t expect it to be a pull down (or other) menu NOW, but code gets reused later in multiple ways.
And for text entry no sane user is going to type in words like “micrometer”.
I think that supporting the standarized SI units and a few basic imperoal ones should be enough, but it also seems like too much effort in too small a detail.

Unfortunately Metre is the SI spelling, the US and most Brits get it wrong

2 Likes

The reason we (UK) use French spellings is because we were invaded by French speaking Normans. After the initial cultural shock, it became fashion to “Frenchify” the language. Whether this was a genuine appreciation of French culture or a desire to ingratiate the new rulers, I’m not sure. Spellings such as “centre”, “colour”, “hotel” were adopted, even though they are still pronounced like “center” and “color”. Many loanwords were adopted, such as mutton, beef etc. Some words were adopted twice with different spellings, e.g. warranty and guarantee, hotel and hostel.

Many words in politics, law and the military are derived from French, as the Normans took key roles in all those areas.

Not just spelling, but also names. Traditional English names like Ethelred disappeared, replaced with Thomas, David, Henry etc. Normans also introduced the idea of surnames. By default, people were named after their occupation, so “Smith” became the most common surname.

It’s somewhat ironic that modern Brits often disparage the French, but we were hugely influenced by the Norman invasion. Although, Normans weren’t native French either, they were occupied and then ruled by Vikings that settled in France. (Norman = Norse-men, literally “men from the North”).

Anyway, I actually prefer the US spellings, they make more sense. Also, the US spell checker is often the default, so it is easier just to use that.