Create Revit workset by linked file with Dynamo (updated)

This little Dynamo graph may become handy If you use individual Revit worksets for each of the linked Revit files. While operating with linked files via worksets becomes super comfortable (you can even unload links before opening your Revit model), it becomes a pain to manually create separate worksets for each model.

This is where Dynamo will come in handy:

WorksetByLinkedFile

As you can see, the logic behing this graph is simple:

  1. Scan your current document for linked Revit files, and retrieve their names. This is done using Archi-lab.net package by Konrad K Sobon, so you'll need to install it (if you haven't already done this) before running the script;
  2. Then we cut off all the unnecessary symbols from the link names using the node "String.Split" and add our desired prefix via "String.Insert";
  3. The last one node "Workset.ByName" is also listed in Archi-lab package and basically does the rest - creates worksets by the input list of names. Although I don't check if some of the worksets already exist, it won't give you errors or warnings.
That's how it looks like after executing the script:

Worksets with Dynamo

Note that this graph only creates worksets for you, but you still have to select linked file in Revit through the Project Browser and manually assign an appropriate workset for it. However, this could be further modified to fully automate the process if it is needed (see an updated part below).

Update (July 10, 2017):

To further streamline the workset management process, you can tell Revit to set these newly created worksets to the linked files. This could be done by tweaking the original logic of my script:

Create and set workset by linked file(s)

Here we get the linked file's type, using the custom node called "Element.Type" from the "Clockwork" package, then set the workset id to the type properties. Note that since the "Workset" parameter in Revit is a dropdown list, it expects an integer value that corresponds to the workset id. You can't feed the workset name or workset element into the node "Element.SetParameterByName".

So these are all the simple tweaks that would do all the dirty work for you. And as usual, the Dynamo graph is available for download below.

Summary

Revit 2016+ | Dynamo 1.2.1+ | Archi-lab.net package | Clockwork package

Download link(s): Dynamo_Create-n-Set_WorksetByLinkedFile (modified version), Dynamo_CreateWorksetByLinkedFile (original version)