Getting nested families loaded from family-loaded hook

Hi! I recently got into pyRevit and made my first hook script but i’ve run into an issue that I could use help solving.

I’m trying to make a script that everytime I load a family into a certain project it will write to a database to log the family name and current date and time. I made a script with the family-loaded hook and got it work perfectly except it doesn’t run for any nested families that are also loaded. I need it to also run for, or get family names of, the nested families that are being loaded along with the main family - preferably only the families getting newly loaded or overwritten.

At first I assumed that the script would just run multiple times, one for each family being loaded, but it only seems to run for the main family being loaded and none of the nested families. I tried using the family-loading method instead and the result is the same. I’m sure there’s at least a way to get a list of all the nested families in the main family, but I would much prefer to only get the families that changed or are new.

Does anyone have any ideas to look into or a solution?


I know it hasn’t been long, but I solved my issue using a completely different hook, doc-changed. Using that, I can use EXEC_PARAMS.event_args.GetAddedElementIds() to get all the element IDs that were loaded, including the nested families, then I convert them using FilteredElementCollector(doc, added_id_list).OfClass(Family).ToElements() to get the elements from the IDs. The event also has other attributes/methods like .GetDocument(), .Operation, and .GetTransactionNames() that are useful.

1 Like