Scaling a line¶
Scaling a line¶
1# this example creates a line in the active block and scales it
2
3# check there is an active drawing
4if impact.active_drawing.isNone():
5
6 # display a message in the output toolbox
7 impact.gui.output_toolbox.add("Unable to continue: there is no active drawing")
8
9else:
10
11 # create a local variable for the active block
12 ab = impact.active_drawing.active_layer.active_block
13
14 # move to a position in the active block
15 ab.move_ad(-50, 0)
16
17 # create a line
18 line1 = ab.line_ad(50, 0)
19
20 # check the line was created
21 if line1 is not None:
22
23 # create some local variables for the Value, OriginX, OriginY, Retain and
24 # NumCopies options
25 scale_value = 2
26 origin_x = 0
27 origin_y = 0
28 retain = 0
29 num_copies = 1
30
31 # select only the line created earlier
32 ab.select_none()
33 line1.selected = 1
34
35 # scale the line
36 ab.scaled(scale_value, origin_x, origin_y, retain, num_copies)