OffsetSelected example¶
OffsetSelected example¶
1# This example creates a line and offsets it
2
3# Create a local variable for the output toolbox
4ot = impact.gui.output_toolbox
5
6# Clear the output toolbox
7ot.clear()
8
9# Create a local variable for the active drawing
10ad = impact.active_drawing
11
12# Check there is an active drawing
13if ad.isNone():
14
15 # Display a message in the output toolbox
16 ot.add("Unable to continue: there is no active drawing")
17
18else:
19
20 # Create a local variable for the active block
21 ab = ad.active_layer.active_block
22
23 # Ensure no entities are selected
24 ab.select_none()
25
26 # Move to the origin of the active block
27 ab.move_ad(0, 0)
28
29 # Create a line
30 line1 = ab.line_ad(100, 0)
31
32 # Select the line
33 line1.selected = 1
34
35 # impact.creator local variable for the SideToOffset, OffsetDistance, etc. options
36 v = impact.creator.vector(10, 10)
37 offset_distance = 100
38 leave_original = 0
39 sharp_corners = 0
40
41 # Offset the selected line
42 ab.offset_selected(line1, v, offset_distance, leave_original, sharp_corners)
43