RevitAddin.CommandLoader
project compiles IExternalCommand
with Revit open using CodeDom.Compiler
and creates a PushButton
on the Revit ribbon.
This project was generated by the AppLoader Revit plugin.
- Compile multiple
IExternalCommand
at once with Revit opened. - Generate
PushButton
with the compiledIExternalCommand
withIExternalCommandAvailability
. - AutoUpdate plugin using ricaun.Revit.Github.
Gist
link downloads the content and compiles each file.
Revit 2017 to 2020 the CodeDom.Compiler
only work with C# compiler version v4.0
maximum, the following features do not work in C# version 4.
- Async Features (C# version 5)
- String interpolation (C# version 6)
Revit 2021 to 2024 the CodeDom.Compiler
uses the Roslyn version compiler. The Roslyn compiler is a new compiler that supports C# version 6 and above.
Revit 2025+ the CodeDom.Compiler
uses the Microsoft.CodeAnalysis.CSharp to work with NET Core.
The RevitAddin.CommandLoader.Tests have some tests to make sure the compiler works in Net Framework and Net Core.
Using System.ComponentModel
attributes is possible to customize the IExternalCommand
that is generated in the Revit ribbon.
DisplayNameAttribute
: Set the Text in thePushButton
.DescriptionAttribute
: Set the Tooltip in thePushButton
.DesignerAttribute
: Set the LargeImage in thePushButton
. (Works withcomponent
,URL
, andbase64
)
If IExternalCommandAvailability
is added in the same IExternalCommand
class the availability gonna be applied in the PushButton
.
The command below show the version of Revit in a MessageBox
.
using System;
using System.ComponentModel;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
namespace RevitAddin
{
[DisplayName("Revit\rVersion")]
[Description("Show a Window with the Revit VersionName.")]
[Designer("/UIFrameworkRes;component/ribbon/images/revit.ico")]
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
System.Windows.MessageBox.Show(uiapp.Application.VersionName);
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
}
The RevitAddin.CommandLoader
have the feature to download gist
files from GitHub and compile the IExternalCommand
with the gist
file.
Just copy the gist
link in the RevitAddin.CommandLoader
compiler and execute.
- CommandVersion - File with Revit defines.
- CommandCreate - Multiple file each with a
IExternalCommand
. - CommandTheme - Commands to change
UITheme
.
- Download and install RevitAddin.CommandLoader.exe
Videos in Portuguese with the creation of this project.
Videos in English about this project.
This project is licensed under the MIT Licence.
Do you like this project? Please star this project on GitHub!