Clockwork Element.SetWorkset node

I’m attempting to use the Clockwork Element.SetWorkset node to set the worksets for reference planes, levels, and grids in my model and am only having limited success. The node runs, but only shows that some of the input elements have had their workset successfully set.

My Python before the node shouldn’t matter, but here it is anyway - finding or creating the desired workset:
import clr

from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

#Collecting workset elements, workset ID's, and workset names
worksetCollect = FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset)
worksets = FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset).ToWorksets()
worksetIds = worksetCollect.ToWorksetIds()
worksetNames = [i.Name for i in worksetCollect]

#Is "Shared Levels and Grids" available in model?
if "Shared Levels and Grids" in worksetNames:
	index = worksetNames.index("Shared Levels and Grids")
	outWorkset = worksets[index]
#If not, create it
	outWorkset = Workset.Create(doc, "Shared Levels and Grids")

OUT = outWorkset

and yes, I know I can clean up my selecting element categories - that was left over from a different process I was trying before :slight_smile:

Hey Jack,

  Your python script is only for creating shared levels & Grids workset. why dont you create a program as shown in the below image.I used Orchid Nodes here.

Hi Harsha -

I’m using the Python to create a workset if the one does not exist - I’m creating this tool to work with/enforce our office BIM standards.
I’m trying to avoid using the workset dropdown list nodes because any given model may have more or less worksets, which throws off the index of the item chosen - this script will be used with Dynamo Player by users who have little to no Dynamo experience so it needs to always set these elements to the “Shared Levels and Grids” workset.
Currently my only problem is that the element.setworkset is failing for many of the elements I feed it.

1 Like

@Andreas_Dieckmann maybe you can help with this one? The clockwork element.setworkset node is failing on a seemingly random basis here. Some elements are successfully updated while others of the same type in the same list are not. Any ideas?