Export Families from Revit File By Category

I am trying to export all model families such that I will have 1 input from user the export location and the script will
1- collect all families
2- check the categories of the families - create subfolder in path provided
3- export Families to the subfolders created

I think something is not right in the last node (saveas Node by Crumple)
Also I am using Revit 2020.2

I also attached the dyanmo script and screenshot.
FamilySaveByCategory-2.dyn (29.3 KB)

Why not just use the built in save as library tool?

I am creating a library for the families used and will be alot easier to have them organized by category

1 Like

Thinking you might have to look into using the API directly via Python or C#. Revit 2020 is two years outside of the support window now and most packages won’t support it directly (unsure if Crumple is in that list - maybe test one file to a provided path instead of a group?). I can’t even get it installed without going though multiple hoops and I work for Autodesk.

Can you upgrade to a newer build?

okay, thats a nice idea for the project no I wont be able to upgrade the revit model. but yeah I can use a higher version lets say revit 2022 and 2024 but then will i be able to import the famlies back in the revit 2020

Nope - upgrading is a one way street. You’re going to have to do it manually or build some custom code if you can’t get Crumple to work.

Is the person(s) preventing you from upgrading aware of the security vulnerabilities presented to all firms participating in the project by using this old version? There is a reason AEC suffers more infosec incidents than other industries, and most of it has to do with simple stuff like not upgrading…

Thanks for pointing that out. I think we kinda went in another direction there regarding the script
do u have a workflow that can help with that or something that I have been doing wrong

I don’t have code to do this already and since you’re so far out of support I can’t help even indirectly with generic graph beyond what you’ve already seen. However as this is a one time process (seriously if it’s a many time thing for a version this far out of support the project has bigger issues than family libraries to worry about ) you can do it fairly automated with an alternative workflow.

  1. Rename all families to append the category as a prefix. This can be done with Dynamo in your build without too many issues - look into the clockwork package if memory serves.
  2. Save out the entire family library to a working directory using the Revit UI.
  3. Generate a directory in the working directory for each category (again this shouldn’t be too hard with Dynamo so you can automate that too)
  4. Move the files from the working directory to the related category directory based on the names. Again fairly straight forward in your Dynamo build.
  5. Rename the files to remove the category prefix, once again doable without too much effort.

Steps 1 and 2 have to happen in 2020, but 3-5 can happen in any tool you like as long as it has access to the file system (straight Python, powershell, power automate, any version of Dynamo sandbox, C#, VBA…).

Hi, I’m not an expert but I think I know where your problem is and I also think I have a better solution. In “create subfolder/category,” look at IN[1] input, There are duplicate values; you have to create 2 lists. list-a telling which file belongs to which subfolder (could have duplicate values). list-b a list of every category containing no duplicates. With that said, I don’t think you should use dynamo this way for this case, generate a txt file using dynamo that has all the categories for the families (sort the family by name alphabetically, turn the list into a category only and then export it, You have many option for the file format; i suggest .txt for simplicity) Then export all the families manually into a folder (for this kind of automatic, you don’t do it one by one). then using Python outside of Dynamo, give it the directory you have exported the families to and use the txt file as a guide as to which file belongs to which subfolder. I hope I made sense

2 Likes