Move example (Python)¶
Move example (Python)¶
1# this example moves by a specified offset then creates a line, moves by the
2# specified offset again and creates another line
3
4# check there is an active drawing
5if impact.active_drawing.isNone():
6
7 # display a message in the output toolbox
8 impact.gui.output_toolbox.add("Unable to continue: there is no active drawing")
9
10else:
11
12 # create a local variable for the active block
13 ab = impact.active_drawing.active_layer.active_block
14
15 # create a local variable for the Offset option
16 offset = None
17 try:
18 offset = impact.creator.vector(50,50)
19 except Exception as exc:
20 pass
21 impact.gui.output_toolbox.add(f"Failed to create object via impact.creator.vector(): {exc}")
22
23 # move by the specified offset
24 ab.move(offset)
25
26 # create a line
27 ab.lined(100, 0)
28
29 # move by the specified offset
30 ab.move(offset)
31
32 # create a line
33 ab.lined(0, 100)