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 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.
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