Enquire Individual Lengths of Cut palettes

Enquire Individual Lengths of Cut palettes
 1# This example shows how to determine the lengths of all cut type
 2# lines within the active layer. It shows how to calculate the
 3# lengths of all cut palettes in a single operation, then
 4# examine the individual palettes to determine the length of each.
 5
 6ot = impact.gui.output_toolbox
 7ot.clear()
 8
 9# Convertor object for formatting the values nicely
10conv = impact.system.convertor
11
12# Check there is an active drawing
13ad = impact.active_drawing
14if ad.isNone():
15    ot.add("Unable to continue: There is no active drawing")
16else:
17
18    # This is the object which does all the work
19    enquire = ad.active_layer.root_block.enquire_lengths
20
21    enquire.palette_types = ipPaletteType.ptCut
22    enquire.entity_types = [ipEntityType.etLine, ipEntityType.etInsert]
23    enquire.recurse = True
24    enquire.selected_entities_only = False
25    enquire.visible_entities_only = False
26
27    # This is where the calculations are done
28    enquire.perform()
29
30    # Now we output all the results
31    ot.add("Total Cut Line Extents: " + str(conv.length_as_string(enquire.extents.width)) + " x " + str(conv.length_as_string(enquire.extents.height)))
32    ot.add("Total Cut Line Length: " + str(conv.length_as_string(enquire.length)))
33
34    for palette in ad.palettes:
35        pal_len = palette.enquire_length
36        if pal_len > 0:
37            ot.add("  Palette: " + palette.full_name + ": " + str(conv.length_as_string(pal_len)))