The following variables can be used inside your Launchpad scripts.
Revit Global Variables
app = current Revit Application
doc = current Document open in Revit
uidoc = current UI Document open in Revit
selection = list of Element Ids of the currently selected elements
revitVersion = current Revit version number (i.e. 2026)
User-Defined Global Variables
You can define your own global variables that will persist for the life of the Revit session. These variables are useful when you want user selections from one tool to be available in another tool, or when you want to pre-populate a user interface with previously entered data.
You can define a global variable by using the "globals" dictionary. The dictionary requires a "key" and a "value". The key is the name of the variable. The value can be any data type. You can define a define a global variable with the following code:
// Create global variables - only do this once
globals.Add("numGlobalVar", 5);
globals.Add("textGlobalVar", "this is some text");
Once a variable is defined, you can update its value by referencing the key.
// Update global variable values
globals["numGlobalVar"] = 6;
globals["textGlobalVar"] = "this is my new text";
To clear out all the variables in the global dictionary, use the Clear() method.
// Clear global variables
globals.Clear();
If you want to output all the current global variables and their values, use this code:
// Output all global variables and values
UI.ShowGlobals();