Tidy Slots

Tidy Slots
 1# This example creates a slot (rectangle) and tidys it
 2
 3# Create a local variable for the impact.gui
 4g = impact.gui
 5
 6# Create a local variable for the output toolbox
 7ot = g.output_toolbox
 8
 9# Clear the output toolbox
10ot.clear()
11
12# Create a local variable for the active drawing
13ad = impact.active_drawing
14
15# Check there is an active drawing
16if ad.isNone():
17
18    # Display a message in the output toolbox
19    ot.add("Unable to continue: there is no active drawing")
20
21else:
22
23    # Create a local variable for the active block
24    ab = ad.active_layer.active_block
25
26    # Move to the origin
27    ab.move_ad(0, 0)
28
29    # Create a rectangle (slot)
30    line1 = ab.line_ad(10, 0)
31    line2 = ab.line_ad(10, 100)
32    line3 = ab.line_ad(0, 100)
33    line4 = ab.line_ad(0, 0)
34
35    # Ensure None is selected (auto select may be on)
36    ab.select_none()
37
38    # Select all the lines
39    line1.selected = True
40    line2.selected = True
41    line3.selected = True
42    line4.selected = True
43
44    # Define some local variables for the method parameters
45    max_slot_width = 90
46    max_slot_angle = 10
47    tidy_flap_slots = True
48    tidy_lock_slots = True
49
50    # Tidy the slots
51    ab.tidy_slots(max_slot_width, max_slot_angle, tidy_flap_slots, tidy_lock_slots)
52
53    # View the extents
54    g.active_window.view_extents()
55
56
57
58
59