Global Helpers
Paracore injects several global variables and functions into your script's execution context. These helpers eliminate the need for common Revit API setup code.
🏢 Revit Context
Doc: The active Revit Document (Autodesk.Revit.DB.Document).UIDoc: The active UI Document (Autodesk.Revit.UI.UIDocument).UIApp: The Revit Application instance (Autodesk.Revit.UI.UIApplication).
📝 Logging & Console
Println(string message): Prints a message followed by a newline to the Paracore Console.Print(string message): Prints a message without a newline.
💡 Why use Println? We strongly recommend using
Println()instead of the standardTaskDialog.Show().
- Non-Blocking:
Println()streams messages to the Paracore Dashboard instantly without pausing your script.- Clean Workflow: Avoid distracting popups that interrupt your focus.
🏗️ Transactions (Transact)
The Transact helper automatically handles the Revit Transaction lifecycle (Start, Commit, and Rollback on error).
Document modifications MUST be wrapped in a Transact block.
Transact("Update Wall", () => {
wall.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).Set("Updated");
});
🛑 Best Practices for Transactions
- Avoid Transactions inside Loops: Never put a
Transactcall inside aforeachorforloop. Opening and closing hundreds of transactions is slow and clutters the Revit Undo stack. - Put Loops inside Transactions: Instead, wrap your entire loop inside a single
Transactblock. This ensures all changes are processed as one "undoable" operation. - Undo Support: Every script execution that uses
Transactcan be completely reversed using the standard Revit Undo (Ctrl+Z) command.
📊 Visual Helpers
These helpers automatically format and send data to the Table Tab for analysis and visualization.
| Method | Description |
|---|---|
Table(data) | Renders a list of objects as a searchable, sortable grid. |
BarChart(data) | Renders data as a Bar Chart. |
PieChart(data) | Renders data as a Pie Chart. |
LineChart(data) | Renders data as a Line Chart. |
Example: Quick Table
var walls = new FilteredElementCollector(Doc).OfCategory(BuiltInCategory.OST_Walls).ToElements();
Table(walls.Select(w => new { w.Name, w.Id }));
🛠️ Advanced: Show(type, data)
The underlying engine uses the Show method. While you can use it directly, the specialized helpers above are recommended.
Show("table", myData);