From 1eebeb7f9c412ca7973f92324fd5bb3508a1e2a2 Mon Sep 17 00:00:00 2001 From: Connor Ivy Date: Wed, 8 Mar 2023 12:15:08 -0600 Subject: [PATCH] add close doc function --- xUnitRevitUtilsShared/xru.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/xUnitRevitUtilsShared/xru.cs b/xUnitRevitUtilsShared/xru.cs index 719d723..6c4bd00 100644 --- a/xUnitRevitUtilsShared/xru.cs +++ b/xUnitRevitUtilsShared/xru.cs @@ -47,6 +47,23 @@ namespace xUnitRevitUtils UiContext.Send(x => doc = Uiapp.OpenAndActivateDocument(filePath).Document, null); Assert.NotNull(doc); return doc; + } + /// + /// Closes the provided Revit document + /// + /// Revit document to be closed + /// If true, saves changes to document before closing + /// + /// Bool indicating whether or not the document was successfully closed + /// + public static bool CloseDoc(Document doc, bool saveChanges = false) + { + if (doc == null) + return false; + + var result = false; + UiContext.Send(x => result = doc.Close(saveChanges), null); + return result; } ///