Load multiple families from a folder


#1

Hello,
Is there a node to load multiple families from a folder at once? I looked on this forum but I didnt find anything. Thanks!


#2

sure this has been solved before :wink:


#3

This is code though, not a node. Do you have to go into Revit macro creation to use this? Thanks!


#4

Or can I paste it into a code block or something?


#5

If you really want to become good in using Dynamo, will I strongly recommend you to become familiar with Python and Designscript coding. If you dont do that, will you end in some dead ends very fast…

loadFamily.dyn (5.6 KB)

I adjusted the code mentioned previously so it can take a list instead of one family, thats all…

  • Load Revit families from list

    import clr
    clr.AddReference(‚ÄėRevitAPI‚Äô)
    from Autodesk.Revit.DB import *

    clr.AddReference(‚ÄėRevitServices‚Äô)
    import RevitServices
    from RevitServices.Persistence import DocumentManager
    from RevitServices.Transactions import TransactionManager
    doc = DocumentManager.Instance.CurrentDBDocument

    #Inputs is stored in the IN variable
    elements = IN[0]

    #Ensure loaded families can overwrite existing families.
    class FamilyOption(IFamilyLoadOptions) :
    def OnFamilyFound(self, familyInUse, overwriteParameterValues) :
    overwriteParameterValues = True
    return True

      def OnSharedFamilyFound(self, sharedFamily, familyInUse, source, overwriteParameterValues) :
      	return True
    

    #Core data processing
    TransactionManager.Instance.EnsureInTransaction(doc)
    try:
    for element in elements :
    doc.LoadFamily(element, FamilyOption())
    except:
    pass
    TransactionManager.Instance.TransactionTaskDone()

    #Nothing assign to the OUT variable
    OUT = ‚ÄėFamilies is updatet/reloaded‚Äô


Reload Family and overwrite parameter values
Batch Auditing Families
Load multiple Families from a folder and to multiple Revit Models from a folder
#6

Clockwork has a node as well


#7

my code is reloading, meaning overwriting… so there is a difference :slight_smile:

do you need overwriting or not?.. choose the solution you need :slight_smile:


#8

understood erfajo,
Do you know of a site or a set of resources I can go to to learn design script/python. Its not that I dont want to, its that I dont have anyone to teach me. Thanks.


#9

well Python that everywhere :slight_smile:
… and stackoverflow is the goto place for help :slight_smile:

Designscript start with the Dynamo Primer…
In general, search for Designscript or code block… good luck :slight_smile:
http://dynamoprimer.com/en/
http://dynamobim.org/cbns-for-dummies/


#10

Well I already went through Primer, Athought I dont feel like it was very indepth. If thats all design script is then that is pretty minimal. What do you mean python that everywhere? do you have a website or something? kind of like the dynamo dictionary?


#11

Dont underestimate DesignScript, it can do some powerful things, but agree… it is a very slight documentation and almost no guidance you can get beside this community.

Python… here you go :slight_smile:

please take the time to mark the solution you end up using :slight_smile:


#12

This script doesnt seem to do anything. I saved some particular families that I wanted into the folder indicated in the script below. However after running the script, nothing seems to happen. I noticed that the Directory.ContentsAll node seems to have changed. Is it the clockwork node? I cant seem to find a DanEDU package in the package manager…Please advise. thanks.


#13

Hello John,
How do you load an entire folder using this node? I tried using it with the directory.path node, but that doesnt seem to work. Please advise.


#14

‚ÄėDanEDU Dynamo‚Äô is present as a downloadable package, and ‚ÄėDirectory.ContentsAll‚Äô is present in the package.
The script provided open all files in a directory and load/overwrite the content in the open project file… you have to verify this in the project file, you cant see it inside Dynamo. See what the code does, it is quite clear what happens.

I am sure that the Clockwork node works as supposed, but not in exact the same way as mine. If they were totally equal would I remove my node since Clockwork is a much larger package than mine. I only provide nodes that can do things slightly different or more efficient.
Take my ‚ÄėListClean‚Äô and ‚ÄėListReplace‚Äô node that is among the most efficient I have seen and I would love that the OOTB node would be efficient in the same way, so I could remove mine. if you want to know more, then continue reading here, the code is public‚Ķ


#15

I know it isn’t the Dynamo way- but sometimes an automated method is more work than a manual one
So perhaps I am lazy, but I just drag & drop families using Windows Explorer

For families in nested folders- search for *.rfa, and then drag/drop all the files from the search window.

Andrew


#16

@Andrew_Hannell you are so compleatly right :slight_smile:
…dont do it more complicated than needed :slight_smile:

My reason for doing it is that the ‚ÄėDirectory.ContentsAll‚Äô takes a recursive call in a directory so by just giving the folder root I can load hundreds of files and update families on the fly in a project :slight_smile:

Searching for .rfa files… that was smart, why didnt i think about that way to do it :slight_smile:


#17

See below video, but the process is fairly simple to load a list of families at once. Get all the relevant files and its full path(I used python os module with walk and python filtering to output a list of locations from files indicated in excel file). Once here this is inputted into the loadfamily node and it will load the full list of files into the relevant project file.


#18

Andrew,
Yeah I know, but I just wanted to learn how to do it in dynamo. Thanks though!


#19

@Brendan_Cassidy,
thats pretty slick. I would love to look at that script but it says you wont share it? I mean it looks cool, but if I cant see how your doing it, it doesnt really help me at all. Thanks anyways though!


#20

@mix Yeah not willing to share until i possibly do some other things or release as a package.

Within my last message i give enough information on how you can load rfa families into a revit project, with the video to show you it starting from a excel file via os.walk for python and filtering. Or if you can get a dynamo node that lists all files in a folder then do a filter by if it contains rfa and if yes keep these then load them into the load family node as a full list.