Opening Database Windows¶
Opening Database Windows¶
1# This script shows how to display Database Windows for both internal and external tables
2# including for child tables by supplying a parent key
3
4ui = impact.gui
5ot = ui.output_toolbox
6
7db = impact.active_database
8ad = impact.active_drawing
9
10ot.clear()
11
12# open the configured CUSTOMER Database Window (either built-in CUSTOMER or remote customer table)
13if ui.open_database_window("CUSTOMER", None):
14 ot.add("A CUSTOMER record was modified")
15
16if not ad.isNone():
17
18 # open the configured layer type Database Window (for the impact.active_drawing.active_layer)
19 if ui.open_database_window(ad.active_layer.layer_type, None):
20 ot.add(str(ad.active_layer.layer_type) + " information was modified")
21
22 # open the integrated Database Window
23 if ui.open_database_window("<INTEGRATED>", None):
24 ot.add("Something was changed in the impact.active_drawing")
25
26# open a specific Database Window directly
27dbw = db.find_master_tool_setting("Palettes", ipMasterSettingType.mstDBWindow)
28
29if dbw is not None:
30 ot.add("Successfully located setting " + str(dbw.full_name))
31
32 call(ui.open_database_window2(dbw, None))
33
34else:
35 ot.add("Unable to locate Database Window 'Palettes'")
36
37# the following examples use advanced database window options
38
39# open the configured DRAWINGS Database Window in read only mode
40if not ad.isNone():
41 opts = ui.create_database_window_options()
42
43 opts.read_only = True
44
45 call(ui.open_database_window("DRAWINGS", opts))
46
47# open a Database Window for a specific layer even when it isn't current
48if not ad.isNone():
49 layer = ad.layers("B")
50
51 if not (layer is None):
52 if ad.active_layer.full_name != layer.full_name:
53 opts = ui.create_database_window_options()
54
55 opts.drawing = ad
56 opts.layer = layer
57
58 call(ui.open_database_window(opts.layer.layer_type, opts))
59
60 else:
61 ot.add("Layer 'B' is the active layer in the active drawing")
62
63 else:
64 ot.add("Unable to locate layer 'B' in the active drawing")
65
66# open the configured CUSTOMER Database Window and scroll to the current customer
67if not ad.isNone():
68 opts = ui.create_database_window_options()
69
70 opts.primary_key = ad.customer.key
71 opts.operation = ipDatabaseWindowOperation.dwoScrollToPrimaryKey
72
73 call(ui.open_database_window("CUSTOMER", opts))
74
75 ui.show_message(ipShowMessageType.smtInfo, "Old Primary Key: " + str(ad.customer.key) + ", New Primary Key: " + str(opts.primary_key), None)
76
77# open the configured SALESREP Database Window and add a new record
78opts = ui.create_database_window_options()
79
80opts.operation = ipDatabaseWindowOperation.dwoAdd
81
82if ui.open_database_window("SALESREP", opts):
83 ui.show_message(ipShowMessageType.smtInfo, "Added new SALESREP with Primary Key: " + str(opts.primary_key), None)
84
85# open the configured CUSTOMER Database Window and edit the current customer
86if not ad.isNone():
87 opts = ui.create_database_window_options()
88
89 opts.primary_key = ad.customer.key
90 opts.operation = ipDatabaseWindowOperation.dwoChange
91
92 call(ui.open_database_window("CUSTOMER", opts))
93
94# open the specific 'ADDRESS List' Database Window for the current customer
95# this uses a Parent/Child relationship to show only those addresses for the customer
96dbw = db.find_master_tool_setting("ADDRESS List", ipMasterSettingType.mstDBWindow)
97
98if not (ad.isNone()) and not (dbw is None):
99 opts = ui.create_database_window_options()
100
101 opts.parent_table_name = "CUSTOMER"
102 opts.parent_key_value = ad.customer.key
103 opts.child_column_name = "A_CUSTKEY"
104 opts.window_title = "Addresses for " + ad.customer.name
105
106 call(ui.open_database_window("ADDRESS", opts))
107
108else:
109 ot.add("Unable to locate the Database Window 'ADDRESS List'")
110
111
112
113