Inventor 2021 now comes with a dark theme. Along with the dark theme, the Inventor API samples were updated with a new code sample for switching themes.
I converted the initial VBA code sample to iLogic, and it works really well, the code builds a list of available themes (see my thoughts below about this), then presents the user with an “InputBox”, when a number (1 or 2) must be typed to choose a theme.
I took this idea and adapted it to use an Array for the list of themes, which is presented to the user in an “InputListBox”, this makes the selection much simpler (and faster) for the user. The animated GIF below shows the (shortened) process:
My thoughts on the listing of themes, makes me think that we will have more than just dark and light themes in upcoming releases, and maybe even the option of creating, or modifying our own themes, either way the iLogic utility below will be able to list them for you.
Here is the iLogic code
'This version of iLogic code by @ClintBrown3D, based on Inventor API sample - THIS CODE WILL ONLY WORK WITH INVENTOR 2021 or NEWER 'Originally Published at https://clintbrown.co.uk/ilogic-theme-switcher Dim oThemeManager As ThemeManager oThemeManager = ThisApplication.ThemeManager Dim oTheme As Theme, i As Long: i = 0 Dim sNames As String, sName As String Dim oThemes As New ArrayList For Each oTheme In oThemeManager.Themes i = i + 1 oThemes.Add(i & " - " & oTheme.Name) Next sName = InputListBox("Pick a Theme", oThemes, oThemes, Title := "@ClintBrown3D", ListName := "Themes") If sName = ("") Then : Return : End If i = Left(sName, 1) If oThemeManager.Themes.Item(i).Name <> oThemeManager.ActiveTheme.Name Then oThemeManager.Themes.Item(i).Activate Else Call MsgBox("The selected theme is active, please select another theme.", vbOKOnly, "Unofficial Inventor") End If
This version of the code was briefly tested in Inventor 2021.
Please note that I cannot offer any additional support, this blog post is offered as-is, and is aimed at the more advanced user.
As always, please test all iLogic code extensively on non-production files. Do not use any code in a production environment until YOU have thoroughly tested it and have verified that it works as expected. Always back up any data before running any experimental code. You are ultimately responsible for any iLogic code that you run, so make sure you test it thoroughly!