Intersect Entity (Python)

Intersect Entity (Python)
 1# Get the active block
 2myBlock = impact.active_drawing.active_layer.active_block
 3
 4# Get two entities from the block
 5e1 = None
 6try:
 7    e1 = myBlock.entities.item(1)
 8except Exception as exc:
 9    impact.gui.output_toolbox.add(f"Failed to create object via my_block.entities.item(): {exc}")
10e2 = None
11try:
12    e2 = myBlock.entities.item(2)
13except Exception as exc:
14    impact.gui.output_toolbox.add(f"Failed to create object via my_block.entities.item(): {exc}")
15
16points = None
17i = None
18
19# get the points at which the two entities
20# intersect
21points = e1.intersect_entity( e2, ipIntersectType.itSeg1Seg2 )
22
23# display the points
24for i in range(0, len(points) - 1 + 1):
25    impact.gui.output_toolbox.add(str(points(i)).X)
26    impact.gui.output_toolbox.add(str(points(i)).Y)