Hi guys. I am new in Dynamo Revit. Still exploring and learning about this Dynamo.
Is there any ways to export all families (specialty equipment) that had been used in Project to Desktop/folder path?
I had compiled families from different source, format it with my shared parameter and put all the data needed to the families.
Now i want to export all the formatted families to individual family in my desktop included the family that has a few type in single family.
Do you want families which have an active instance of the saved types, or all families and types?
I want all families that I used in the plan even though the families is the types of the same family.
Is that what you mean by an active instance of the saved type?
Let’s say you have only placed instances of the highlighted family types in the project, which families would you want saved?
Would you want to maintain all family types or purge the unused ones?
As an FYI, I don’t have a solution readily handy either way but it will help find the right solution for you by clarifying the above.
i want to save the active family and purge the unused one.
For example, i have another compilation of families. In the compilation, i had only 1 family and that family have hundreds of type. So i separate each of them and numbered it so in the schedule, i can see all of them and put the data for each family. After that, i want to save all the families to my disk and purge it.
Is it possible to make it happen by using dynamo?
Hundreds of types for a family, or hundreds of instances? If types, can you show a screenshot of the project browser so I can see the scope? Sounds like since you’re already in the UI you can simply use the “Save as Library” to save out every family (including it’s types) to the desired directory.
this save as all loadable families into particular folder,
Family save.dyn (18.0 KB)
“Save as Library” will save all the family in the project. I just want ‘Specialty Equipment’ family.
Image below I separate and numbered them for me to insert the data.
Ah, if all you’re looking to do is save out the family documents (guess I misinterpreted the question) you can try this python code, which is a work in progress. Feed in a list of families to save out, a target directory, and a boolean (true / false) to overwrite any which existing or not.
SAVE OUT FAMILY TO DIRECTORY
__author__ = 'Jacob Samll'
__twitter__ = '@Jacob.W.Small'
# Dynamo version - 2.0.3
# Revit version: 2019
#This takes a collection of families from the active document as input 0 and saves them as RFA files to the directory given at input 1, overwriting them acording to the boolean input 2. Only minimally tested, so proceed with caution
sys.path.append("C:\Program Files (x86)\IronPython 2.7\Lib")
#Saves a list of families in the active project to a given directory, using the family name as the file name
import clr #imports the common language runtime to the Iron Python Environment
clr.AddReference("RevitServices") #adds Revit Services library to the CLR
import RevitServices #brings the Revit Services library to the Iron Python environment
from RevitServices.Persistence import DocumentManager #bring the documnet manager module into the Iron Python environment
from RevitServices.Transactions import TransactionManager #brings the transaction manager into the Iron Python environment
clr.AddReference("RevitAPI") #adds the Revit API to the CLR
import Autodesk #imports the Autodesk library into the Iron Python environment
from Autodesk.Revit.DB import * #imports the entirety of the Revit.DB library - this could be made a bit more precise for increased efficiency
##builds some of the consistent stuff before it begins to itterate over the list of inputs
doc = DocumentManager.Instance.CurrentDBDocument #sets the doc variable as the active document
families = UnwrapElement(IN) #sets the base family variable to the contents of input 0
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
directory = IN #sets the directory variable to the contents of input 1
filePaths = [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.
overwrite = IN
TransactionManager.Instance.ForceCloseTransaction() #closes any open transactions to be sure they don't prevent the code from executing
saveAsOptions = SaveAsOptions() #constructs a save as options object for use in the save as operation
saveAsOptions.OverwriteExistingFile = overwrite #sets the overwrite property for the just constructed save as options object to the value of input 2
resultSet =  #builds an empty list to append the result message to.
i = 0 #sets the variable i to 0 to use as a means of iterating though the list of paths in sequence with the list of family documents
#personally I like really verbose messagint to users of code like this - adjust the messaging as you see fit
if overwrite:#if the value of input 2 is true performs the offset lines below
successMessage = " Saved out the family documnet.\n Overwrote any rfa with matching name.\n You can recover from the rfa backup \n in the same directory if such exists." #builds a meaningful success message for when this works with overwrite option set to false
else: #if the value of input 2 was not true performs the offset lines below
successMessage = " Saved the family document.\n No previously existing rfa at path." #builds a meaningful success message for when this works with the overwrite option set to false
#begins to itterate over the list of families
famDocs = [doc.EditFamily(family) for family in families] #gets the family document from the parent family
##there is likely a better way to do this via list comprehension, but I'm too tired to work it out right now - feel free to pass on any better ideas
for famDoc in famDocs: #begins a loop for each family document in the list of family documnets
try: #trys the offset lines below
famDoc.SaveAs(filePaths[i], saveAsOptions) #attempts to save the family document to the path at the matching index using the save as option
resultSet.append(families[i].Name+".rfa:\n"+successMessage) #appends the message to the result set
except: #if the above failed, does this
resultSet.append(families[i].Name+".rfa:\n File was not saved due to\n the following exception:\n "+traceback.format_exc().split("Exception: ")[-1].strip()) #appends the exception in what may consistently be a more human readible result... might want to test this more
i+=1 #increments the value of i by 1
OUT = resultSet #outputs the resultSet list to the Dynamo environment - you could push this as a message for the user
As noted aboe, this is still under development. Also it may be slightly over-commented as I’m using it in a presentation I have coming up, and I tend to over do my comments to begin with.
Thank you for the .dyn file. But when i open the file, i got error on ‘Family.Save’ node.
oh talking about installing others package, can you explain how to install Orchid package manually? because I cannot search package from Dynamo ‘Search for a package’. It will appear “Search returned no results!”.
where can i paste this python code?