Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not recover a DXF created by Microsoft Visio Professional: ezdxf.lldxf.const.DXFStructureError: HATCH: unknown edge type: 0 #836

Closed
jsimomaa opened this issue Feb 16, 2023 · 1 comment

Comments

@jsimomaa
Copy link

Describe the bug
Trying to recover a corrupted DXF file created and exported by Microsoft Visio Professional fails with an error.

Oddly enough, the file seems to contain multiple hatches with multiple 0 values for tag 72. The drawing contains both texts as fonts and as objects.

Traceback (most recent call last):
  File "/workspaces/test/utils/read_file.py", line 17, in read_dxf
    [drawing, _] = recover.readfile(file_name)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/recover.py", line 79, in readfile
    doc, auditor = read(fp, errors=errors)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/recover.py", line 104, in read
    return _load_and_audit_document(recover_tool)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/recover.py", line 141, in _load_and_audit_document
    doc._load_section_dict(recover_tool.section_dict)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/document.py", line 387, in _load_section_dict
    loader.load_and_bind_dxf_content(sections, self)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/lldxf/loader.py", line 150, in load_and_bind_dxf_content
    for index, entity in enumerate(load_dxf_entities(section, doc)):
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/lldxf/loader.py", line 142, in load_dxf_entities
    yield factory.load(ExtendedTags(entity), doc)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/entities/factory.py", line 69, in load
    entity = cls(tags.dxftype()).load(tags, doc)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/entities/dxfentity.py", line 224, in load
    entity.load_tags(tags, dxfversion=dxfversion)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/entities/dxfentity.py", line 249, in load_tags
    self.dxf = self.load_dxf_attribs(processor)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/entities/polygon.py", line 80, in load_dxf_attribs
    tags = self.load_paths(tags)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/entities/polygon.py", line 107, in load_paths
    self.paths = BoundaryPaths.load_tags(path_tags)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/entities/boundary_paths.py", line 130, in load_tags
    else EdgePath.load_tags(path_tags)
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/entities/boundary_paths.py", line 713, in load_tags
    edge_path.edges.append(edge_path.load_edge(edge_tags))
  File "/home/vscode/.local/lib/python3.10/site-packages/ezdxf/entities/boundary_paths.py", line 722, in load_edge
    raise const.DXFStructureError(
ezdxf.lldxf.const.DXFStructureError: HATCH: unknown edge type: 0

To Reproduce
Information and data needed to reproduce the error:

  1. Simplified script triggering the error:
from ezdxf import recover
from ezdxf.document import Drawing

def read_dxf(file_name):
    if file_name.lower().endswith('.dxf'):
        [drawing, _] = recover.readfile(file_name)
        return drawing

read_dxf("SVGtextimportedtoVisiov2.dxf")
  1. Versions:
$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ python3 --version
Python 3.10.9
$ pip show ezdxf
Name: ezdxf
Version: 1.0.2b1
Summary: A Python package to create/manipulate DXF drawings.
Home-page: https://ezdxf.mozman.at
Author: Manfred Moitzi
Author-email: me@mozman.at
License: MIT License
Location: /home/vscode/.local/lib/python3.10/site-packages
Requires: pyparsing, typing-extensions
Required-by: 

Confidential Data
SVGtextimportedtoVisiov2.zip

Expected behavior
Do something magical with the file what QCAD does as well? 😄

Screenshots
In Microsoft Visio Professional before saving as DXF:
image

In QCAD:
image

@mozman
Copy link
Owner

mozman commented Feb 16, 2023

It's a wonder that Autodesk TrueView opens that file and the only reason for me to fix this issue.

BricsCAD crashes in normal mode and fixes 246 errors in RECOVER mode, this file is a joke!

@mozman mozman closed this as completed Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants