GetPaletteExtents example¶
GetPaletteExtents example¶
1# this example gets the palette extents of several palettes in the
2# active block
3
4# check there is an active drawing
5if impact.active_drawing.isNone():
6
7 # display a message in the output toolbox
8 impact.gui.output_toolbox.add("Unable to continue: there is no active drawing")
9
10else:
11
12 # create a local variable for the active drawing
13 ad = impact.active_drawing
14
15 # create a local variable for the active block
16 ab = ad.active_layer.active_block
17
18 # create a local variable to store the palettes to get the extents of
19 palettes = [None] * 2
20
21 # set the palettes to get the extents of
22 palettes[0] = ad.palettes.item("Cut")
23 palettes[1] = ad.palettes.item("Crease")
24
25 # get the palette extents
26 rect = ab.get_palette_extents(palettes)
27
28 # display the result in the output toolbox
29 impact.gui.output_toolbox.add(rect.to_string())
30