Setting Multiple Workset Visibilities

I’m setting up a Project Start Up script to auto create worksets, set up their global settings, and then set individual workset visibilities into view templates. I have creation and global settings operating. I am struggling with using the Archilab node View.SetWorksetVisibility. The Archilab node does not seem to want to lace in the same method Element.SetParameterByName operates and no matter which pattern of iterations I try, I can’t seem to get it to assign properly. Has anyone ever ran into this and found a solution?

From top to bottom on the left, I have:
list of view templates as their view elements
the worksets as pulled from archilab.Workset.GetAll() for compatibility with View.SetWorksetVisibility
The list of visibility settings as a lists that match formatting of the other lists

@scottW4TRA ,

can you not do it via a view-template ? and set it to specific views?

When in doubt, use 1-to-1 inputs. Lacing and list levels still follow the rules of the node. If the node expects a certain structure it may be more difficult to get exactly what you want. Structure your lists so that there is no uncertainty.

No. Project templates cannot be workshared so you can’t host workset information into the View Templates.

@scottW4TRA how did you manage the default visibility for the worsets in the model? Thanks

Got busy running the business and totally missed your message back in August. I’ll try isolating each workset and running it 1-to1. Thanks for the input

Default will always be visible in all views when you create them. After creation, you have to manipulate. I either found or created a python for it. If found I apologize to whomever I found it from, as I can’t give proper credit.

#import libraries
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc =  DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

# collect all worksets ids and names
filter = WorksetKindFilter(WorksetKind.UserWorkset)
WkSetId = [w.Id for w in FilteredWorksetCollector(doc).WherePasses(filter)]
WkSetNames = [w.Name for w in FilteredWorksetCollector(doc).WherePasses(filter)]
result = []
# Inputs
names,bool = IN

#Get WorksetDefaultVisibilitySettings and SetWorksetVisibilty by workset name
for wid, wnm in zip(WkSetId,WkSetNames):
	if wnm in names:
		TransactionManager.Instance.EnsureInTransaction(doc)
		wvb=WorksetDefaultVisibilitySettings.GetWorksetDefaultVisibilitySettings(doc).SetWorksetVisibility(wid,bool)
		gwvb=WorksetDefaultVisibilitySettings.GetWorksetDefaultVisibilitySettings(doc).IsWorksetVisible(wid)
		if not gwvb:
			result.append('Visibility in all Views Off')
		else:
			result.append('Visibility in all Views On')
        TransactionManager.Instance.TransactionTaskDone()

OUT = result
1 Like

Thank you so much that will help me a lot

I edited so the python can be copied correctly.
Also I should add, that list of worksets is all in a string format

If I can get the workset assignments to push into view templates to operate, I’ll make a new post that has everything complete.

1 Like

I’d love to see a greater string than the image you posted. I’d love to have the pass through and wait options so I don’t need 2 different scripts. I tried the python script but it didn’t affect my user worksets in the project at all. Not sure what I am doing wrong here.