CopyEntities example¶
CopyEntities example¶
1# this example copies all the entities in the active block
2
3# define some local variables
4ab = impact.active_drawing.active_layer.active_block
5entities = ab.entities
6
7the_count = entities.count
8
9# check there are some entities to copy
10if not the_count == 0:
11
12 # create an array to store the entities to be copied
13 entities_to_copy = None
14
15 # redimension the array to the required size
16 entities_to_copy = [None] * the_count
17
18 # initialise the contents of the array
19 for i in range(1, the_count + 1):
20 entities_to_copy[i-1] = entities.item(i)
21
22 # specify the origin of the new entities
23 origin_x = 2000
24 origin_y = 2000
25 origin_mode = ipOriginMode.omBottomLeft
26
27 # set the scale to 2
28 scale = 2
29
30 # set the angle to 0
31 angle = 0
32
33 # do not mirror in the x direction
34 mirror_x = 0
35
36 # do not mirror in the y direction
37 mirror_y = 0
38
39 # copy the specified entities
40 ab.copy_entities(origin_x, origin_y, origin_mode, scale, angle, mirror_x, mirror_y, 0, entities_to_copy)
41