Describe the bug
I have some DWG files, and after converting them to DXF files using ODAFileConverter, I found that some of the layer names are strings like "\M+5D7DF\M+5CFDF\M+5BCDC".
When attempting to read these DXF files using ezdxf, an error occurred.
The error message is as follows:
Traceback (most recent call last):
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/addons/drawing/qtviewer.py", line 256, in _select_doc
doc, auditor = recover.readfile(path)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/recover.py", line 80, in readfile
doc, auditor = read(fp, errors=errors)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/recover.py", line 105, in read
return _load_and_audit_document(recover_tool)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/recover.py", line 142, in _load_and_audit_document
doc._load_section_dict(recover_tool.section_dict)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/document.py", line 394, in _load_section_dict
loader.load_and_bind_dxf_content(sections, self)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/lldxf/loader.py", line 156, in load_and_bind_dxf_content
factory.bind(entity, doc)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entities/factory.py", line 88, in bind
doc.entitydb.add(entity)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entitydb.py", line 173, in add
entity.add_sub_entities_to_entitydb(self) # type: ignore
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entities/subentity.py", line 80, in add_sub_entities_to_entitydb
self.new_seqend()
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entities/subentity.py", line 87, in new_seqend
seqend = factory.create_db_entry("SEQEND", attribs, self.doc)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entities/factory.py", line 63, in create_db_entry
entity = new(dxftype=dxftype, dxfattribs=dxfattribs)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entities/factory.py", line 53, in new
entity = cls(dxftype).new(
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entities/dxfentity.py", line 166, in new
entity.update_dxf_attribs(attribs)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entities/dxfentity.py", line 448, in update_dxf_attribs
setter(key, value)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entities/dxfns.py", line 230, in set
self.__setattr__(key, value)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entities/dxfns.py", line 172, in __setattr__
self.__dict__[key] = check(value)
File "/home/maslke/.local/lib/python3.10/site-packages/ezdxf/entities/dxfns.py", line 161, in check
raise const.DXFValueError(
ezdxf.lldxf.const.DXFValueError: Invalid value \M+5D7DF\M+5CFDF\M+5BCDC for attribute "layer" in entity SEQEND(#None).
I have tracked the code, and found codes in validator.py:
def is_valid_table_name(name: str) -> bool:
# remove backslash of DXF unicode encoding \U+xxxx
chars = set(name.replace(r"\U+", ""))
return not bool(INVALID_LAYER_NAME_CHARACTERS.intersection(chars))
In above code, removes \U+ , but \U+ is not be removed.
If I edited is_valid_table_name like this, this dxf file will be read successfully.
def is_valid_table_name(name: str) -> bool:
# remove backslash of DXF unicode encoding \U+xxxx
chars = set(name.replace(r"\U+", "").replace(r"\M+", ""))
return not bool(INVALID_LAYER_NAME_CHARACTERS.intersection(chars))
So,\M+ should be removed? Or, it is just a issue with my dxf fie and it's not a common issue.
Describe the bug
I have some DWG files, and after converting them to DXF files using ODAFileConverter, I found that some of the layer names are strings like "\M+5D7DF\M+5CFDF\M+5BCDC".
When attempting to read these DXF files using ezdxf, an error occurred.
The error message is as follows:
I have tracked the code, and found codes in validator.py:
In above code, removes \U+ , but \U+ is not be removed.
If I edited is_valid_table_name like this, this dxf file will be read successfully.
So,\M+ should be removed? Or, it is just a issue with my dxf fie and it's not a common issue.