ViewBox (Python)¶
ViewBox (Python)¶
1# This example creates a line in the active block and zooms into
2# the extents of the line
3
4# Create a local variable for the impact.gui
5g = impact.gui
6
7# Create a local variable for the output toolbox
8ot = g.output_toolbox
9
10# Clear the output toolbox
11ot.clear()
12
13# Create a local variable for the active drawing
14ad = impact.active_drawing
15
16# Check there is an active drawing
17if ad.isNone():
18
19 # Add an error message to the output toolbox
20 ot.add("unable to continue: no active drawing")
21
22else:
23
24 # Create a local variable for the active block
25 ab = ad.active_layer.active_block
26
27 # Move to position 0, 0
28 ab.move_ad(0, 0)
29
30 # Create a line in the active block
31 line1 = ab.line_ad( 100, 100 )
32
33 # View the extents of the line
34 g.active_window.view_box(line1.extents)