Dimension text has wrong alignment in export by matplotlib backend #319
-
First of all, many thanks to Manfred for creating and maintaining this great library! I'm using the dimlines addon to create dimension annotations before generating quick PDF preview of the DXF file contents for the user via the matplotlib backend. The dimension text is properly centred in the DXF, but if exported into PDF the text is not centred to the middle of the dimension line and instead starts from the middle and continues to the right of the center. Is there any simple solution to fix this? Or do I have to generate the annotations from scratch on my own using just simple entities? I'm using the dimlines since the days of dxfwrite... so if there is no easy fix for this, it will mean quite some refactoring for me. Thanks for any suggestions. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 2 replies
-
Do you have other software that is able to view dxf files that you could open your generated file in? I'm wondering whether the issue is in the generation of the dxf or the rendering of it. Also if you could provide a small example showing the problem that would be useful |
Beta Was this translation helpful? Give feedback.
-
FreeCAD on Linux does not render at all: PDF output is offset to the right: I'm sorry that the example files are different in most cases, but the basic idea stays the same. |
Beta Was this translation helpful? Give feedback.
-
could this be related to #310 ? have you tried the latest code from git? wait, never mind. You were worried about the text and not the arrows overhanging, although it does look like they are in the image you posted (which should be fixed now) if you post the dxf file that you're showing above I can take a look at how it decides where to put the text |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot! This file was generated in version 14.2, but I checked with 15.1 too and the PDF result is the same. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I think I figured it out. Looks like to handle this case the insert should be ignored and the align_point should be used instead. In most cases it looks like the insert is set so that it lies at the left-baseline of the text (probably the CAD application takes care of this normally but the dxf file is valid if this is not the case). I determined this from looking at the dxfattributes:
I've opened a pull request with my fix: #320 |
Beta Was this translation helpful? Give feedback.
-
Well, from question to fix available in the repo within 20 hours... Talk about open source magic. I tried on top of your branch text_alignment (0.15.2a0) and this fixes my issue. All dimension texts are now positioned properly in the PDF. I will wait how it will turn out with the MR #320. Many thanks for your work! |
Beta Was this translation helpful? Give feedback.
I think I figured it out. Looks like to handle this case the insert should be ignored and the align_point should be used instead. In most cases it looks like the insert is set so that it lies at the left-baseline of the text (probably the CAD application takes care of this normally but the dxf file is valid if this is not the case).
It looks like the CAD applications trust the alignment point more than the insert location for where to place the text, so ezdxf should do the same.
I determined this from looking at the dxfattributes: