Addins - Using the Inventor Themes Light / Dark

Addins - Using the Inventor Themes Light / Dark

NachoShaw
Advisor Advisor
213 Views
4 Replies
Message 1 of 5

Addins - Using the Inventor Themes Light / Dark

NachoShaw
Advisor
Advisor

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

EESignature


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.


214 Views
4 Replies
Replies (4)
Message 2 of 5

jjstr8
Collaborator
Collaborator

I don't have DevExpress, so I tried the brute-force method. I gave up (for the time being) on making all my windows support light/dark mode. I ended up just supporting it in simple dockable windows, since a mismatch sticks out pretty bad. I added an event that any of them can subscribe to to listen for a theme change. I also tweaked my icons to work for both themes, but it's easy enough to swap them on a theme change. 

0 Likes
Message 3 of 5

Mustafa.Salaheldin
Collaborator
Collaborator

Thanks @NachoShaw I figured this out too. The point that I still investigating is how to apply the Inventor default theme to my custom DevExpress UserControl. I don't want to use the iLogic Theme, I want to use Inventor Theme.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes
Message 4 of 5

NShawAcacia
Community Visitor
Community Visitor

Hi

 

I included a vb.net version that works direct in Visual Studio on a project solution. Happy to help you get there if you need bud, just give me a bit of what you're trying to do. connect privately if you need

0 Likes
Message 5 of 5

Mustafa.Salaheldin
Collaborator
Collaborator

@NShawAcacia Thanks, but again, your code applied the iLogic skins, not the Inventor skin, and by the way there is a direct call to the theme register then skin apply, rather than re-implementing the CustomThemeSkins class.


¯\_(ツ)_/¯
Let it work like a charm.

Mustafa Salaheldin


EESignature




Digital Integration Manager, DuPod

Facebook | Twitter | LinkedIn

0 Likes