Sample Code Revit Batch Processor 1.1.16 documentation
Creates a new revision in a revit document up to version 2022.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revision_data (revisionData) – Named tuple containing revision data
Result class instance.
Revision created status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the message revision created successfully.
result.result: will contain list with single entry: the new revision created
On exception:
result.status (bool) will be False.
result.message will contain the exception message.
Creates a new revision in a revit document version 2023 and onwards.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revision_data (revisionData) – Named tuple containing revision data
Result class instance.
Revision created status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the message revision created successfully.
result.result: will contain list with single entry: the new revision created
On exception:
result.status (bool) will be False.
result.message will contain the exception message.
Gets the revision schedule instance from a given sheet.
If no revision schedule is found, None is returned. If multiple are fopund, the first one is returned.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
sheet (Autodesk.Revit.DB.ViewSheet) – Sheet to get revision schedule from.
Revision schedule instance or None if not found.
Autodesk.Revit.DB.ScheduleSheetInstance or None
alias of revisionData
Returns all revisions in model as list of named tuples.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
list of named tuples containing revision data
[ revisionData ]
Creates a revision in the document.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revision_data (revisionData) – Named tuple containing revision data
Result class instance.
Revision created status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the message revision created successfully.
result.result: will contain list with single entry: the new revision created
On exception:
result.status (bool) will be False.
result.message will contain the exception message.
Sets a revision status to ‘Issued’.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revision (Autodesk.Revit.DB.Revision) – The revision
Result class instance.
Revision status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the message revision marked as issued successfully.
result.result: empty list
On exception:
result.status (bool) will be False.
result.message will contain the exception message.
Sets a revision, identified by its id, status to ‘Issued’.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revision_id (Autodesk.Revit.DB.ElementId) – The Id of the revision.
Result class instance.
Revision marked as issued status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the message revision marked as issued successfully.
result.result: empty list
On exception:
result.status (bool) will be False.
result.message will contain the exception message.
Adds revisions to single sheet
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
sheet (Autodesk.Revit.DB.SheetView) – The sheet to add the revision to.
revision_ids ([Autodesk.Revit.ElementId]) – List of revision ids
Result class instance.
Revision adding to sheet status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the message revision added to sheet successfully.
result.result: empty list
On exception:
result.status (bool) will be False.
result.message will contain the exception message.
Get all issued revisions in a model.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
list of revision objects
[Autodesk.Revit.DB.Revision]
Get the last issued revision from a model.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
A revision object or None if no issued revision in the model
Autodesk.Revit.DB.Revision or None
Updates the revision sequence number of a revision.
Pop the revision from its current index in the revision sequence list. Insert it again at the new index
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revision (Autodesk.Revit.DB.Revision) – the revision
new_sequence_number (int) – The new index (sequence number ) of the revision. 1 based!!
Result class instance.
Revision re-ordering status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the message revision re-ordered successfully.
result.result: new revision sequence list
On exception:
result.status (bool) will be False.
result.message will contain the exception message.
Attempts to replace the current revision sequence with the one past in.
Note: both sequences must contain the same revisions…just in a different order.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revision_sequence (IList<ElementId>) – List of revision element ids describing the new sequence.
Result class instance.
Revision re-ordering status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the message revision re-ordered successfully.
result.result: new revision sequence list
On exception:
result.status (bool) will be False.
result.message will contain the exception message.
Checks if revisions in the document are set to be ‘by sheet’. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document
True if revisions are by sheet, False if revisions are ‘by project’.
bool
Deletes all revision in file passing filter in one transaction.
doc (Autodesk.Revit.DB.Document) – Current model document
revision_description_filter (list, optional) – list of filters, defaults to []
Result class instance.
result.status. True if all possible revisions where deleted successfully, otherwise False.
result.message will contain the name(s) of the revisions excluded by filter and number of revisions deleted.
result.result empty list
On exception:
result.status (bool) will be False.
result.message will contain generic exception message.
result.result will be empty
To get the complete revision history of a sheet, without using a revision schedule, use this module.
The flow is as follows:
Check if revisions vary by sheet or are project-wide
Get all revision IDs from the sheet using ViewSheet.GetAllRevisionIds()
Loop over each revision ID and get the revision element using Document.GetElement(revisionId)
For each revision: - Get the revision sequence ID using Revision.RevisionNumberingSequenceId - Determine the sequence type (Numeric, Alphanumeric, or None) - Create appropriate storage object based on sequence type:
Numeric: Uses prefix, suffix, start number, and minimum digits
Alphanumeric: Uses prefix, suffix, and predefined sequence
None: Uses the revision’s RevisionNumber property directly
Store the revision data with its index position on the sheet
Build a dictionary with revision sequence ID as key and list of storage objects as values - Each storage object tracks:
The revision element
Its index on the sheet (for maintaining original order)
The sequence settings needed to generate the revision value
Build the final revision data list by: - Iterating through sheet positions (0 to number of revisions) - Finding the matching storage object for each position - Generating the actual revision value using the storage object’s sequence counter - Pairing the revision value with its Revit element
Return list of tuples: (revision_value, revision_element) in sheet order
General notes:
In alphanumeric mode: if the number of revisions exceeds the entries in the predefined sequence, the sequence continues with A,B,C…Z,AA,BB,CC,AAA,BBB,CCC and so on.
The module handles both “revisions vary by sheet” and “same revisions for all sheets” scenarios through the storage objects’ internal logic.
Builds the revision data list from the revision dictionary and number of revisions on sheet. :param rev_dictionary: The revision dictionary with sequence id as key and list of revision by sheet storage instances as value. :type rev_dictionary: dict :param number_of_revs_on_sheet: The number of revisions on the sheet. :type number_of_revs_on_sheet: int
The list of revision data tuples (revision value, revision Revit element).
[(str, Autodesk.Revit.DB.Revision)]
Gets the revisions from a sheet.
doc (Autodesk.Revit.DB.Document) – The Revit document.
sheet (Autodesk.Revit.DB.ViewSheet) – The Revit sheet (ViewSheet).
The list of revision data tuples (revision value, revision Revit element).
[(str, Autodesk.Revit.DB.Revision)]
Gets a revision sequence by its name. If no match is found None is returned!
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revision_sequence_name (str) – The sequence name
The matching sequence or None
Autodesk.Revit.DB.RevisionNumberingSequence
Creates a revision sequence with provided name and settings.
Will throw an exception if sequence creation failed.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
revision_sequence_name (str) – The name of the sequence
alpha_settings (Autodesk.Revit.DB.AlphanumericRevisionSettings, optional) – Custom settings, defaults to rdb.AlphanumericRevisionSettings()
The new sequence.
Autodesk.Revit.DB.RevisionNumberingSequence