pyRevit icon indicating copy to clipboard operation
pyRevit copied to clipboard

retrieve a document's tab color from a C# addin

Open RevitIRL opened this issue 4 months ago • 3 comments

Is your feature request related to a problem? Please describe

I've got a C# add-in with some document-specific UI elements that I'd like to color to match the pyRevit tabs.

Describe the solution you'd like

Given the Document element (or HashCode, or however pyRevit keeps track of it), I'd like to query pyRevit to find the corresponding color being used.

Describe alternatives you've considered

I've considered taking my color list ["#FFFBDEAE","#FFC8D5E1","#FFAAAAFF","#FFAAFFAA","#FFFFFFAA","#FFAAD5FF","#FFFFC1AA","#FFAAFFFF","#FFDDEEBB","#FFFFAAD9"] and writing my own code to keep track of the documents and colors, but I've occasionally had issues with missing document events and I'm concerned with the colors getting out of sync. Also, the users are technically able to set their own colors (even if not likely to do so). Re-using the same colors (which I like), while not being able to guarantee that they match throughout the interface would be horrible (I'd be better off using completely different colors to avoid confusing the user, but having them identical would be so much better). Also, if dark support is added in the future, that would add yet another issue.

Additional context

I've used ChatGPT to translate the occasional python to C# for me to understand what's going on, but I have no direct python experience, and I wasn't able to figure out if it's already possible to do this just by looking at the code base.

RevitIRL avatar Sep 11 '25 08:09 RevitIRL

which document specific colors? are you looking for the tabs of the open documents? you can look inside the pyrevit-config.ini to get the list of colors.

tay0thman avatar Sep 16 '25 09:09 tay0thman

Yes. Like I said above, I can hard-code the static list of colors (which is from pyRevit_config.ini), or even read the file on each machine, I suppose, but even though I could mimic the color-picking logic, I can't guarantee that they'll always be the same (user could turn on/off or change colors in pyRevit, etc.)

RevitIRL avatar Sep 17 '25 18:09 RevitIRL

My Guess is that you could find this info not necessarily at the application level but at the windows.window level. You could use the visual studio snooping tool to snoop the window

jmcouffin avatar Sep 17 '25 19:09 jmcouffin