vagran / dxf-viewer

DXF 2D viewer written in JavaScript
Mozilla Public License 2.0
290 stars 86 forks source link

Support DIMBLK #80

Open KaivnD opened 1 year ago

KaivnD commented 1 year ago

Hi! I have a dxf file export from netDxf, like this image

the LinearDimension in this drawing use DIMBLK1 and DIMBLK2 for dimension arrow style, which is ArchitecturalTick , but when I open it use dxf-viewer arrow style becomes this image

I found out only DIMTSZ is larger than 0 will draw arrow as tick, my question is, will dxf-viewer support DIMBLK for Dimension arrow rendering? https://github.com/vagran/dxf-viewer/blob/63485967cc7fdd06d93960b76ba0508f525d96f2/src/LinearDimension.js#L101

here is my dxf file DIMBLK.zip

vagran commented 1 year ago

Hi! Regarding dimensions support, in most real world files I have touched, dimensions are defined among with a pre-rendered block, which is referenced by a DIMENSION entity. These blocks already contain proper representation of a dimension in a form of lines, polygons, texts and other primitives, generated by a CAD software, so the DXF viewer can display them exactly in the same way as seen in the corresponding CAD software. On the other hand, dimension can be described by dozens of parameters which in theory should result in the same displayed result, however it is not really well documented to properly implement it, and also each CAD software may interpret it slightly differently. dxf-viewer has some implementation for rendering dimension based solely on the specified parameters, however, due to a lack of sufficient amount of examples and lack of proper specification of that, it is not really well tested and is still considered experimental. Current implementation is mostly based on findings documented in ezdxf project. Currently, it does not account DIMBLK parameter. As you properly noticed, switching between ticks and arrows is based on DIMTSZ parameter value, which is based on AutoDesk documentation for this parameter. As I see in your example file, DIMTSZ parameter is not specified (so is zero by default, according to the same documentation). Also, in your file DIMBLK parameter has empty string value, and DIMBLK1 and DIMBLK2 are not present. So there is probably some misunderstanding about ArchitecturalTick value, which is not present in the example file you have provided. We can add some support for these parameters, having proper example and some understanding about how they should be properly handled.

KaivnD commented 1 year ago

@vagran thanks for explanation I'll take a look why AutoCAD present this file correctly. and here is some relevant code, to explain why I say earlier

use DIMBLK1 and DIMBLK2 for dimension arrow style, which is ArchitecturalTick

https://github.com/haplokuon/netDxf/blob/9bb9df935ec364f52ac8d2dea79b89ebfdbd20e5/netDxf/Tables/DimensionStyle.cs#L596-L618

https://github.com/haplokuon/netDxf/blob/9bb9df935ec364f52ac8d2dea79b89ebfdbd20e5/netDxf/Entities/DimensionArrowhead.cs#L675-L698