

I'm just dipping my toe into the Dynamo water. I've tried in the past... brain just doesn't want to think like that - I'll get there eventually.
So my first taste was with Create Worksets. I didn't create, just copied a .dyn to run. I think would work well at the initial project setup, but probably wouldn't use it much after that unless it was a large project split up with multiple links.
I then started thinking about RVT links. Can Dynamo read an excel file and find a particular rvt link and put it on the correct workset? I'm thinking one column would be the links and the second column would be the workset to be placed. Of course Dynamo would have to pick up both the instance and type workset that a link could be placed on.
Just going through some unanswered questions, sorry to zombie this post. But in case people have similar needs:
Dynamo doesn't directly have some tile able to inspect / set a workset this way. However, a workset is just a parameter value of any one element. Dynamo does include tiles like SetParameterByName through which you can change any element's workset (as long as it's not readonly - like when it's inside a group).
The trick is the value given is just a number, not the workset's name. And to obtain that number you need to find out what it is. Either manually by setting something to the target workset, or through the RevitAPI by iterating over all worksets and finding the Id value of the one matching the name you're after. Unfortunately Dynamo doesn't include a tile which can search for a workset Id like that. Instead it provides tools like Python do "add" such custom abilities.
Here's a sample of how to set all revit links, as well as their type definitions to a specific workset (by name).
Note I've used default tiles as much as possible. The only exception being that Python Script tile. It's contents is as follows:
A bit over the top as I also send out all the worksets and their Id's. My idea was to allow choosing from one of them afterwards. But I found using Python directly to get only the one you want is actually simpler than filtering a list and then extracting its value.Code:import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager doc = DocumentManager.Instance.CurrentDBDocument worksets = FilteredWorksetCollector( doc ) worksets.OfKind( WorksetKind.UserWorkset ) name = IN[0] wsl = [] found = None for ws in worksets: wsl.append([ws.Name, ws.Id.IntegerValue]) if ws.Name == name: found = ws.Id.IntegerValue OUT = [found, wsl]
In fact omitting the List.FirstItem just after the Python script and changing the Py to just this would give the exact same result:
Code:import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager doc = DocumentManager.Instance.CurrentDBDocument worksets = FilteredWorksetCollector( doc ) worksets.OfKind( WorksetKind.UserWorkset ) name = IN[0] found = None for ws in worksets: if ws.Name == name: found = ws.Id.IntegerValue OUT = found
And then to fully answer this question - including the excel source for each link to workset match:
The python node had to change a bit:
The "Type Name" parameter of the link is simply the filename (including the .rvt extension) of each.Code:import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager doc = DocumentManager.Instance.CurrentDBDocument worksets = FilteredWorksetCollector( doc ) worksets.OfKind( WorksetKind.UserWorkset ) names = [] ids = [] for ws in worksets: names.append(ws.Name) ids.append(ws.Id.IntegerValue) OUT = [names, ids]
There are also a bunch of package nodes that can get worksets and their names / ids.
Jsut out of curiosity, you assign all your links to the same worksets?
I have the same kind of definition but i use the file name to create the worksets and assign it
If you look at the 3rd post, I've added an extra way by doing exactly what the OP asked for: Each link has an associated workset listed from an Excel file. Though I change the link and all instances thereof to the same workset.
Your idea also could be done, e.g. get the Type Name, make a workset with same, and then set the type and all instances thereof to that workset. Though I'd be a bit reticent of this. Links can change names, and I'f seen a lot of temporary links coming and going. I'd hate to have a workset list grow and grow with lots of names no longer in use.
Perhaps that would be another idea for a Dyn project: "Purge" unused worksets.
Wow, that was a long time ago and I don't check here very often. Thank you irneb for resurrecting this thread. I'll have to check that out.