Home/ Reference/ Geometry & Transform

shape.AddToSelection() / .RemoveFromSelection()

Add to or drop from the selection. Build up a batch this way, then process it in one pass.

Signature

shape.AddToSelection() / .RemoveFromSelection()

Notes

Add to or drop from the selection. Build up a batch this way, then process it in one pass.

Python example (runnable)

Requires pywin32. The example assumes app / doc / page / layer are already connected. See Connection & Init
Python
page = doc.ActivePage

# select every shape on this page
for i in range(1, page.Shapes.Count + 1):
    page.Shapes.Item(i).AddToSelection()

rng = app.ActiveSelectionRange
print("Selected: ", rng.Count, " item(s)")

# drop one of them
page.Shapes.Item(1).RemoveFromSelection()
print("After removing one: ", app.ActiveSelectionRange.Count)

About this section: Geometry & Transform

Geometry & Transform — position, size and rotation of shapes.

Other entries in this section