Addins - Using the Inventor Themes Light / Dark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
Getting addins to adopt the light / dark themes to some has been a challenge. I went through an arduous task of creating a skin based on the dark theme and i had to fill in a lot of blanks. Then the other day i was looking for a library in the Inventor 2024/Bin folder and came across this-
Autodesk.iLogic.ThemeSkins
A quick reference add and look inside and found the themes were under a DevExpress skin manager. I have a DevExpress subscription so i set up a skin class to pull out the theme and applied it to my custom addin form. Worked like a charm so here is the code for anyone who wants to do the same. a DevExpress subscription is required (unless i make a special library as a tool i guess).
you need references to the following
using DevExpress.LookAndFeel;
using DevExpress.Skins;
using DevExpress.UserSkins;
using DevExpress.Utils;
using DevExpress.XtraEditors;
using Autodesk.iLogic.ThemeSkins;
using DevExpress.Skins.Info;
using System.Reflection;
using Inventor;
This code gets the theme skin and registers it, then checks what theme style you currently have in Inventor and switches the theme to the inventor theme
public YourClassName()
{
// This call is required by the designer.
InitializeComponent();
string DarkTheme = "inventor dark theme";
string LightTheme = "inventor light theme";
string AdeskLib = "Autodesk.iLogic.ThemeSkins.CustomSkins.";
SkinManager.EnableFormSkins();
var valDark = new SkinBlobXmlCreator(DarkTheme, AdeskLib, typeof(CustomThemeSkins).Assembly, null as string);
var valLight = new SkinBlobXmlCreator(LightTheme, AdeskLib, typeof(CustomThemeSkins).Assembly, null as string);
SkinManager.Default.RegisterSkin(valDark);
SkinManager.Default.RegisterSkin(valLight);
Inventor.ThemeManager oThemeManager = AddinGlobal.InventorApp.ThemeManager;
Inventor.Theme oTheme = oThemeManager.ActiveTheme;
switch (oTheme.Name)
{
case "LightTheme":
this.LookAndFeel.SetSkinStyle(LightTheme);
break;
case "DarkTheme":
this.LookAndFeel.SetSkinStyle(DarkTheme);
break;
}
LookAndFeel.UpdateStyleSettings();
}
And also in dotnet
Imports DevExpress.LookAndFeel
Imports DevExpress.Skins
Imports DevExpress.UserSkins
Imports DevExpress.Utils
Imports DevExpress.XtraEditors
Imports Autodesk.iLogic.ThemeSkins
Imports DevExpress.Skins.Info
Imports System.Reflection
Imports Inventor
Public Sub New()
' This call is required by the designer.
InitializeComponent()
Dim DarkTheme As String = "inventor dark theme"
Dim LightTheme As String = "inventor light theme"
Dim AdeskLib As String = "Autodesk.iLogic.ThemeSkins.CustomSkins."
SkinManager.EnableFormSkins()
Dim valDark As New SkinBlobXmlCreator(DarkTheme, AdeskLib, GetType(CustomThemeSkins).Assembly, DirectCast(Nothing, String))
Dim valLight As New SkinBlobXmlCreator(LightTheme, AdeskLib, GetType(CustomThemeSkins).Assembly, DirectCast(Nothing, String))
SkinManager.Default.RegisterSkin(valDark)
SkinManager.Default.RegisterSkin(valLight)
Dim oThemeManager As Inventor.ThemeManager = AddinGlobal.InventorApp.ThemeManager
Dim oTheme As Inventor.Theme = oThemeManager.ActiveTheme
Select Case oTheme.Name
Case "LightTheme"
Me.LookAndFeel.SetSkinStyle(LightTheme)
Case "DarkTheme"
Me.LookAndFeel.SetSkinStyle(DarkTheme)
End Select
LookAndFeel.UpdateStyleSettings()
End Sub
Hope that helps
Nacho
Automation & Design Engineer
Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.