I’m new to Dynamo and working on a dynamo script that sorts various families/elements to different worksets. We use a standard workset naming and sorting between all projects so this seemed like a good task to automate. When I set it up it and run it on a test project, it works fine (the odd error if it can’t find something, aka. list is blank but still works). However when I use it on another project it forgets all the workset names and it has to be re-setup. Is there a way to keep it saved or look it up by name? Thanks.
What do you mean by re-setup? Are you talking about closing and re-opening Dynamo each time you switch to a new document?
Edit: Is something like this what you’re looking for?
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
workset_filter = WorksetKindFilter(WorksetKind.UserWorkset)
worksets = FilteredWorksetCollector(doc).WherePasses(workset_filter).ToWorksets()
name = IN[0]
OUT = []
for workset in worksets:
if workset.Name == name:
OUT = workset
Given a case-sensitive name of a workset, it will return the actual Workset object if a workset in the current document has the same name.
2 Likes
Yep, each time I switch documents it doesn’t remember/keep the worksets selected.
Awesome, that’s perfect. Works great, thank you.