# Open/Close Worksets in current document via Python

**URL:** <https://forum.dynamobim.com/t/open-close-worksets-in-current-document-via-python/65718>\
**Category:** Revit\
**Tags:** revit, python\
**Created:** [July 1, 2021, 12:03pm UTC](https://forum.dynamobim.com/t/open-close-worksets-in-current-document-via-python/65718 "2021-07-01T12:03:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andhamer](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andhamer/32/106256_2.png) [@andhamer](https://forum.dynamobim.com/u/andhamer)\
**Post date:** [July 1, 2021, 12:03pm UTC](https://forum.dynamobim.com/t/open-close-worksets-in-current-document-via-python/65718/1 "2021-07-01T12:03:04Z")

</div>

Hello everyone.  
I’m trying to create PyScript for open/close worksets.  
In the beginning I collect worksets via Orchid with using name filters, than transfer it to my script. In the script I collect WorksetId and get it to _WorksetConfiguration().Close()_, but it not work.  
Why it didn’t works?((

 ![t112_010721](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/f/7fa6e5d5a4ec5c1395b545a3e1395014036dc2af.png)

---

<div class="post-metadata">

**Author:** ![Manel\_Fernandez](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/manel_fernandez/32/9123_2.png) [@Manel\_Fernandez](https://forum.dynamobim.com/u/Manel_Fernandez)\
**Post date:** [July 1, 2021, 12:44pm UTC](https://forum.dynamobim.com/t/open-close-worksets-in-current-document-via-python/65718/2 "2021-07-01T12:44:31Z")

</div>

Hi there,

You should use:  
[https://www.revitapidocs.com/2020.1/fa6d4b89-a703-80ee-26a6-e88aa89b96a5.htm](https://www.revitapidocs.com/2020.1/fa6d4b89-a703-80ee-26a6-e88aa89b96a5.htm)

SetWorksetVisibility Method

View.SetWorksetVisibility(WorksetId, WorksetVisibility.Hidden)

Cheers

Manel

---

<div class="post-metadata">

**Author:** ![andhamer](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andhamer/32/106256_2.png) [@andhamer](https://forum.dynamobim.com/u/andhamer)\
**Post date:** [July 1, 2021, 12:52pm UTC](https://forum.dynamobim.com/t/open-close-worksets-in-current-document-via-python/65718/3 "2021-07-01T12:52:57Z")

</div>

Thank you for reply!  
Is it only for view? I need to close worksets in document, not in a view

---

<div class="post-metadata">

**Author:** ![Manel\_Fernandez](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/manel_fernandez/32/9123_2.png) [@Manel\_Fernandez](https://forum.dynamobim.com/u/Manel_Fernandez)\
**Post date:** [July 1, 2021, 1:01pm UTC](https://forum.dynamobim.com/t/open-close-worksets-in-current-document-via-python/65718/4 "2021-07-01T13:01:19Z")

</div>

Sorry mate, I use it in views, not for documents.

Cheers

Manel

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [July 1, 2021, 2:34pm UTC](https://forum.dynamobim.com/t/open-close-worksets-in-current-document-via-python/65718/5 "2021-07-01T14:34:24Z")

</div>

Hello @Manel_Fernandez

Are you try with an WorksetConfigurationOption ?

```auto
import System
from System.Collections.Generic import List
#rest of code
#
# create WorksetConfiguration with CloseAllWorksets by default
wkstConfig = WorksetConfiguration(WorksetConfigurationOption.CloseAllWorksets)
# open Wksets
lstWksetId = List[WorksetId](wkset.Id)
wkstConfig.Open(lstWksetId)

```

---

<div class="post-metadata">

**Author:** ![andhamer](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andhamer/32/106256_2.png) [@andhamer](https://forum.dynamobim.com/u/andhamer)\
**Post date:** [July 2, 2021, 6:34am UTC](https://forum.dynamobim.com/t/open-close-worksets-in-current-document-via-python/65718/6 "2021-07-02T06:34:56Z")

</div>

Yes, I tried.  
It not works.

 ![t115_020721](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/8/08abe38314d9fea164cca7efa8851e71b2358872.png)

---

<div class="post-metadata">

**Author:** ![Thomas\_Mahon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_mahon/32/64209_2.png) [@Thomas\_Mahon](https://forum.dynamobim.com/u/Thomas_Mahon)\
**Post date:** [July 2, 2021, 7:40am UTC](https://forum.dynamobim.com/t/open-close-worksets-in-current-document-via-python/65718/7 "2021-07-02T07:40:54Z")

</div>

It’s currently not possible via the Revit API - the only thing you can do is define which worksets to open / close before you open a Revit document. That’s what WorksetConfiguration / WorksetConfigurationOption is used for but they will do nothing once the document is open.
