vagran / dxf-viewer

DXF 2D viewer written in JavaScript
Mozilla Public License 2.0
310 stars 97 forks source link

Getting scales or measurements #11

Closed carlblock closed 2 years ago

carlblock commented 2 years ago

First of all thanks for taking time to improve the original dxf-parser! I've working on doing an adaption of this library for react-three-fiber.

But there's some feature sets I've been considering to try to include. Right now I've been been a bit stuck on how to find ways on how to work with the scales in the DXF files, generally to enable the user to measure a distance or to normalise the different sizes of the dxf files that sometimes seems to widely different in terms of scale.

I've seen there's bounds and the origin measurements but I'm unsure if they can have any relation with calculating the document scale or line lengths in terms of millimetres/meters or other document scales. A good example of implementation I found was the Autodesk online viewer. My question is if anyone else has worked on this or have any insights in how this can be implemented?

Thanks!

vagran commented 2 years ago

After some quick research a have an impression that there is no well-defined specification for that but $INSUNITS header variable is often used for that purpose. Also from my experience, when it is a drawing for some geo-spatial object like construction site, the drawing model space coordinate system ususally corresponds to some well-defined projected coordinate reference system (CRS or SRS in GIS terms), and it is specified somewhere among with the DXF and thus fully defines its scale and global position.