When using the create revision by name node in Revit 2023 it keeps create a new numbering sequence with “Dynamo” as a prefix instead of the numbering sequence I have input. I have used the revision by name node on earlier projects (2021 and 2022) and never experienced this problem. Have I missed something obvious or is there a bug in the 2023 API that needs fixed on the Auto-desk side?
Hey Jonny, I’ve been fighting the same issue this week.
I am not even certain what the “name” input does in that node. I can’t seem to find the input anywhere in revit DB after the revision is created. I ended up doing a workaround, create the revision - the new sequence gets created - then in python i find the correct sequence, assign it to the new revision, and delete the old sequence.
below is a few code snippets that you can use. I have grabbed bits and pieces of this python code from various sources online and got it working for my projects. Hopefully these will help you to cobble together something that should work for your situation. There’s obviously a bit extra you’ll need to add in the code but it might help
def set_numberingSequenceId(r, val):
UnwrapElement(r).RevisionNumberingSequenceId = val
return r
try:
revisionNumberingSequences = FilteredElementCollector(doc).OfClass(RevisionNumberingSequence)
for s in revisionNumberingSequences:
sequenceName = s.Name
revisionNumberingSequenceNames.append(sequenceName)
except:
errorReport = "Get Sequence Names not working"
try:
newId = UnwrapElement(IN[1]).Id
TransactionManager.Instance.EnsureInTransaction(doc)
output = set_numberingSequenceId(IN[0], newId)
TransactionManager.Instance.TransactionTaskDone()
except:
errorReport = "Error occurred while setting Revision Number Sequence ID"
I haven’t yet figured out why/how the “Name” parameter is being derived from a combination of the Description and the sequence? Is this intended behaviour?
Thank you very much for sending the python code. I am eager to give it a try and improve my understanding of python, as I have only recently begun my journey in the language. I am currently studying the basics and finding my feet.
I agree with you regarding the name input, as it seems to default to the sequence number and description in the database, regardless of what it is named. Additionally, the revision create method in the API does not require it as an argument, which is quite strange. I previously used the Achi lab revision create node, but it hasn’t been updated for 2023 yet.
I was wondering if you have attempted to write any python nodes to execute the revision create method from the API. I am curious to see if this would result in the same issue.
No not really. I considered it, but because a lot of our firms scripts are predominantly dynamo i decided it was faster for me to use the existing revision.byname and just modify what i needed. I’m also relatively new to python and API so i pick my battles LOL.
If you have a crack at putting the full revision create into a python node in 23 i’d certainly be interested to see what you find
Hello @BrookePeterson , would you kindly provide me with the complete code for this workaround? Despite my best efforts to set up the inputs and make it work on my own, it seems to be beyond my current level of expertise. I may need a few more months to get it working, but I would like to try and resolve this issue as soon as possible. I would greatly appreciate your assistance.
Hey Jonny, the final code i used was modified to work specifically with my firms template/views parameters etc so would still need tweaking anyway. If you would like to post what you have so far I and others will be able to help get it working
I feel like i am probably a million miles away. I copied in the boiler hall template (a lot of which is probably overkill) and have tired to set up the inputs.
I have tried various inputs and just cant get my head around it. I’m sure this is incredibly basic for you but its mind blowing to me
import clr
import sys
sys.path.append(‘C:\Program Files (x86)\IronPython 2.7\Lib’)
import System
from System import Array
from System.Collections.Generic import *
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
The inputs to this node will be stored as a list in the IN variables.
r = IN[1]
newId = IN[0]
output =
val =
Place your code below this line
def set_numberingSequenceId(r, val):
UnwrapElement(r).RevisionNumberingSequenceId = val
return r
try:
revisionNumberingSequences = FilteredElementCollector(doc).OfClass(RevisionNumberingSequence)
for s in revisionNumberingSequences:
sequenceName = s.Name
revisionNumberingSequenceNames.append()
except:
errorReport = “Get Sequence Names not working”
try:
newId = UnwrapElement(IN[1]).Id
TransactionManager.Instance.EnsureInTransaction(doc)
output = set_numberingSequenceId(IN[0], newId)
TransactionManager.Instance.TransactionTaskDone()
except:
errorReport = “Error occurred while setting Revision Number Sequence ID”
2.7 works just fine. You can modify the code to python 3 to make it more current but not required.
I’ve modified your code as below. Its working for me in a test project now.
import clr
import sys
sys.path.append("C:\Program Files (x86)\IronPython 2.7\Lib")
import System
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
#######OK NOW YOU CAN CODE########
def set_numberingSequenceId(r, val):
UnwrapElement(r).RevisionNumberingSequenceId = val
return r
# The inputs to this node will be stored as a list in the IN variables.
if isinstance(IN[1], list):
revs = ProcessList(UnwrapNestedList, IN[1])
else:
revs = [UnwrapElement(IN[1])]
doc = DocumentManager.Instance.CurrentDBDocument
errorReport = None
newId = IN[0]
sequenceName = []
numberingSequenceId = []
try:
allrevisionNumberingSequences = FilteredElementCollector(doc).OfClass(RevisionNumberingSequence)
sequenceNames = []
for s in allrevisionNumberingSequences:
if str(s.Name) == newId:
sequenceName.append(s.Name)
numberingSequenceId = s.Id
elif "Dynamo" in str(s.Name):
elementIdToDelete = s.Id
except:
import traceback
errorReport = traceback.format_exc()
try:
TransactionManager.Instance.EnsureInTransaction(doc)
output = set_numberingSequenceId(IN[1], numberingSequenceId)
TransactionManager.Instance.TransactionTaskDone()
except:
errorReport = "Error occurred while setting Revision Number Sequence ID"
#Delete the unwanted RevisionNumberingSequence created by Dynamo
try:
TransactionManager.Instance.EnsureInTransaction(doc)
doc.Delete(elementIdToDelete)
TransactionManager.Instance.TransactionTaskDone()
except:
import traceback
errorReport = traceback.format_exc()
#Assign your output to the OUT variable.
if errorReport == None:
OUT = output
else:
OUT = errorReport
This is making the assumption that you have already created your chosen revision numbering sequence in Revit interface, the code just selects the numbering sequence name - it doesn’t create it. Then once the revision is swapped to the new sequence the ‘dynamo’ temporary one gets deleted to clean your model.
I’ve tired it in a few test models and keep getting this error at line 37.
Note in the below I’m collecting all revisions for the purpose of testing, they are all set to Dynamo and I’m trying to delete those and set back to Numeric.
try:
allrevisionNumberingSequences = FilteredElementCollector(doc).OfClass(RevisionNumberingSequence)
sequenceNames =
for s in allrevisionNumberingSequences:
if str(s.Name) == newId:
sequenceName.append(s.Name)
numberingSequenceId = s.Id
elif “Dynamo” in str(s.Name):
elementIdToDelete = s.Id
except:
import traceback
errorReport = traceback.format_exc()
output =
try:
for r in revs:
TransactionManager.Instance.EnsureInTransaction(doc)
output.append(set_numberingSequenceId(r, numberingSequenceId))
TransactionManager.Instance.TransactionTaskDone()
except:
errorReport = “Error occurred while setting Revision Number Sequence ID”
“ProcessList” is a routine that handled the input if the input was a list. It was missing from what I sent you.
I minimised the code I gave you partly because it included routines written by other coders that I didn’t want to claim as my work, and to be honest, I probably couldn’t even give credit to the original author since I grabbed bits and pieces from so many places to make mine work for my situation that I cant really remember who wrote all the individual bits and pieces!
Hi Jonny, thanks for pointing me to this tread.
I’m complete new to Python world, getting error message below, all I’ve done is install IronPython2.7 and change the path to correct one Program Files (without x86).
Full code below, much appreciate any help anyone can assist… It’s part of much bigger routine that I’m developing and this is now the last piece of the puzzle.
import clr
import sys
sys.path.append("C:\Program Files\IronPython 2.7\Lib")
import System
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
def set_numberingSequenceId(r, val):
UnwrapElement(r).RevisionNumberingSequenceId = val
return r
#The inputs to this node will be stored as a list in the IN variables.
if isinstance(IN[1], list):
revs = UnwrapElement(IN[1])
else:
revs = [UnwrapElement(IN[1])]
doc = DocumentManager.Instance.CurrentDBDocument
errorReport = None
newId = IN[0]
sequenceName =
numberingSequenceId =
try:
allrevisionNumberingSequences = FilteredElementCollector(doc).OfClass(RevisionNumberingSequence)
sequenceNames =
for s in allrevisionNumberingSequences:
if str(s.Name) == newId:
sequenceName.append(s.Name)
numberingSequenceId = s.Id
elif “Dynamo” in str(s.Name):
elementIdToDelete = s.Id
except:
import traceback
errorReport = traceback.format_exc()
output =
try:
for r in revs:
TransactionManager.Instance.EnsureInTransaction(doc)
output.append(set_numberingSequenceId(r, numberingSequenceId))
TransactionManager.Instance.TransactionTaskDone()
except:
errorReport = “Error occurred while setting Revision Number Sequence ID”
try:
TransactionManager.Instance.EnsureInTransaction(doc)
doc.Delete(elementIdToDelete)
TransactionManager.Instance.TransactionTaskDone()
except:
import traceback
errorReport = traceback.format_exc()
if errorReport == None:
OUT = output
else:
OUT = errorReport
I have posted the code again in formatted text. Hopefully this helps and makes it easier to copy.
the code below works, and have been used 100’s times without fail.
Hopefully copying the below and setting the engine to python 2 will resolve your issues.
keep me posted
import clr
import sys
sys.path.append("C:\Program Files (x86)\IronPython 2.7\Lib")
import System
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
def set_numberingSequenceId(r, val):
UnwrapElement(r).RevisionNumberingSequenceId = val
return r
# The inputs to this node will be stored as a list in the IN variables.
if isinstance(IN[1], list):
revs = UnwrapElement(IN[1])
else:
revs = [UnwrapElement(IN[1])]
doc = DocumentManager.Instance.CurrentDBDocument
errorReport = None
newId = IN[0]
sequenceName = []
numberingSequenceId = []
try:
allrevisionNumberingSequences = FilteredElementCollector(doc).OfClass(RevisionNumberingSequence)
sequenceNames = []
for s in allrevisionNumberingSequences:
if str(s.Name) == newId:
sequenceName.append(s.Name)
numberingSequenceId = s.Id
elif "Dynamo" in str(s.Name):
elementIdToDelete = s.Id
except:
import traceback
errorReport = traceback.format_exc()
output = []
try:
for r in revs:
TransactionManager.Instance.EnsureInTransaction(doc)
output.append(set_numberingSequenceId(r, numberingSequenceId))
TransactionManager.Instance.TransactionTaskDone()
except:
errorReport = "Error occurred while setting Revision Number Sequence ID"
try:
TransactionManager.Instance.EnsureInTransaction(doc)
doc.Delete(elementIdToDelete)
TransactionManager.Instance.TransactionTaskDone()
except:
import traceback
errorReport = traceback.format_exc()
if errorReport == None:
OUT = output
else:
OUT = errorReport