mozman / ezdxf

Python interface to DXF
https://ezdxf.mozman.at
MIT License
937 stars 191 forks source link

TypeError: 'PatternLine' object is not iterable #1082

Closed cl33 closed 6 months ago

cl33 commented 6 months ago

The source code is as follows:

import ezdxf
from ezdxf.addons.dxf2code import entities_to_code, block_to_code

doc = ezdxf.readfile('3807.dxf')
msp = doc.modelspace()
source = entities_to_code(msp)

# create source code for a block definition
block_source = block_to_code(doc.blocks['MyBlock'])

# merge source code objects
source.merge(block_source)

with open('source.py', mode='wt') as f:
    f.write(source.import_str())
    f.write('\n\n')
    f.write(source.code_str())
    f.write('\n')

The error encountered is as follows:

File "E:\MyProject\image\test_cad.py", line 6, in source = entities_to_code(msp) File "E:\Anaconda\envs\tensroflow\lib\site-packages\ezdxf\addons\dxf2code.py", line 86, in entities_to_code code.translate_entities(entities, ignore=ignore) File "E:\Anaconda\envs\tensroflow\lib\site-packages\ezdxf\addons\dxf2code.py", line 348, in translate_entities self.translate_entity(entity) File "E:\Anaconda\envs\tensroflow\lib\site-packages\ezdxf\addons\dxf2code.py", line 328, in translate_entity entity_translator(entity) File "E:\Anaconda\envs\tensroflow\lib\site-packages\ezdxf\addons\dxf2code.py", line 746, in _hatch self._polygon(entity) File "E:\Anaconda\envs\tensroflow\lib\site-packages\ezdxf\addons\dxf2code.py", line 764, in _polygon self.add_list_source_code( File "E:\Anaconda\envs\tensroflow\lib\site-packages\ezdxf\addons\dxf2code.py", line 386, in add_list_source_code self.add_source_code_lines(_fmt_list(values, indent=4 + indent)) File "E:\Anaconda\envs\tensroflow\lib\site-packages\ezdxf\addons\dxf2code.py", line 375, in add_source_code_lines self.code.add_lines(code) File "E:\Anaconda\envs\tensroflow\lib\site-packages\ezdxf\addons\dxf2code.py", line 197, in add_lines for line in code: File "E:\Anaconda\envs\tensroflow\lib\site-packages\ezdxf\addons\dxf2code.py", line 252, in _fmt_list v = tuple(tuple(v)) TypeError: 'PatternLine' object is not iterable

mozman commented 6 months ago

Where is the the DXF file? What OS? Which Python version? Which ezdxf version?

There is a template for issues you could have followed to save me all these questions.