1
$\begingroup$

I'm an software dev and my job is to convert a .dxf file into a .svg file

My code actually works, but there are some issues with the dimensions or something similar. Unfortunately, i have no background in technical drawing whatsoever.

The finished .svg looks different from what expected.

When using an online .dxf to .svg converter it works. The .svg looks as expected from the customer.

My guess is that there seems to be something in the header of the .dxf file that I'm ignoring. I've read through several documents but i can't figure out why my .svg looks different.

Expected:

enter image description here

What i am getting:

enter image description here

Its much smaller and its flipped. Ignore the color, i filled every hexagon on purpose! Looking at the converted .svg in detail, all coordinates are different from what it says in the .dxf

This is the header of the .dxf file:

header:

$ACADVER: "AC1012"
$AUNITS: 0
$CELTYPE: "BYLAYER"
$CLAYER: "0"
$DIMALT: 0
$DIMALTF: 0.0393700787
$DIMASZ: 3.5
$DIMBLK: "_FILLED"
$DIMCEN: 5.346
$DIMDLI: 22.572
$DIMEXE: 1
$DIMEXO: 0
$DIMGAP: 0.625
$DIMLFAC: 1
$DIMLIM: 0
$DIMSCALE: 1
$DIMTFAC: 1
$DIMTM: 0.01
$DIMTOL: 1
$DIMTP: 0.01
$DIMTXT: 3.5
$DWGCODEPAGE: "ANSI_1252"
$EXTMAX: {x: 594, y: 420, z: 0}
$EXTMIN: {x: 0, y: 0, z: 0}
$HANDSEED: "CEF6"
$LIMMAX: {x: 594, y: 420}
$LIMMIN: {x: 0, y: 0}
$LTSCALE: 32.67
$PDMODE: 3
$PDSIZE: 0.05
$TILEMODE: 1
$VIEWCTR: {x: 297, y: 210}
$VIEWSIZE: 420
$\endgroup$
1
  • 3
    $\begingroup$ Dxf has a bottom corner coordinate where y is up. Which is common for physical mediums. Whereas svg has a top corner y is down measurement which is common for monitors because thats the refresh order of the screen. But to be honest this does not at all seem to be the right place to ask. $\endgroup$
    – joojaa
    Commented Aug 19, 2020 at 10:16

1 Answer 1

4
$\begingroup$

SVG and images in general define a coordinate system with

  • positive x towards the right
  • positive y towards the bottom

I.e. the pixels with coordinate y=1 are near the top.

On the other hand dwg, defines a coordinate system with

  • positive x towards the right
  • positive y upwards

All you need to do is flip your svg along the x axis, either on the original or in the final svg.

$\endgroup$
1
  • 2
    $\begingroup$ You may also need to offset the if you use the extent info so it lays out somehow sane. But thats offcourse optional $\endgroup$
    – joojaa
    Commented Aug 19, 2020 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.