Hi
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:
Unable to close all open transaction phases!
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?
Japhy
(Japhy)
December 7, 2023, 2:02pm
3
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.
Search the forum first, if its something to do with the Revit API try Revit API forums, Stack Overflow, Youtube & various blogs, they are all great resources.
Japhy
(Japhy)
December 7, 2023, 2:04pm
4
Here’s an one example from the forum. The error was due to not handling an error in one of the families.
Hello,
I am trying to write a GHPython script for Rhino Inside Revit that will iterate through a folder of families and assign the built-in material parameter for the family geometry to a shared family parameter. I created the families using Rhino Inside Revit and a custom generic model template, but I was unable to associate the geometry to the family parameter at time of creation. I am hoping to process these families after the fact, but I am getting a transaction error. Any advice would be a…