How to rename Worksets?



Hi - I am trying to batch rename Worksets. Admittedly I don’t have much experience with python and am really guessing at the modifications required to rename in batch vs. by single workset.

import clr
from Autodesk.Revit.DB import *

import Revit

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])
names = IN[1]

#rename workset in a transaction



OUT = worksets

Complete script;

ReName Worksets.dyn (14.4 KB)

Thanks for any help!!


You have to iterate over your lists of worksets and names using a ForLoop and zip()

import clr

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

import Autodesk
from Autodesk.Revit.DB import *

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIDocument

worksets = UnwrapElement(IN[0])
names = IN[1]


for workset, name in zip(worksets,names):
	WorksetTable.RenameWorkset(doc,workset.Id, name)

OUT = worksets

Let me know if this works


Hi @awilliams - thank you for your help!!

I get;
IronPythonEvaluator.EvaluateIronPythonScript operation failed.
unexpected token ‘‘’


Hmm I don’t see any extraneous apostrophes in the code I pasted so I’m thinking maybe just a copy/paste error? Try deleting all the contents of your Python script node and repasting


This would pop up if you mixed tabs and spaces in the same file. I would just go through it and check that you are consistently using one or the other.


I ran the script above and it worked without error so it must be a copy/paste slip up, but thank you for that info! I read the error quickly and thought I saw “’” (an apostrophe). Good to know in case I run into that error on my end at some point


Ha, my bad. If it’s really just an apostrophe then you are totally right. It would not show that message. Any message about illegal characters or unexpected new line, could be caused by what I was referring to.


Could you show a screen shot of your graph and error?


Hi @awilliams, @Konrad_K_Sobon, @salvatoredragotta

I realized I was making a very beginner mistake :flushed: and importing the script as a string.

I am getting an error that the ‘GIven Workset Name is already in use’?

Thank you for your help!!


That’s pretty self explaining…given name is already used. Workset names must be unique.


I tyring to rename this worksets to uppercase but it appears that the code have an error the python show Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 21, in
TypeError: expected WorksetId, got inttest.dyn (22.7 KB)