Get Active Workset

Is there a way to get the active workset in a document using Dynamo? I have a script that I want to run only on the elements in the active workset, so I’d like to be able to pull the workset ID and filter elements based on that. I haven’t come across any nodes that do this.

Hi @brunelli.b,

Put this in a python node, and see if it does what you need:

import clr
#Import the Revit API
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

#Start scripting here:
wt = doc.GetWorksetTable()
wId = wt.GetActiveWorksetId() 

#Assign your output to the OUT variable.
OUT = wId
1 Like

Thanks a lot. That works perfectly.