Application globals (Python)¶
Application globals (Python)¶
1# this example adds (or replaces) some application impact.globals
2# and displays them in the output toolbox
3
4# create a local variable for the application impact.globals
5applicationGlobals = impact.globals
6
7# create a local variable for the output toolbox
8ot = impact.gui.output_toolbox
9
10# add (or replace) some impact.globals
11
12# use an integer
13applicationGlobals.add("Carl", 27)
14
15# use a real number
16applicationGlobals.add("Dan", 3.14)
17
18# use a string
19applicationGlobals.add("John", "jv")
20
21# use an object
22applicationGlobals.add("Chris", impact.active_drawing)
23
24# note - not case sensitive, modify the earlier "Carl" global
25applicationGlobals.add("carl", 9)
26
27# clear the output toolbox
28ot.clear()
29
30# iterate all the impact.globals and display them in the output toolbox
31for g in applicationGlobals:
32
33 # can only display the value of the global if it is not an object
34 if not IsObject( g.value ):
35
36 ot.add(g.name + ": " + g.value)
37
38 else:
39 d = g.value
40
41 if not d is None:
42
43 ot.add(g.name + ": " + d.full_name) # expected to be an IDrawing