Deleting a palette

Deleting a palette
 1# this example attempts to delete the palette named "testa" from the active drawing
 2# if this palette is already used by the drawing, it is replaced with one named "testa_1"
 3
 4# create a local variable for the output toolbox
 5ot = impact.gui.output_toolbox
 6
 7# Clear the output toolbox
 8ot.clear()
 9
10# Create a local variable for the active drawing
11ad = impact.active_drawing
12
13# Check there is an active drawing
14if ad.isNone():
15
16    # Display an error message in the output toolbox
17    ot.add("Unable to continue: no active drawing")
18
19else:
20    d_palettes = ad.palettes
21
22    pal_to_delete = d_palettes.item("testa")
23    pal_to_become = d_palettes.item("testa_1")
24
25    if not pal_to_delete is None and not pal_to_become is None:
26        d_palettes.delete(pal_to_delete, pal_to_become)
27