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:

SetWorksetVisibility Method

View.SetWorksetVisibility(WorksetId, WorksetVisibility.Hidden)



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.



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)

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.