Rename an existing Workset


#1

Is there a way to rename an existing workset to a different name in dynamo? I’m wanting to rename the default “Shared Levels and Grids” workset to a different name within a graph I have created that creates worksets based on our company standards. Thanks for any help in advance.


Dynamo graph to rename existing worksets
#2

I couldn’t find a custom node for renaming worksets, but it’s possible since 2015 R2 with the WorksetTable.RenameWorkset method.

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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument

#Converting input from Dynamo to Revit

workset = UnwrapElement(IN[0])
name = IN[1]


#rename workset in a transaction
TransactionManager.Instance.EnsureInTransaction(doc)

WorksetTable.RenameWorkset(doc,workset.Id,name);

TransactionManager.Instance.TransactionTaskDone()

OUT = workset

How to rename the defaulf worksets? is it possible
#3

Thanks. I knew it was in the API but I didn’t know enough about ironpython to implement it. Much appreciated.


#5

Does this script accept lists if for example I want to batch rename worksets?

Or at least the 2 default ones?

Thanks…


#6

Hi @Stavros_Koulis

Yes you can batch rename worksets. Read this how to handle list in Python Dividing parts with dynamo