I have developed a bunch of custom tools for myself and the other structural engineers at my small company. I use pyRevit to implement all of this, and right now it manifests itself as a custom tab on our ribbons with all the various tools displayed. However most of these tools are specific to the structural group.
I am now starting to create some tools specific to other groups, like the MEP staff. I dont want the MEP staff’s toolbar to be bogged down with structural specific tools and vice-versa.
Ideally I could, at the very beginning of each script (or within the bundle.yaml), specify which users should see each tool. The alternative would be to setup separate extension directories for each discipline (structural, mechanical, etc), which is fine, but it would be cleaner to use the same extension folder.
Is this possible, easily, at this moment with pyRevit? I’m trying to minimize the amount of coding/impact to existing scripts, which is why I was hoping the bundle.yaml could accomplish this. Besides that, I’d probably be better off with individual discipline directories rather than figuring it out with some code appended to each script.
Not possible the way you would like it to.
If some tools are similar, you could put their content in a common library and call them in a main function in your different scripts/button/toolbar.
There are some options, with different upsides and drawbacks.
Alt. 1a: Use one common .extension with one lib-folder and two .tab folders (OrgStructure.tab and OrgMEP.tab). This is probably the simplest, both tabs are shown but each diciplin only uses the tab they need. This also opens the possibility for a third tab (Org.tab) that has common tools everyone uses. Drawback is that is loads 3-4 tabs regardless of what the user needs, and Revit has a hard limit of 20 tabs loaded by API. If the users have other addins and surpass the limit, some addins or your tabs will not be loaded.
Alt. 1b: same as above, but on startup you hide the diciplin tabs and only show the Org.tab, in the Org.tab create code for .smartbutton toggles to turn on/off the diciplin tabs. This needs custom code to hide tabs and toggle visability (its possible, I have coded this in our extension).
Alt. 2: Set up two .extensions and a .lib extension (see Library Extension). The main drawback is that the .lib extension cannot be used in startup.py scripts (as i understand it, I never got it to work). Upside is that users can install only the extenstions/tabs they need and only those are loaded. And all scripts use the common .lib extension.
There are probably other solutions too, but might get complicated. Might be possible to create a UserSettings menu and a settings file that only load the tabs the user has set, and use alt. 1a?
I would not recommend setting up logic for which user should see what tools, it would be hard to maintain and some users might need both diciplin tools at some point. Better to let the users choose which one they need.