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.
In Revit 2021+ the CodeDom.Compiler
uses the (Roslyn)[https://github.com/aspnet/RoslynCodeDomProvider] version compiler.
The Roslyn compiler is a new compiler that supports C# version 6 and above.
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)
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
.
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;
}
}
}
- Download and install RevitAddin.CommandLoader.exe
Videos in portuguese with the creation of this project.
This project is licensed under the MIT Licence.
Do you like this project? Please star this project on GitHub!