Extending a line (Python)¶
Extending a line (Python)¶
1# This example creates a new line and then extends it (from the end)
2# by 50% of the original length of the line.
3
4# Create a local variable for the active drawing
5ad = impact.active_drawing
6
7# Check that there is an active drawing
8if not ad.isNone():
9
10 # Create a local variable for the active block
11 ab = impact.active_drawing.active_layer.active_block
12
13 # Move to the origin of the active block
14 ab.move_ad(0, 0)
15
16 # Create a new line
17 newLine = ab.line_ad( 100, 0 )
18
19 # Define some parameters for the ILine.extend method
20 extension = newLine.length / 2
21 fromStart = False
22
23 # Extend the line
24 newLine.extend(extension, fromStart)
25
26else:
27
28 # Display a message in the output toolbox
29 impact.gui.output_toolbox.add("unable to continue: no active drawing")