: Add using Autodesk.Revit.DB; and using Autodesk.Revit.UI; at the top. 💻 The Boilerplate Code
Every external command needs a specific structure. Use this template:
: The primary way to "find" things in your model (like all Walls or Doors).
: A tool within the SDK to load code without restarting Revit. 🏗️ Basic Project Setup
💡 : Use RevitLookup . It is an open-source tool that lets you "peek" under the hood of Revit elements to see their API properties in real-time.
: Open Visual Studio and start a new C# Class Library project. Add References : Browse to your Revit installation folder. Add RevitAPI.dll (database functions). Add RevitAPIUI.dll (interface functions). Set Copy Local to False for both.
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] public class MyCommand : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { // 1. Get the Document UIApplication uiApp = commandData.Application; Document doc = uiApp.ActiveUIDocument.Document; // 2. Start a Transaction using (Transaction trans = new Transaction(doc, "My Customization")) { trans.Start(); // Your logic goes here (e.g., changing a parameter) trans.Commit(); } return Result.Succeeded; } } Use code with caution. Copied to clipboard 📝 Manifest Files (.addin)
: Use uiApp.ActiveUIDocument.Selection to interact with what the user clicks.
: Add using Autodesk.Revit.DB; and using Autodesk.Revit.UI; at the top. 💻 The Boilerplate Code
Every external command needs a specific structure. Use this template:
: The primary way to "find" things in your model (like all Walls or Doors). Instant Autodesk Revit 2013 Customization with ...
: A tool within the SDK to load code without restarting Revit. 🏗️ Basic Project Setup
💡 : Use RevitLookup . It is an open-source tool that lets you "peek" under the hood of Revit elements to see their API properties in real-time. : Add using Autodesk
: Open Visual Studio and start a new C# Class Library project. Add References : Browse to your Revit installation folder. Add RevitAPI.dll (database functions). Add RevitAPIUI.dll (interface functions). Set Copy Local to False for both.
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)] public class MyCommand : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { // 1. Get the Document UIApplication uiApp = commandData.Application; Document doc = uiApp.ActiveUIDocument.Document; // 2. Start a Transaction using (Transaction trans = new Transaction(doc, "My Customization")) { trans.Start(); // Your logic goes here (e.g., changing a parameter) trans.Commit(); } return Result.Succeeded; } } Use code with caution. Copied to clipboard 📝 Manifest Files (.addin) : A tool within the SDK to load
: Use uiApp.ActiveUIDocument.Selection to interact with what the user clicks.