Replying back with a potential solution to my issue and to check if there are any issues with it.
After some research, I found this reply with Python code to save out families in a project. I copied it into my graph and modified it a little as I still had RAM issues with it.
Here is my modified code:
"""
SAVE OUT FAMILY TO DIRECTORY
This takes a collection of families from the active document and saves them as RFA files to the path given, overwriting the original.
Original author: Jacob Small
Modified by: LCarrozza4MGVV
Dynamo version: 2.12.0
Revit version: 2022
"""
## Imports
import sys
sys.path.append("C:\Program Files (x86)\IronPython 2.7\Lib")
import clr
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 *
import traceback
## Inputs
doc = DocumentManager.Instance.CurrentDBDocument #sets the doc variable as the active document
families = UnwrapElement(IN[0]) #sets the base family variable to the contents of input 0
#directory = IN[1] #sets the directory variable to the contents of input 1
filePaths = IN[1] #[directory+"\\"+family.Name+".rfa" for family in families] #builds a file path for each family by appending the directory to the family name an an rfa file extension.
if not hasattr(families, '__iter__'): #checks if the input wasn't a list
families = [families] #if not, wraps the object in a list so we can ensure we've got something to iterate over
filePaths = [filePaths]
## Setting Variables
TransactionManager.Instance.ForceCloseTransaction()
saveAsOptions = SaveAsOptions()
saveAsOptions.OverwriteExistingFile = True
resultSet = []
# Begins to itterate over the list of families
for family,path in zip(families,filePaths):
try: # Try to save family to folder
path = path + "\\" + family.Name + ".rfa"
famDoc = doc.EditFamily(family) # Gets the family document from the parent family
famDoc.SaveAs(path, saveAsOptions) # Saves out the family
famDoc.Close(False) # Closes the family doc
famDoc.Dispose() # Releases doc from memory
resultSet.append(family.Name+".rfa saved!")
except: # If try fails, output error message
error = traceback.format_exc().split("Exception: ")[-1].strip()
error = error.split("Parameter name: ")[0].strip()
resultSet.append(family.Name+".rfa not saved.\nException:\n"+error)
OUT = resultSet
I mainly changed how the for loops work and added in “famDoc.Close()” and “famDoc.Dispose()” (is .Dispose() redundant?) to manage memory usage. This seems to work perfectly and is just as quick as the in-UI method, my only hesitation is why does the OOTB note “Document.SaveFamilyToFolder” (or any other package’s save family nodes) not seem to use this since I still have RAM issues with them?
If anyone could take a look at the Python code and advise if there are any issues, that would be great!
Thanks!