# Get Active Workset

**URL:** <https://forum.dynamobim.com/t/get-active-workset/19132>\
**Category:** Revit\
**Created:** [February 15, 2018, 9:34pm UTC](https://forum.dynamobim.com/t/get-active-workset/19132 "2018-02-15T21:34:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brunelli.b](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@brunelli.b](https://forum.dynamobim.com/u/brunelli.b)\
**Post date:** [February 15, 2018, 9:34pm UTC](https://forum.dynamobim.com/t/get-active-workset/19132/1 "2018-02-15T21:34:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [February 15, 2018, 9:51pm UTC](https://forum.dynamobim.com/t/get-active-workset/19132/2 "2018-02-15T21:51:08Z")

</div>

Hi @brunelli.b,

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

```
import clr
#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
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
```

---

<div class="post-metadata">

**Author:** ![brunelli.b](https://avatars.discourse-cdn.com/v4/letter/b/67e7ee/32.png) [@brunelli.b](https://forum.dynamobim.com/u/brunelli.b)\
**Post date:** [February 15, 2018, 10:16pm UTC](https://forum.dynamobim.com/t/get-active-workset/19132/3 "2018-02-15T22:16:02Z")

</div>

Thanks a lot. That works perfectly.
