Circle example (Python)

Circle example (Python)
 1# this example creates a circle 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    # create some local variables for offset, radius, etc.
15    offset = None
16    try:
17        offset = impact.creator.vector(100,100)
18    except Exception as exc:
19        pass
20    impact.gui.output_toolbox.add(f"Failed to create object via impact.creator.vector(): {exc}")
21    radius = 50
22    startAngle = 45
23    antiClockwise = 0
24
25    # move to the origin of the active block
26    ab.move_ad(0, 0)
27
28    # create a circle
29    ab.circle(offset, radius, startAngle, antiClockwise)