Parameter Along¶
Parameter Along¶
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 = impact.creator.vector(1.0, 0.5)
22
23 # create some local variables for the control points of the bezier
24 x1 = 0
25 y1 = 0
26 x2 = 1
27 y2 = 0
28 x3 = 1
29 y3 = 1
30 x4 = 0
31 y4 = 1
32
33 # create the bezier
34 bezier = ab.bezier_ad(x1, y1, x2, y2, x3, y3, x4, y4)
35
36 # Declare some variables to store the results
37 result = 0.0
38 height = None
39
40 # Call the method
41 result = bezier.parameter_along(v, height)
42
43 # Display the results
44 ot.add(result)
45 ot.add(height)
46
47else:
48 ot.add("No Active Drawing")
49