From 9189dec644331f959353ca78434dc3350251f8f4 Mon Sep 17 00:00:00 2001 From: Stanislav <42420548+PushKK@users.noreply.github.com> Date: Fri, 9 Jan 2026 13:00:36 +0300 Subject: [PATCH] Draft Workbench: Patch for import DXF without CODE30 (Z for POINT) (#26778) * Patch for DXF without CODE30 (Z for POINT) Time to time I use DXF file from measurement microscope without Z for POINT. This patch help me for download this files without errors. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/Mod/Draft/importDXF.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index b1205dec35..9f69be7442 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -1984,10 +1984,16 @@ def addText(text, attrib=False): The DXF object of type `'text'` or `'mtext'`. attrib : bool, optional - It defaults to `False`. If `True` it determines - the layer name from the DXF code 8, the text value from code 1, - the position from codes 10, 20, 30, the height from code 40, - the rotation from code 50, and assigns the name `'Attribute'`. + It defaults to `False`. + If `True` it determines from the DXF: + - the text value - code 1, + - the text colour - code 6, + - the text font - code 7, + - the layer name - code 8, + - the position (X, Y, Z) - codes 10, 20, 30, + - the text height - from code 40, + - the rotation angle - from code 50, + and assigns the name `'Attribute'`. Otherwise, it assumes these values from `text` and sets the name to `'Text'`. @@ -2640,7 +2646,11 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True): for point in points: x = vec(rawValue(point, 10)) y = vec(rawValue(point, 20)) - z = vec(rawValue(point, 30)) + # For DXF file without Z values. + if rawValue(point, 30): + z = vec(rawValue(point, 30)) + else: + z = 0 lay = rawValue(point, 8) if dxfImportLayouts or (not rawValue(point, 67)): if dxfMakeBlocks: