Automatic Workset

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In sharing mindset, here is the concept behind an add-in that automatically sets a project's active workset to the user's preference every time a project document is opened. Maybe this is a nonsense add-in that is not needed, but it seems to be a welcomed add-in.
It is simply a single panel with a splitbutton control. The splitbutton contains a button for every company standard workset, including one called NADA. Selecting any button switches the current project's workset to the workset the button represents. The selection also sets and saves a user preference setting, "preferedWS", that is associated with the add-in application. The NADA button only sets the preferedWS to "". The add-in application adds and removes an event handler for ControlledApplication.DocumentOpened on Startup and ShutDown. That handler reads the preference setting, changes the newly opened document with a call to a function that switches the active workset if the prefered workset exists in the document, activates a small WindowStyle "None" WPF form that takes a text argument (the workset name) for feedback display, that also starts a one second timer to close itself in one second, and lastly, figure out which of the splitbutton's buttons to set as CurrentButton so that the Splitbutton control appears to remember what it was set to during the previous Revit session.
In operation the user sets the splitbutton to the desired preferred workset. The workset changes the workset if the workset exists. Otherwise a message pops up saying it did not happen. The splitbutton, being a splitbutton, is now set to the preferred workset. That reminds the user the preference has been set , regardless of whether or not the active file had that workset. The next time the user opens a document in that session a message flashes saying the workset, if present, has been set. The same would happen in subsequent Revit sessions and the splitbutton would also be reflecting what the preferred workset is because the add-in sets the CurrentButton on every documentopen, which is always the ribbon's context, except for newly created documents. Setting the splitbutton to NADA turns off the feature.