Skip to content

Instantly share code, notes, and snippets.

@ricaun
Created February 27, 2024 18:21
Show Gist options
  • Save ricaun/86334ff6560e3e8c4671148c5c995b39 to your computer and use it in GitHub Desktop.
Save ricaun/86334ff6560e3e8c4671148c5c995b39 to your computer and use it in GitHub Desktop.
Revit Multiple CommandTheme
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.ComponentModel;
namespace RevitAddin
{
[DisplayName("Theme\rChange")]
[Transaction(TransactionMode.Manual)]
public class CommandTheme : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
UIThemeManager.CurrentTheme = UIThemeManager.CurrentTheme == UITheme.Dark ? UITheme.Light : UITheme.Dark;
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
[DisplayName("Theme\rChange")]
[Transaction(TransactionMode.Manual)]
public class CommandTheme1 : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
UIThemeManager.CurrentTheme = UIThemeManager.CurrentTheme == UITheme.Dark ? UITheme.Light : UITheme.Dark;
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
[DisplayName("Theme\rChange")]
[Transaction(TransactionMode.Manual)]
public class CommandTheme2 : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
UIThemeManager.CurrentTheme = UIThemeManager.CurrentTheme == UITheme.Dark ? UITheme.Light : UITheme.Dark;
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
[DisplayName("Theme\rChange")]
[Transaction(TransactionMode.Manual)]
public class CommandTheme3 : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
UIThemeManager.CurrentTheme = UIThemeManager.CurrentTheme == UITheme.Dark ? UITheme.Light : UITheme.Dark;
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
[DisplayName("Theme\rChange")]
[Transaction(TransactionMode.Manual)]
public class CommandTheme4 : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
UIThemeManager.CurrentTheme = UIThemeManager.CurrentTheme == UITheme.Dark ? UITheme.Light : UITheme.Dark;
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
[DisplayName("Theme\rChange")]
[Transaction(TransactionMode.Manual)]
public class CommandTheme5 : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
UIThemeManager.CurrentTheme = UIThemeManager.CurrentTheme == UITheme.Dark ? UITheme.Light : UITheme.Dark;
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
[DisplayName("Theme\rChange")]
[Transaction(TransactionMode.Manual)]
public class CommandTheme6 : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
UIThemeManager.CurrentTheme = UIThemeManager.CurrentTheme == UITheme.Dark ? UITheme.Light : UITheme.Dark;
return Result.Succeeded;
}
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment