If you have gone through a process of saving Central models, and you have forgotten to ‘Synchronize with Central’ before closing them for the first time, you may find that your user has all User Created Worksets checked out in those files. A quick recap:
Workshared Revit files use a persons Revit user name (sometimes linked to an Autodesk SSO login) to determine if things are checked out
If someone has a User Workset checked out, you won’t be able to edit it until they Relinquish. (Note: you can Detach and recreate the file but that is dangerous if you have multiple people working on something)
Basically I had a bunch of Revit files that had all User Worksets from certain usernames checked out. They were upgraded and they were Central files. All that was needed was a simple Open and Relinquish. As I didn’t want to do this manually, I sourced some macro code from here and adapted it for my situation.
What does it do?
This Application level macro starts with a dialog box where you can select files. After you select them, it then loops over each file and Opens it, then does a Relinquish All Mine on User Created Worksets, and then it Syncs with Central and Closes the file. The key part of the code is here:
How to set it up?
First, get the code below. Copy and paste it into a new Application Macro in Revit.
* Created by SharpDevelop.
* User: lukes
* Date: 1/10/2018
* Time: 2:54 PM
* To change this template use Tools | Options | Coding | Edit Standard Headers.
public partial class ThisApplication
private void Module_Startup(object sender, EventArgs e)
private void Module_Shutdown(object sender, EventArgs e)
#region Revit Macros generated code
private void InternalStartup()
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
public void RelinquishMineFromFiles()
OpenFileDialog theDialogRevit = new OpenFileDialog();
theDialogRevit.Title = "Select Revit Project Files";
theDialogRevit.Filter = "RVT files|*.rvt";
theDialogRevit.FilterIndex = 1;
theDialogRevit.InitialDirectory = @"C:\";
theDialogRevit.Multiselect = true;
if (theDialogRevit.ShowDialog() == DialogResult.OK)
/* string mpath = "";
string mpathOnlyFilename = "";
FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
folderBrowserDialog1.Description = "Select Folder Where Revit Projects to be Saved in Local";
folderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer;
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
mpath = folderBrowserDialog1.SelectedPath;*/
foreach (String projectPath in theDialogRevit.FileNames)
FileInfo filePath = new FileInfo(projectPath);
ModelPath mp = ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath.FullName);
OpenOptions opt = new OpenOptions();
/* opt.DetachFromCentralOption = DetachFromCentralOption.DetachAndDiscardWorksets;*/
WorksetConfiguration openConfig = new WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets);
// Set list of worksets for opening
mpathOnlyFilename = filePath.Name;*/
Document openedDoc = Application.OpenDocumentFile(mp, opt);
/* SaveAsOptions options = new SaveAsOptions();*/
TransactWithCentralOptions twcOpts = new TransactWithCentralOptions();
SynchronizeWithCentralOptions syncopt = new SynchronizeWithCentralOptions();
RelinquishOptions rOptions = new RelinquishOptions(true);
rOptions.UserWorksets = true;
syncopt.SaveLocalBefore = false;
syncopt.SaveLocalAfter = false;
/* options.OverwriteExistingFile = true;
ModelPath modelPathout = ModelPathUtils.ConvertUserVisiblePathToModelPath(mpath + "\\" + mpathOnlyFilename);
Add the System.Windows.Form reference and
Build the Solution
Note: I built and tested this on Revit 2018.2.
How to Use It?
Set your Revit User Name to the user that you want to Relinquish the Worksets for…
You may have to logout of your own SSO first
Go to Revit Options
Input the exact user name (including @ if an email address)
Start a new blank project in Revit
Start the Macro Manager
Select the RelinquishMineFromFiles macro that you built
Select the files you want to fix
Wait for the result. The macro will step through them, Relinquish, Sync and Close the files.
Please use at your own risk, this has the potential to be pretty risky in a real project environment. Only use it if you understand what is going on 🙂
The next generation of successful designers will have one important thing in common – the ability to quickly build the tool they need to accomplish a given task. Revit macro coding is one way to do this (Dynamo is another, even powerful Excel spreadsheets can qualify as BIM tools). But if you have had limited involvement with Revit macros in the past, you might be wondering “So… What is a macro anyway?”
One good place to start would in this great little article by Troy Gates on AUGI. Here are three tips from the article to get you interested:
I highly suggest creating the macros in the application tab so you can reuse the macros in any Revit model. If you store the macro inside the model, then it is only available to that Revit model.
The Revit API also allows the use of Microsoft LINQ (Language Integrated Query) functions. LINQ allows you to use a database-like query system to filter the elements contained in a collection. It is much more powerful and easier to use, in my opinion, when working with collections of Revit elements.
your code needs to define objects that the Revit API will use to interface with these. These objects are called UIDocument and Document…
The problem – Appending a given NWC creates hundreds of lights in your NWF, as they were exported with light sources from Revit:
Update: scroll to the bottom of the Autodesk Rendering, Lights pane and select the last entry. Press and hold the Delete key on the keyboard – it will rapidly delete lights out of the Navisworks model.
One way to get rid of all these light sources is to use a macro recorder to delete them all. This is because Navisworks 2015 does not allow you to delete multiple light sources at once (sadface), and it doesn’t allow you to “Clear Palette” like Presenter did.
The immediate workaround is to use Shaded mode with Headlight only, as this ignores Light sources. Not pretty.
You could also down-save to 2013, delete the lights in Presenter, then save-up to 2015, but that seems a little too hacky, even for me.
Here’s the clicky mouse macro method:
Install MouseController (I used choco install mousecontroller)
Open the problem NWF
When it “Can’t resolve external references” for each .ies file, just click Ignore All
Set up a macro to delete lights (see the Screencast below)
My best result was using Time Stretch 3.0x and Repeat every 0.8 seconds
Set it and walk away from your PC for a bit
Some other things to try:
Look for a light source subcategory in your NWC export view
Turn it off
Append to a brand new NWF and see if the lights show up in Autodesk Rendering
Another thing to try:
Navisworks Exporter settings/File Reader/Revit
Untick “try and find missing materials”. Make sure that box is NOT checked.
Also turn off light source as in step 1 above.
Append to a brand new NWF and see if the lights show up in Autodesk Rendering
Some of the bugs that might show up:
Missing IES file references
Regenerating thumbnail image …
The only real fix (at this stage) is to open each Lighting Family and untick Light Source. Obviously, this is not really an option if you are doing lighting analysis or using the lights for rendering in Revit or 3dsMax etc:
Interestingly, this hotfix comes in the form of a macro to clean up your files. The issue as stated on the Autodesk Knowledge Network is: In Revit 2015 the performance of some file is very slow. This means that opening material browser may take an extremely long time or Revit will hang. Typically you cannot execute the “Purge unused elements” command as well, because Revit will freeze. … Every time you edit a family and load it back in > overwrite > the number of materials will grow substantially. For example after 5 or so subsequent reloads in our sample file it jumps from 15551 to 186623 materials. … We have seen this most commonly when editing titleblock familes in the German and Japanese version of Revit.
One of the most popular addins for Revit to date is the simple section box tool by Coins. But what about doing the same thing in 2D? Paolo has put together a macro (and shared the code) that crops a Plan view around a selection of elements. Nice job!
From Punto Revit:
I’ve been asked by a reader if it is possible via Revit API to crop a plan view around a selection of objects, if there are no scope boxes associated it can be done in a fairly easy way.
Have you ever experienced the “Missing Third Party Updater” message? It comes about when an Updater (addin or macro) is in use, and then does not exist on a PC that is new to the project.
From sasha.varsanofieva You must close all local files, open and click do not warn on your central, and then recreate locals. Otherwise the locals will continue to write the tag back into your central and from your central into the locals.
I don’t think the API programmers should get scared just yet, but is there a day coming when visual programming will completely replace custom code? Julien seems to think so:
“I firmly believe Dynamo could be used for many many purposes, and addin-like behavior is one… Definitions are easy to share and update. Users can tune them with only some basic Dynamo skill. It is not the same with addins. It is a lot of work to manage and deploy. And users will not be able to tune things. Same thing for macros.”