Iterating bridges (Python)

Iterating bridges (Python)
 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
26            ot.add(" ")
27            ot.add("--- Entity --- ")
28
29            # Create a local variable for the entity bridges
30            bridges = entity.bridges
31
32            ot.add(" ")
33
34            # Ensure there are some bridges for the entity
35            if bridges.count > 0:
36
37                ot.add("StartAbsolute")
38                ot.add(" ")
39
40                for bridge in bridges:
41                    ot.add(bridge.start_absolute)
42                ot.add(" ")
43                ot.add("StartRelative")
44                ot.add(" ")
45
46                for bridge in bridges:
47                    ot.add(bridge.start_relative)
48                ot.add(" ")
49                ot.add("CentreAbsolute")
50                ot.add(" ")
51
52                for bridge in bridges:
53                    ot.add(bridge.centre_absolute)
54                ot.add(" ")
55                ot.add("CentreRelative")
56                ot.add(" ")
57
58                for bridge in bridges:
59                    ot.add(bridge.centre_relative)
60            else:
61
62                ot.add("This entity has no bridges")
63
64else:
65
66    # Display a message in the output toolbox
67    impact.gui.output_toolbox.add("unable to continue: no active drawing")