Open/Close Worksets in current document via Python

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?((

Hi there,

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

SetWorksetVisibility Method

View.SetWorksetVisibility(WorksetId, WorksetVisibility.Hidden)

Cheers

Manel

1 Like

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

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

Cheers

Manel

Hello @Manel_Fernandez

Are you try with an WorksetConfigurationOption ?

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)
2 Likes

Yes, I tried.
It not works.

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.

5 Likes