Writing Values¶
Writing Values¶
1# This example shows how to update values in the database directly for a
2# database item. It should be used only by developers who are happy modifying
3# the impact database tables directly. This technique should be used with
4# extreme care because it could result in invalid database records.
5# If you wish to store database values for a working project or other open
6# item then use IDrawing.database_values instead.
7
8
9db = impact.active_database
10
11
12def describe_item(db_item):
13 if db_item is None:
14 return
15
16 # Note: It is important to assign db_item.values to a local
17 # variable because otherwise we would get a new interface everytime
18 # we used db_item.values which would return to stored values
19 values = db_item.values
20
21 values.save("D_NOTES", "Some Notes")
22
23 # The values are upated in the database when DoUpdate is called
24 if values.do_update():
25 impact.gui.output_toolbox.add("Successfully updated drawing '" + db_item.name + "'")
26 else:
27 impact.gui.output_toolbox.add("Error: Unable to update drawing")
28
29
30impact.gui.output_toolbox.clear()
31
32impact.gui.output_toolbox.add("**** Finding Project by Name 'DB Mac Test 1' ****")
33describe_item(db.find_item_by_name(ipDrawingType.dtProject, "DB Mac Test 1"))