Can't Set Worksets with Dynamo for Revit 2023

Has anyone tried to set worksets with the new Dynamo release that comes with Revit 2023?
image
I cannot set worksets anymore on a graph that worked in the past with ootb nodes…

Just returns nulls…

I would recomend you waiting for the first hotfix :slight_smile: 2023.1.0

I tend to agree with this sentiment, but, I do believe this is a result of the unit changes finally being done in this release.(https://thebuildingcoder.typepad.com/blog/2021/04/pdf-export-forgetypeid-and-multi-target-add-in.html#2)

I think the built-in set parameter by name node isn’t converting to whatever ForgeTypeId is needed for that node. (I am honestly a bit surprised that method ever worked because setting parameters by name for stuff like that has historically been buggy)

That being said, I would definitely report it on GitHub because they might be able to fix that on the Dynamo side of things.

If it were me, I would be using something that sets that parameter very specifically with the builtinparameter name as documented here, https://thebuildingcoder.typepad.com/blog/2013/01/change-element-workset.html.

And clockwork does this really well:


“But I don’t want to Use Packages”

Also, doable in python (CPython3 script below)

# Load the Python Standard and DesignScript Libraries
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# import Revit API
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import GraphicsStyle,ElementId,Element,BuiltInParameter

# import Dynamo Revit Services
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

# custom def for setting workset
def SetWorkset(element,workset):
    TransactionManager.Instance.EnsureInTransaction(doc)
    param = element.get_Parameter(BuiltInParameter.ELEM_PARTITION_PARAM)
    
    # set based on type
    if isinstance(workset, GraphicsStyle):
        param.Set(workset.Id.IntegerValue)
    elif isinstance(workset, ElementId):
        param.Set(workset.IntegerValue)
    elif isinstance(workset, int):
        param.Set(workset)      
    TransactionManager.Instance.TransactionTaskDone()
    return element

# inputs
elements = UnwrapElement(IN[0])
workset = UnwrapElement(IN[1])

# return the results
if isinstance(IN[0], list): OUT = [SetWorkset(x,workset) for x in elements]
else: OUT = SetWorkset(elements,workset)
5 Likes

Hello all - as per 📢 Dynamo 2.13 - Revit 2023 Set Parameter Issue(s) - Hotfix Out Now this is now fixed in the Revit Hotfix, so please go download :partying_face:

1 Like