Skip to content
Discussion options

You must be logged in to vote

The bbox.extends() method calculates bounding boxes of entities: https://ezdxf.mozman.at/docs/bbox.html

The result is a bounding box class: https://ezdxf.mozman.at/docs/math.html#boundingbox

from ezdxf.math import BoundingBox

dxf_types = ['ARC','CIRCLE','HATCH','INSERT','LINE','LWPOLYLINE','MTEXT']
search_box = BoundingBox([(495, 585), (547, 585), (547, 537), (495, 537), (495, 585)])
cache = bbox.Cache()
for dxf_type in dxf_types:
    entity_boxes = bbox.multi_flat(msp.query(dxf_type), cache=cache)
    for entity_box in entity_boxes:
        print(search_box.inside(entity_box.extmin) and search_box.inside(entity_box.extmax))

print(cache)  # if there are very few hits and you don't reuse…

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@c-chaitanya
Comment options

@mozman
Comment options

@mozman
Comment options

Comment options

You must be logged in to vote
1 reply
@c-chaitanya
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by c-chaitanya
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants