Updating Dynamic Text

Updating Dynamic Text
 1# This example updates all dynamic text entities in the active layer.
 2
 3# Create a local variable for the output toolbox
 4ot = impact.gui.output_toolbox
 5
 6# Clear the output toolbox
 7ot.clear()
 8
 9# Create a local variable for the active drawing
10ad = impact.active_drawing
11
12# Check that there is an active drawing
13if not ad.isNone():
14
15    # Recalculate all text entities in the active layer
16    ad.active_layer.recalculate_text_entities()
17
18    # Display a success message
19    ot.add("Successfully updated text entities")
20
21else:
22
23    # Display a message in the output toolbox
24    ot.add("Unable to continue: no active drawing")