The last notice for now.
My DXF file attached in my first ticket was originally made using mm as main unit. Because DXF file rarely has declared units in it (but according to this it can be declared), I read that dxf2pcb in the first place suppose an imperial (inch) as a main unit of DXF file. So everytime I do the conversion I have to declare scale factor of 0.03937 (and need to calculate it over and over) to get right objects size again in converted PCB file. I don't know how accurate is that unit conversion but do the unit conversion cannot be accurate at all notably when converted PCB file uses mils as it's unit. That's the twice unit conversion. I read somewhere in mailing list that gEDA gradually moves it's internals into metric system, is that right?
Scale feature is real good one but it's usage for unit conversions is IMHO not the right use case.
As a quick solution I propose to add four cli switches -mm2mm, -mm2mil, -mil2mil and -mil2mm to tell dxf2pcb in which unit is source DXF file and which unit is desired in converted PCB file. But it is not much user friendly as better solution is automatic recognition of source DXF file units (if it is possible) and use the same units in the PCB file in the first place without any additional switches of course.
Jiri
I don't think the unit conversions introduce significant error. I'm doing my calculations using Python's default floating-point data type, which is double-precision. A coordinate of 10 (inches, mm, or whatever) will have error down in the 10^-14 range. In other words, if you want a value of 10 exactly, you might end up with 9.99999999999999 to 10.00000000000001.
A unit conversion switch is a good idea, though. I'll add it soon.
It's more about user experience to not mess up with different kind of units (pcb, footprints, snipets etc.) during one development cycle. For that reason I've proposed to do automatic unit identification of DXF file before start doing any kind of conversions. But not all time there are units stored in DXF file so that switches can in some cases manually override that automatic unit recognition. A two years ago I've made some little tool to do that unit conversions within footprint files (here. It's far from perfect but at time I wrote it works pretty well for my purpose.
Sure I'm convinced that it is better to do not even one unit conversion when it is not absolute necessary. One of all stories stored in my head Mars Probe Lost Due to Simple Math Error. There are many more of them known though.
I just added two switches to better handle unit confersion.
The -iun switch selects input units for the DXF.
The -ilu switch selects input line weight units (in case they are different from the drawing units).
Changing the output units is a bit more involved, especially if you want mixtures (I often want coordinates in mm but drills and clearances in mil). Anyway, these switches eliminate the need to use the scaling feature just to get the units to come out right.
I'll start a new ticket for the output units feature and close this one.
I confirm that the new switch -iun work as expected, so -scl switch do not need to be used for original DXF unit conversion.
One more note to the conversion precision. On geda-user mailing list Kai-Martin Knaak states what I cite here: "My guess in the dark would be, that dxf2pcb does not do
nanometer precision, which is the resolution pcb uses since a few years.
If dxf2pcb emits coords given in integer multiples of 1 mil, it kind of
jettisons three orders of magnitude of precision."
dxf2pcb, in it's present state (v1.5.3), outputs all PCB data in units of cmil (centi-mils, 1/100000 inch). So the precision is on the order of 0.25 micrometers. Ticket 5 will take care of this since other output units (mm and mil) are rendered to the file in floating point.
So that really answers the question, why some lines are and some are not merged during PCB file import.
I just released v1.5.5 which can read drawing units from the DXF file.
I've just tried the new version on file guides.dxf from my first ticket. The Warning message appears: Warning: Unknown drawing units designation 'unitless' in DXF file, ignoring.
As of I cannot find string 'unitless' inside that DXF file using fulltext search I guess that warning message is some kind of universal message. Is it?
The script reads drawing units from DXF Group Code 9, value $INSUNITS. It is reprsented as an integer where 0 indicates unitless, 1=inches, 2=feet, 3=miles, 4=mm, etc. The word "unitless" comes from a look-up table (dictionary) in the script (at line 23 in version 1.5.6).