Parameter Along (Python)

Parameter Along (Python)
 1# This example creates a new line from coordinates 0,0 to 100, 0
 2# in the active block. A vector is then created at the position 150, 50. This
 3# vector is then passed as an argument to the ILine.parameter_along method, the
 4# results of the method are displayed in the output toolbox.
 5
 6# Create a local variable for the output toolbox
 7ot = impact.gui.output_toolbox
 8
 9# Clear the output toolbox
10ot.clear()
11
12if not impact.active_drawing.isNone():
13
14    # Create a local variable for the active block
15    ab = impact.active_drawing.active_layer.active_block
16
17    # Move to the origin of the active block
18    ab.move_ad(0, 0)
19
20    # Create a vector
21    v = None
22    try:
23        v = impact.creator.vector(150, 50)
24    except Exception as exc:
25        pass
26    impact.gui.output_toolbox.add(f"Failed to create object via impact.creator.vector(): {exc}")
27
28    # Create a line
29    line = ab.line_ad( 100, 0 )
30
31    # Declare some variables to store the results
32    result = 0.0
33    height = None
34
35    # Call the method
36    result = line.parameter_along( v, height )
37
38    # Display the results
39    ot.add(result)
40    ot.add(height)
41
42else:
43
44    ot.add("No Active Drawing")