Select a collection of entities

Select a collection of entities
 1ab = impact.active_drawing.active_layer.active_block
 2
 3# Put various entities into an array
 4ents_array = []
 5ents_count = 0
 6for ent in ab.entities:
 7    if ent.geometric:
 8        if ent.palette.palette_type == ipPaletteType.ptCut:
 9            ents_array = (list(ents_array or []) + [None] * (ents_count + 1))[:ents_count + 1]
10            ents_array[ents_count] = ent
11            ents_count = ents_count +1
12
13impact.gui.output_toolbox.add("Found " + str(ents_count) + " matching entities")
14
15# Now convert the array to a collection and perform the selection on the collection
16if ents_count > 0:
17    ents_coll = impact.creator.entities(ents_array)
18    ab.select(ents_coll, True)
19
20