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

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#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
else:
	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?

Bumping this thread as I never got an answer…Anyone?

I am just throwing ideas since I do not have access to your model or workflow:

  1. are not those elements that return false already in that workset?
  2. in the python code, see if you can wrap the workset with a dynamo wrapper (with ToDSType) and see if that changes the behavior
  3. use an alternative SetWorkset node from another package…

As you can see, there are already two worksets: Shared Levels and Grids and Workset1 . These are the two default worksets that are automatically created when you first enable worksharing.

So why use the Python to create the Shared Levels and Grids in the first place?

What is the input for ‘Workset’. I could be wrong but afaik it should be a number not a name. Do you feed a Name instead of a Number maybe?

This may help?

Another way to get a name of a Workset i got from another topic.

Knipsel

1 Like

I’m using Python on the chance that a user has deleted Shared Levels and Grids. It happens frequently (somehow)…I think your other comment is the solution.