Upgrading multiple files at once issue

Hi everyone,

I have made a workflow that fetches all files in our library (in Revit 2021) and then it checks our 2022 library, and upgrades all models to that either dont exist in the 2022 folder, or dont have the same last modified date.

Unfortunately at the very end im encountering an issue where all files are written with the same content, and exact same file size. I assume this is just a lacing issue or caused by me not using a for each… with python

Can anyone tell me how to do the last part? where it opens the documents and saves all of them to the new folder?

For clarification…

Our company works with 4 different revit versions. Our families and templates we make ourselves are always made in the olders (still used) version of Revit. In this case its Revit 2021. We maintain these families only in 2021, for UX we upgrade these models after updating them, to all our newer revit versions. Its incredibly tedious and i want to batch upgrade it like this.

I differentiate between .rfa and .rvt so i can print out a PDF of the startview, later on when this is working…

This is the part that doesnt work as expected, i assume its just saving the same doccument 4 times

That resolution…

Hold on, making a new image

I plagiarized the python code in the save document node, and the open document code mentioned here:

to work with an array of documents and paths…

import clr

# Add references to RevitAPI and RevitServices

# Import necessary modules
from RevitServices.Persistence import DocumentManager
from Autodesk.Revit.DB import Document, ModelPathUtils, OpenOptions, DetachFromCentralOption, SaveAsOptions

# Input parameters
document_paths = IN[0]  # List of document file paths
save_paths = IN[1]  # List of target save paths

def open_and_save_documents(document_paths, save_paths):
    result = []
    for doc_path, save_path in zip(document_paths, save_paths):
        # Open the document
        doc = DocumentManager.Instance.CurrentDBDocument
        app = doc.Application
        model_path = ModelPathUtils.ConvertUserVisiblePathToModelPath(doc_path)
        open_options = OpenOptions()
        open_options.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets
        doc_on_disk = app.OpenDocumentFile(model_path, open_options)
        # Save the document
        path_to_save = save_path  # No extension added
        save_options = SaveAsOptions()
        save_options.OverwriteExistingFile = True
            doc_on_disk.SaveAs(path_to_save, save_options)
            result.append((True, doc_on_disk))

            result.append((False, doc_on_disk))
    return result

# Call the function to open and save documents
result = open_and_save_documents(document_paths, save_paths)

# Output the results
OUT = result