-
Notifications
You must be signed in to change notification settings - Fork 0
Examples CSharpScript
Truong Giang Vu edited this page May 31, 2026
·
1 revision
Script: main_script.csx
Use this example when you want to test a small C# Revit command without creating a full compiled add-in project.
- referencing Revit API assemblies from a script;
- loading a helper script with
#load; - defining an
IExternalCommandclass; - showing a Revit
TaskDialog; - selecting an element;
- tracing bounding box and point geometry for visualization/logging.
- Open Revit 2025 or adjust the
#rpaths in the script to match your installed Revit version. - Add
Samples/CSharpScriptDemo/as a script folder. - Run
main_script.csx. - Select an element when prompted.
- Review the trace panel and any temporary geometry output.
Common edits:
- Change Revit API reference paths for another Revit version.
- Add more helper functions under
Helpers/. - Replace the selected element logic with a collector.
- Trace different geometry objects to test visualization.
| Symptom | Check |
|---|---|
| Revit API reference not found | update #r paths for your Revit version |
| script compiles but selection fails | run in an open document and select a valid element |
| no visualization | confirm the traced object is supported geometry |
| command not discovered | file name must end with script.csx
|
- Run Code Overview
- Modern Python Scripting
- Python Debugging
- Python Ecosystems
- RevitDevTool And pyRevit
- Python Stub Generation
- Run .NET Add-ins
- Scripting Runtimes