'EntitySection' object has no attribute 'query'

260 views
Skip to first unread message

Kevin Lu

unread,
Sep 9, 2020, 2:13:38 AM9/9/20
to python-ezdxf
Hi, I try to query entities in specific layer. However, the AttributeError shows : 'EntitySection' object has no attribute 'query'.
I had read the tutorial, it said "The ENTITIES section also supports the query() method", and the origin code is:

lines_and_circles = doc.entities.query('LINE CIRCLE[layer=="construction"]') 

When I run the code in tutorial, the same error: 'EntitySection' object has no attribute 'query' was shown.
How to fix this error and achieve the goal I want?
Thank you for your help.

Manfred Moitzi

unread,
Sep 9, 2020, 2:49:39 AM9/9/20
to python-ezdxf
The entities section is not real section, and I guess you want to query the modelspace: doc.modelspace().query()

If you really want to query the entities space, which represents the entities of the modelspace and the "active" paperspace, import the EntityQuery object:

from ezdxf.query import EntityQuery
result = EntityQuery(doc.entities, "... query string ...")
Reply all
Reply to author
Forward
0 new messages