Border Plot - Data Connection Arguments

Border Plot - Data Connection Arguments
 1# This example creates a border plot for the active drawing. It uses the
 2# settings 'Examples|Data Repeaters|Data Repeater XmlFile' and locates
 3# a data repeater on the first page of the report. It then assigns an
 4# new XmlFile argument to the data connector being used
 5
 6# Create a local variable for the database
 7db = impact.active_database
 8
 9# Create a local variable for the output toolbox
10ot = impact.gui.output_toolbox
11
12# Clear the output toolbox
13ot.clear()
14
15if not impact.active_drawing.isNone():
16
17    # get a border plot impact.creator
18    bp = db.border_plot_creator
19
20    # assign a border plot settings to use
21    bp.settings = db.find_master_tool_setting("Examples|Data Repeaters|Data Repeater XmlFile", ipMasterSettingType.mstBorderPlot)
22
23    # assign the source drawing
24    bp.source_drawing = impact.active_drawing
25
26    # check the settings loaded and all areas are matched
27    if bp.valid:
28
29        # find a data repeater on the first page
30        page = bp.pages.item(1)
31
32        ot.add("Template: " + str(page.template.reference))
33
34        dr = page.data_repeaters.item(1)
35
36        if not dr.isNone():
37
38            # use the data connector to set required arguments
39            dc = dr.data_connector
40
41            if dc is not None:
42                ot.add("DataConnector Type: " + str(dc.type))
43
44                # list all current arguments
45                for i in range(1, dc.argument_count  + 1):
46                    ot.add("Argument " + str(dc.argument_name(i)) + ": " + str(dc.get_argument(i)))
47
48                # set the XmlFile argument
49                dc.set_argument("XmlFile", r"D:\\Summary.xml")
50
51            else:
52                ot.add("Unable to locate data connector")
53
54        else:
55            ot.add("Unable to locate data repeater")
56
57        # create the border plot
58        if bp.create():
59
60            # check for a destination drawing
61            drawing = bp.destination_drawing
62
63            if drawing is not None:
64                ot.add("Successfully created border plot '" + bp.settings.full_name + "' in " + str(drawing.full_name))
65
66            else:
67                ot.add("Successfully output border plot '" + bp.settings.full_name + "'")
68
69        else:
70            ot.add("Unable to create the border plot '" + bp.settings.full_name + "'")
71
72    else:
73        ot.add("Unable to load the border plot settings")
74
75else:
76    ot.add("No Active Drawing")