I am not experienced in this myself, so I looked for help elsewhere. I don't know whether you noticed, but in the past, I tried using ChatGPT once or twice to answer Revit API questions with little or next to no success. Now, I passed on your question to Google Gemini. It has the advantage over ChatGPT of being more up to date and having Internet access, afaik. Here is my prompt and its response:
Jeremy: I have implemented a C# .NET add-in for Revit 2024. I've noticed on my production workstation running 2024.2 in dark theme that some controls in addins are getting the dark theme. It looks terrible and quite undesirable. Particularly when labels and checkbox text turns light on a light background. It does not happen to any of the addins (mine or others') on my development machine. I also have a VM used for testing where this behaviour does not occur. Why might this be happening? Why is it not happening consistently?
Gemini: There are several potential reasons why your Revit 2024.2 add-in is experiencing inconsistent theme behavior on your production workstation:
- Theme Inheritance:
- Revit offers the option to use the system theme or manually set a light or dark theme.
- Scenario: If your development and testing environments have different theme settings than your production machine, it can explain the inconsistency.
- Solution: Check the theme settings on all machines.
- Production: Ensure the desired theme (likely light) is chosen.
- Development & Testing: Consider setting the theme to match production for consistency.
- Resource Loading:
- Your add-in might be referencing specific resource files (e.g., colors, styles) for its UI elements.
- Scenario: These resource files might be missing on your production machine or loaded incorrectly, leading to default dark theme styles being applied.
- Solution: Double-check the resource file paths in your code and ensure they are accessible on all machines. Consider using Revit's built-in resource system and avoiding hardcoded paths.
- Custom Themes:
- Some users might install custom themes for Revit, potentially affecting add-in appearance.
- Scenario: If you haven't encountered this on your development or testing machines, it could be happening on the production machine specifically.
- Solution: While not ideal, you can check if any custom themes are installed and recommend users disable them for consistent add-in behavior.
- WPF Theme Management:
- If your add-in uses WPF for its UI, it might inherit unwanted themes from other applications using WPF.
- Scenario: This could explain why other add-ins are also affected.
- Solution: Explore options for managing themes within your add-in using WPF's theme resources and overriding inherited styles.
Additional Tips:
- Consider implementing logic within your add-in to detect the current theme and adjust its own UI styles accordingly.
- Search online resources like the Revit API forums and blogs for specific solutions related to theme management in Revit add-ins.
By investigating these potential reasons and trying the suggested solutions, you should be able to identify the root cause of the inconsistent theme behavior in your add-in and ensure a consistent user experience across different environments.
// End of Gemini's answer.
I hope this helps. Please let me know whether it does, so I can better gauge the utility of Gemini. Thank you!