Launchpad contains several methods to make debugging your script files easier.
The UI class in Launchpad provides three debug methods to help developers inspect and display variables, collections, and global state during script execution. These methods output formatted information to the console, making it easier to understand the current state of your code.
Methods
ShowVars()
Displays one or more variables with their names and values in a formatted output.
title (optional): Custom title for the debug output section
variables: Variable name-value pairs to display (must be provided in pairs)
Usage
Pass variables as alternating name-value pairs. The method expects an even number of arguments.
Examples
// Simple usage with default titleintcount=42;stringname="Wall Type A";UI.ShowVars("count",count,"name",name);// Output:// === VARIABLES ===// count: 42// name: "Wall Type A"
ShowCollection()
Displays the contents of a collection with item count and previews the first few items.
Parameters
name: Display name for the collection
collection: The collection to display
maxItems: Maximum number of items to show (default: 5)
Usage
Use this method to inspect lists, arrays, or any IEnumerable collection. It automatically shows the total count and previews up to the specified number of items.
Examples
ShowGlobals()
Displays all variables stored in the global dictionary or a custom dictionary.
Parameters
globalDict (optional): Custom dictionary to display
title (optional): Custom title for the output
Usage
The parameterless version displays the static RevitCodeGlobals.globals dictionary. You can also pass your own dictionary to display.
Examples
Output Formatting
The debug methods automatically format different data types for clarity:
Strings: Displayed with quotes (e.g., "text")
Numbers: Formatted with appropriate precision
Booleans: Displayed as lowercase (e.g., true, false)
Collections: Show item count (e.g., [5 items])
Revit Elements: Display type, ID, name, and category
ElementIds: Show as ElementId(12345)
null values: Display as null
Best Practices
Use descriptive names: When calling ShowVars, use clear variable names to make the output self-documenting
Limit collection previews: For large collections, keep the default maxItems limit to avoid cluttering the console
Group related output: Use custom titles to organize related debug information
Clean up when done: Remember to remove or comment out debug calls before finalizing your script
Console Output
All debug methods write to the console using Console.WriteLine(). The output will appear in the Launchpad console window when running scripts.