Nested families

Hi :wave:

I am trying to create some kind of workaround for nested families using RiR.

First I load empty families into the project, then I use script to read their documents:

    List<Document> familyDocuments = new List<Document>();

    foreach (string familyPath in FamilyPath)
    {
      Document familyDoc = RhinoInside.Revit.Revit.ActiveDBApplication.OpenDocumentFile(familyPath);
      familyDocuments.Add(familyDoc);
    }

    Document = familyDocuments;

Documents are needed to load into families a new family with a simple box geometry. And the last step is to insert the element through a location.

All the steps seem to work except when I try to save the updated host families in the files. I get two errors:

  1. Unable to close all open transaction phases!
  2. RevitAPI: Close is not allowed when there is any open sub-transaction, transaction or transaction group.

I tried changing the script and using the Transaction.Start/Commit function but it didn’t help. Does anyone have a tip for this?
Thanks!

Maybe I will try simplify my question, I have this code trying to edit family from the path:


    Document familyDoc = RhinoInside.Revit.Revit.ActiveDBApplication.OpenDocumentFile(familyFilePath);

    using (Transaction transaction = new Transaction(familyDoc))
    {
      try
      {
        transaction.Start("Edit Family");
        familyDoc.Save();
        transaction.Commit();
      }
      catch (Exception ex)
      {
        transaction.RollBack();
        Print(ex.Message);
      }
    }

and still getting an error: Unable to close all open transaction phases!

It basically doesn’t want to save the file. Does anyone know what am I missing here?

This is a question better suited for Revit API discussion forums, it comes up a lot. It might eventually get answered here, but unless its low hanging fruit its going to be quicker to go to the dedicated forums. There are a lot of considerations when opening family docs.

Here’s an one example from the forum. The error was due to not handling an error in one of the families.