Error RenameWorkset method

Dear forum,

I’m trying to rename a Workset using Python and the Revit API.
Here is my code :

# -*- coding: latin-1 -*-

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import (
    FilteredWorksetCollector, WorksetKind, Transaction
)
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

ws_table = doc.GetWorksetTable()
doc_ws = FilteredWorksetCollector(doc).OfKind(WorksetKind.UserWorkset).ToWorksets()
ws = doc_ws[0]
t =  Transaction(doc, "RenameWorkset")
t.Start()
ws_table.RenameWorkset(doc, ws.Id, "test_name")
t.Commit()

But I get the following message :

However, this seems to be the correct way to call the RenameWorkset method according to the documentation.

Which version of the Revit you use will impact how you call this out of the box. 2026 will differ from 2025 will differ from 2024 will differ from 2023 all based on the Python engine you’re using in each build (it has to update release to release for security reasons and to enable new features) and the .NET and Revit API changes.

So… which Revit version are you in?

Often it helps out output the list of things you can do with the object you have by commenting out the line which is causing the error (i.e. ws_table.RenameWorkset(doc, ws.Id, "test_name")) and concule the script with the directory of actions performable (i.e. OUT = dir(ws_table))

Hi @tomcosse123

RenameWorkset is a static method (not an instance method)

1 Like