Parameter Along (Python)¶
Parameter Along (Python)¶
1# This example creates a new 360 degree arc (a circle) with a radius of 50,
2# start angle of 270 and centre point at 0, 50 in the active block. A vector is
3# then created at the position 0, 200. This vector is then passed as an argument
4# to the IArc.parameter_along method, the results of the method are displayed in
5# the output toolbox.
6
7# Create a local variable for the output toolbox
8ot = impact.gui.output_toolbox
9
10# Clear the output toolbox
11ot.clear()
12
13if not impact.active_drawing.isNone():
14
15 # Create a local variable for the active block
16 ab = impact.active_drawing.active_layer.active_block
17
18 # Move to the origin of the active block
19 ab.move_ad(0, 0)
20
21 # Create a vector
22 v = None
23 try:
24 v = impact.creator.vector(0, 200)
25 except Exception as exc:
26 pass
27 impact.gui.output_toolbox.add(f"Failed to create object via impact.creator.vector(): {exc}")
28
29 # Create a local variable for the radius
30 radius = 50
31
32 # Create two local variables for the position for the offset
33 positionX = 0
34 positionY = 0
35
36 # Create a clockwise large arc
37 arc = ab.arc_ad( positionX, positionY, radius, 0, 0 )
38
39 # Declare some variables to store the results
40 result = 0.0
41 height = None
42
43 # Call the method
44 result = arc.parameter_along( v, height )
45
46 # Display the results
47 ot.add(result)
48 ot.add(height)
49
50else:
51
52 ot.add("No Active Drawing")