Parameter Along (Python)

Parameter Along (Python)
 1# This example creates a new bezier in the active block. A vector is
 2# then created at the position 1.0, 0.5. This vector is then passed as an argument
 3# to the IBezier.parameter_along method, the results of the method are displayed in
 4# 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(1.0, 0.5)
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 some local variables for the control points of the bezier
29    x1 = 0
30    y1 = 0
31    x2 = 1
32    y2 = 0
33    x3 = 1
34    y3 = 1
35    x4 = 0
36    y4 = 1
37
38    # create the bezier
39    bezier = ab.bezier_ad( x1, y1, x2, y2, x3, y3, x4, y4 )
40
41    # Declare some variables to store the results
42    result = 0.0
43    height = None
44
45    # Call the method
46    result = bezier.parameter_along( v, height )
47
48    # Display the results
49    ot.add(result)
50    ot.add(height)
51
52else:
53
54    ot.add("No Active Drawing")