Latest revision number on sheet

Hello :slight_smile:

Is there a way to get the latest revision of the drawing?

For example, if I have a list of revisions like [P01, P02, T01, C01, C02], how can I get the C02 string value?

At the moment, I am unable to see a solution :cry: I really want to avoid iterating over each drawing and getting the list of revision sequences, and then getting the sequential number with the prefix.

1 Like

@Gian_Claudio ,

i think you have index by -1.
so you have the last item

lis = ["A1","A2","A3","A4","A5"]

lastItem = lis[-1]



hello :slight_smile:

sorry I have not given more context

sheetInDoc = query.get_sheets()
for i in sheetInDoc:
    if query.get_current_sheet_revision(i) != None:
        latest =[query.get_current_sheet_revision(i)][0]
        rev.append([i.SheetNumber, latest,\
print (rev)

from here how can I get the latest revision?

1 Like


query is from which module ?

the model is from pyrevit:

and I have imported like that :slight_smile:

from pyrevit.revit import query

1 Like


what do want to access ?


accessing by Number ?

you want the index!

yes, I want to get the index… I am not sure how to get this it looks like that I need to iterate over and get the index of each numbering type


tricky, i just can access the template but not the index itself


sheetInDoc = query.get_sheets()

rev = []
for i in sheetInDoc:
    if query.get_current_sheet_revision(i) != None:
        latest = [query.get_current_sheet_revision(i)][0]
        # rev.append([i.SheetNumber, latest,latest.RevisionDate,latest.Description,latest.RevisionNumberingSequenceId])


accessing the sequense

Assuming that the “latest” revision means the more recent one, you can just check wich element of the list has the max value at index 2:

latest_rev = max(rev, key=lambda x: x[2])

The key argument is used to extract the values to compare, and it defaults to identity (= the value itself);
The lambda lets you create an anonymous function on a single line.

Taking a step further, I would take advantage of generators and functional programming to skip the list

sheets_and_revs = (
    (s.SheetNumber, query.get_current_sheet_revision(s)) 
    for s in query.get_sheets()
sheets_with_revs = (sr for sr in sheets_and_revs if sr is not None)
latest = max(sheets_with_revs, key=lambda x: x[1].RevisionDate)
sheet_number, revision = latest

I don’t know if this is what you mean, but I hope it can help.

def GetRevisionSequences(sheets):
    revisionSequences = []
    for sheet in sheets:
        sub_lst = []
        revision_Ids = sheet.GetAllRevisionIds()
        # print (revisions)
        for Id in revision_Ids:
    return revisionSequences

def GetAllRevisionsOnSheet(sheets):
    revisions = []
    for sheet in sheets:
        sub_lst = []
        revision_Ids = sheet.GetAllRevisionIds()
        for Id in revision_Ids:
    return revisions

selectedSheets = forms.select_sheets()
allRevisions = GetAllRevisionsOnSheet(selectedSheets)
revisionSequences = GetRevisionSequences(selectedSheets)
latestIndex = [len(revList)-1 for revList in revisionSequences]
latestRevision = []
for sublst,ind in zip(allRevisions,latestIndex):

print ("All revision sequences on sheets: ")
print (revisionSequences)
print ("---------------------------------------------------------------------")
print ("The latest index: ")
print (latestIndex)
print ("---------------------------------------------------------------------")
print ("The latest revision: ")
print (latestRevision)

1 Like