Hello everyone,
I’m currently trying to upgrade an OkPy script from IronPython to CPython for Revit 2025, and I’m encountering an issue. Specifically, the .Add
method for adding to a list no longer works in CPython, and I’ve been struggling to figure out why.
Here’s the situation: the original script—used to create a new revision and then add it to a sheet—worked perfectly in IronPython. It appended the new revision to a list of existing revisions. However, this functionality is now broken in CPython, and I haven’t been able to resolve it.
I’ve searched online and used ChatGPT, but haven’t found a definitive solution. If anyone can shed light on this or offer a working approach in CPython, I’d really appreciate it.
I’ve tried replacing the .Add
method with .append
. While the script runs without errors, it doesn’t behave as expected. Instead of adding the new revision to the existing list of revisions on the sheet, it creates a new revision but replaces the current list—removing all previous revisions from the sheet, even if the “Revision Issued” box was checked in the revision manager.
Additionally, if there are any tutorials, courses, videos, or forum posts that clearly explain the differences and nuances between IronPython and CPython—especially in the context of Revit scripting—that would be extremely helpful. I’ve tried Googling, but I might not be using the right search terms.
Thanks in advance!
import clr
clr.AddReference(‘RevitAPI’)
clr.AddReference(“RevitAPIUI”)
from Autodesk.Revit.DB import*
from Autodesk.Revit.UI import*
from System.Collections.Generic import List#The current uidoc, doc, uiapp, and app are stored in the following variables
doc = currentdoc
app = app
uidoc = uidoc
uiapp = uiapp
inputs = inputssheets = inputs[“MyInput1”]
revnotes = inputs[“MyInput2”]
dclissuedby = inputs[“MyInput3”]
SequenceType = inputs[“MyInput4”]
Counter = 0##Create Transaction##
transaction = Transaction(doc)
transaction.Start(“OkPy - Sheet Revisions”)
for sheet in sheets:
sheet_number = sheet.SheetNumber
new_revision = Revision.Create(doc)
new_revision.RevisionNumberingSequenceId = SequenceType
new_revision.Description = sheet_number +" "+ revnotes
new_revision.IssuedBy = dclissuedby
revision_id_list = sheet.GetAdditionalRevisionIds()
revision_id_list.Add(new_revision.Id)
addrev = sheet.SetAdditionalRevisionIds(revision_id_list)
Counter = Counter + 1transaction.Commit()
message = TaskDialog
mtext = str(Counter) + " Number of Sheets Revised"
message.Show(“Batch Revisions”, mtext)