Iterating bridges

Iterating bridges
 1# Create a local variable for the output toolbox
 2ot = impact.gui.output_toolbox
 3
 4# Clear the output toolbox
 5ot.clear()
 6
 7# Create a local variable for the active drawing
 8ad = impact.active_drawing
 9
10# Check that there is an active drawing
11if not ad.isNone():
12
13    # Create a local variable for the active block
14    ab = ad.active_layer.active_block
15
16    # Create a local variable for the entities in the active block
17    entities = ab.entities
18
19    # Iterate the entities
20    for entity in entities:
21
22        # Check to see if the entity is geometric meaning the entity will
23        # have a Bridges collection
24        if entity.geometric:
25            ot.add(" ")
26            ot.add("--- Entity --- ")
27
28            # Create a local variable for the entity bridges
29            bridges = entity.bridges
30
31            ot.add(" ")
32
33            # Ensure there are some bridges for the entity
34            if bridges.count > 0:
35                ot.add("StartAbsolute")
36                ot.add(" ")
37
38                for bridge in bridges:
39                    ot.add(bridge.start_absolute)
40
41                ot.add(" ")
42                ot.add("StartRelative")
43                ot.add(" ")
44
45                for bridge in bridges:
46                    ot.add(bridge.start_relative)
47
48                ot.add(" ")
49                ot.add("CentreAbsolute")
50                ot.add(" ")
51
52                for bridge in bridges:
53                    ot.add(bridge.centre_absolute)
54
55                ot.add(" ")
56                ot.add("CentreRelative")
57                ot.add(" ")
58
59                for bridge in bridges:
60                    ot.add(bridge.centre_relative)
61
62            else:
63                ot.add("This entity has no bridges")
64
65else:
66
67    # Display a message in the output toolbox
68    impact.gui.output_toolbox.add("unable to continue: no active drawing")