BezierA example (Python)

BezierA example (Python)
 1# this example creates a bezier in the active block
 2
 3# check there is an active drawing
 4if impact.active_drawing.isNone():
 5
 6    # display a message in the output toolbox
 7    impact.gui.output_toolbox.add("Unable to continue: there is no active drawing")
 8
 9else:
10
11    # create a local variable for the active block
12    ab = impact.active_drawing.active_layer.active_block
13
14    # move to the origin of the active block
15    ab.move_ad(0, 0)
16
17    # create four vectors for the control points of the bezier
18    v1 = None
19    try:
20        v1 = impact.creator.vector(0,0)
21    except Exception as exc:
22        pass
23    impact.gui.output_toolbox.add(f"Failed to create object via impact.creator.vector(): {exc}")
24    v2 = None
25    try:
26        v2 = impact.creator.vector(10,20)
27    except Exception as exc:
28        pass
29    impact.gui.output_toolbox.add(f"Failed to create object via impact.creator.vector(): {exc}")
30    v3 = None
31    try:
32        v3 = impact.creator.vector(30,20)
33    except Exception as exc:
34        pass
35    impact.gui.output_toolbox.add(f"Failed to create object via impact.creator.vector(): {exc}")
36    v4 = None
37    try:
38        v4 = impact.creator.vector(40,0)
39    except Exception as exc:
40        pass
41    impact.gui.output_toolbox.add(f"Failed to create object via impact.creator.vector(): {exc}")
42
43    # create the bezier
44    ab.bezier_a(v1, v2, v3, v4)