"Drawing units: inches" while loading file in millimeters. Don't know why.

749 views
Skip to first unread message

Wojciech Nycz

unread,
Nov 6, 2015, 8:51:29 AM11/6/15
to dxf2gcode-dev
Hi guys.
It's been a while since i had the chance to use D2G.

Today I started a new project for my machine. I've made a drawing as usually, exported it to .dxf and started up D2G.
After loading the file i saw "Drawing units: inches". I was sure I've created the file in mm, exported in mm, drawn in mm. Millimeters everywhere!!!
I'm using DraftSight as my main CAD, and i was using it before with normal results. But i also have LibreCAD. I've loaded the file into LibreCAD, saved it straight away under different name and loaded that into D2G.
This time the loaded units were mm.

I'm not sure how those two CAD software handle DXF differently but maybe someone could take a look at the files and see why D2G reads one as inches and the other as millimeters?

Cheers,
InnerBushman
plyty_beton.dxf
plyty_beton2.dxf

Christian Kohlöffel

unread,
Nov 10, 2015, 3:18:24 PM11/10/15
to dxf2gc...@googlegroups.com
HI Bushman,

just had a look in the code, the attached function is handling the import of the units. This means it's searching for:
  1. MESUREMENT
  2. INSUNITS

So check your file if you find a difference there ....

regards Christian


    def Get_Unit(self, str):
        """
        Get_Unit() - Get unit of measure English (Imperial) or Metric from DXF file
        """
        # Set drawing units: 0 = English; 1 = Metric
        # Metric will be treated as being in millimeters
        # English as inches

        metric = 1  # default: metric
        try:
            line = 0
            while not str[line].startswith("$MEASUREMENT"):
                line += 1
            metric = int(str[line + 2].strip())
        except:  # $MEASUREMENT not found or is incorrect
            pass

        # Default drawing units for AutoCAD DesignCenter blocks:
        # 0 = Unitless; 1 = Inches; 2 = Feet; 3 = Miles; 4 = Millimeters;
        # 5 = Centimeters; 6 = Meters; 7 = Kilometers; 8 = Microinches;
        # 9 = Mils (thous); 10 = Yards; 11 = Angstroms; 12 = Nanometers;
        # 13 = Microns; 14 = Decimeters; 15 = Decameters;
        # 16 = Hectometers; 17 = Gigameters; 18 = Astronomical units;
        # 19 = Light years; 20 = Parsecs
        try:
            line = 0
            while not str[line].startswith("$INSUNITS"):
                line += 1
            line += 2
            if int(str[line].stip()) == 1:
                metric = 0
            elif int(str[line].strip()) == 4:
                metric = 1
        except:  # $INSUNITS not found or is incorrect
            pass

        return metric


Am 06.11.2015 um 14:51 schrieb Wojciech Nycz:
Hi guys.
It's been a while since i had the chance to use D2G.

Today I started a new project for my machine. I've made a drawing as usually, exported it to .dxf and started up D2G.
After loading the file i saw "Drawing units: inches". I was sure I've created the file in mm, exported in mm, drawn in mm. Millimeters everywhere!!!
I'm using DraftSight as my main CAD, and i was using it before with normal results. But i also have LibreCAD. I've loaded the file into LibreCAD , saved it straight away under different name and loaded that into D2G.

This time the loaded units were mm.

I'm not sure how those two CAD software handle DXF differently but maybe someone could take a look at the files and see why D2G reads one as inches and the other as millimeters?

Cheers,
InnerBushman
--
--
You received this message because you subscribed to the Google
Groups-group "dxf2gcode-dev".
To post a message, send mail to dxf2gc...@googlegroups.com
To unsubscribe, send mail to dxf2gcode-de...@googlegroups.com
See http://groups.google.de/group/dxf2gcode-dev?hl=en for more options
and the dxf2gcode project page at http://code.google.com/p/dxf2gcode/
---
You received this message because you are subscribed to the Google Groups "dxf2gcode-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dxf2gcode-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

JP

unread,
Nov 16, 2015, 2:31:21 AM11/16/15
to dxf2gcode-dev
Hi here some information of your dxf

plyty_beton.dxf (has two declarations of units)

@846
$MEASUREMENT
 70
     0
  9


0 means inches

while at

@866
$INSUNITS
 70
     4
  9

4 means millimeters


Some contradiction here....


plyty_beton2.dxf ( has only one)
has @172
$INSUNITS

 70
     4
  9


But I'm not sure why you get two different results because INSUNITS is the last one checked (and those two are the same)

Maybe I made a bug don't know...?? Need to debug it, but don't have the time for this currently.

Victor Leung

unread,
Jan 30, 2016, 5:31:41 PM1/30/16
to dxf2gcode-dev
Hi developers,

(Suggestion) Would it be nicer to have an option during Import to say "Units:" , which user can select "Auto Detect" / "mm" / "inch"

Cheers
Victor

JP

unread,
Feb 1, 2016, 3:03:19 AM2/1/16
to dxf2gcode-dev
To InnerBushman,
I have fixed it thanks to the sharp eye stated in https://groups.google.com/forum/#!topic/dxf2gcode-users/az-AhgOPPyU.

To Victor would be nice indeed also not too much work. But you can already sort of convert it by applying the scale all - probably would be a config setting. Might implement it soon - have to work out some details.

Victor Leung

unread,
Feb 1, 2016, 5:12:35 PM2/1/16
to dxf2gcode-dev
Hi JP.

Thanks for considering my suggestion. I think I have read somewhere that DXF does not officially contain a unit concept. It is just coordinates. So it make some sense to prompt user for picking the right one. I think UX-wise is very important to be bug user about this decision. 
Reply all
Reply to author
Forward
0 new messages