LearnRevitAPI
![](https://framerusercontent.com/images/zMFB840Y52OLteloUT4BRuogE.png)
![](https://framerusercontent.com/images/U9zjOvD4k3m6cIJd5bOiu960DeI.png)
Aug 15, 2023
Save all Families from Project
![](https://framerusercontent.com/images/Sd5FTaxiqzG7oeH1ykV6yypUzXo.png?scale-down-to=512)
Often time we want to save our loaded families from Revit projects. Doing it manually is not only boring, but might become time consuming, so let's look at a better approach to save our time with Revit API.
💡 Let's learn how to save all loaded families outside the project.
Output Folder
First of all let's prepare the main folder where each family will be saved.
I like to use folder where my script is located (PATH_SCRIPT), and then we can create folders: "Families", "Revit Year" and "Project's name" to sort it properly.
![](https://framerusercontent.com/images/QbYXJ0BMXBJJ2catKxvcmE.png)
🫳 Get All Families
Next, let's get all our loaded families in the project. We can use .OfClass(Family) to get all families. Also we need to filter out editable families which can be saved outside and not native Revit families.
![](https://framerusercontent.com/images/hve5t2Rod8cOlQkXQqWIgTRgc.png)
📁 Prepare filepaths for families
Once we got our families, we need to prepare filepaths for each family. We will use PATH_FAMILY, which we defined earlier, and then we will add a folder for its Category and the family name itself.
![](https://framerusercontent.com/images/fNb2SopgByNDnROvKhjhm1uL6L4.png)
📁 os.makedirs
Once we have the filepaths, we need to make sure that these folders exists before we try to save a family there. For that we are going to use os.path.exists to check if folder has already been created and os.makedirs if we need to create one.
![](https://framerusercontent.com/images/NmOCLoqVMdgvO2vjiRZfua26A.png)
⬇️ Open and Save Family
We have prepared everything we needed. The last step is to open each family and save it to the path we prepared. For that we are going to use EditFamily and SaveAs methods
💡Also don't forget to close your families to avoid a mess in Revit.
![](https://framerusercontent.com/images/wNrcalh6fcKM446fMPseWfBHMFM.png)
![](https://framerusercontent.com/images/dRXfh6JJNuVihzz6Xx5iPxABpa4.png)
👇 Here is the code Snippet for that
![](https://framerusercontent.com/images/gPYRQg3TJvE48paKRC0AF2gBGRk.png)
📂 Open Final Location
Lastly, I like to open the folder where all families are saved, so users don't have to endlessly scroll through folders looking for it. We can use os.startfile for that.
![](https://framerusercontent.com/images/UqhOTxqEp0vsw00psfY2NlbPEp0.png)
💡Just make sure to keep it outside of the loop so users won't end up with hundreds of open folders.
⚠️NB! Possible Warnings ⚠️
While using this code you will also encounter warnings related to Families. It will pause your script execution until warnings are addressed. It is still quite fast to manually sit and click on each warning, but it's not ideal!
I am going to show you how to suppress warnings in a separate newsletter. For now I hope it won't cause you too much trouble to address them manually.
👀 Final Code
![](https://framerusercontent.com/images/9BTP81q8xnOS4ypeL7xMwg5YB0.png)
Join Newsletter
📩 You will be added to Revit API Newsletter
Join Us!
which is already read by 6700+ people!
![](https://framerusercontent.com/images/svHzzMLtnnRCxtCUwbgAm6CUeB8.jpg)
![](https://framerusercontent.com/images/Y44kwhY0i7q37LzXUjrlxeGUo.jpg)
![](https://framerusercontent.com/images/lqKYmh8rqwZwgY2C9MSQER6iBCI.jpg)
![](https://framerusercontent.com/images/SyGCvJ3dbHsJEyklWWBhweY.jpg)
![](https://framerusercontent.com/images/DwiaUdmQHs3FVdDH2PXwAr0Y.jpg)