mozman / dxfgrabber

Outdated DXF reader, please switch to ezdxf (UNMAINTAINED)
Other
67 stars 15 forks source link

Problem with Attrib #5

Closed etienne67 closed 7 years ago

etienne67 commented 7 years ago

Hello, In one DXF (the file attached), I have a problem with the attrib of an insert. The attrib is not recognised by DXFGrabber: the insert object has 0 attrib whereas in the DXF there as 1 attrib (named lot). Can you explain the problem ? Thank you. dessin test56-pb-Attrib.zip

mozman commented 7 years ago

To INSERT attached attribs are stored in a list Insert.attribs

see documentation: https://dxfgrabber.readthedocs.io/en/latest/#insert

import dxfgrabber

dxf = dxfgrabber.readfile('dessin test56-pb-Attrib.dxf')

print('DXF contains {} entities'.format(len(dxf.entities)))

for entity in dxf.entities:
    print(entity.dxftype)
    if entity.dxftype == 'INSERT':
        for attrib in entity.attribs:
            print('    TAG:{}'.format(attrib.tag))
            print('    TEXT:{}'.format(attrib.text))

Best regards, Manfred

etienne67 commented 7 years ago

Hello, I knew how to use Attribs, and it has worked well for several drawings until now, but I found last week one drawing in which dxfgrabber didn't find the attrib (the DXF I sent to you). So this weekend I looked for solving that problem, and in fact, I found that the problem was due to a slightly modification I made in your dxfentities.py code in order to manage a new attribute for the text (attachment_point like in MTEXT), and there was a slight mistake in that new code. So I found the solution to my problem. Thank you, and sorry for the inconvenience.

Best regards. Etienne