From 1d5bd54548c1723258e7ad8296ae1c11bdeca0ec Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 15 Jul 2022 06:10:50 -0400 Subject: [PATCH 01/37] check ownership methods --- Revit_Core_Adapter/CRUD/Update.cs | 7 +++ Revit_Core_Engine/Query/CheckedoutStatus.cs | 50 +++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 Revit_Core_Engine/Query/CheckedoutStatus.cs diff --git a/Revit_Core_Adapter/CRUD/Update.cs b/Revit_Core_Adapter/CRUD/Update.cs index bcd00c5e5..46d9ca2b6 100644 --- a/Revit_Core_Adapter/CRUD/Update.cs +++ b/Revit_Core_Adapter/CRUD/Update.cs @@ -41,6 +41,13 @@ public bool Update(Element element, IBHoMObject bHoMObject, RevitPushConfig push RevitSettings settings = this.RevitSettings.DefaultIfNull(); string tagsParameterName = settings.MappingSettings.TagsParameter; + if(WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByOtherUser) + { + BH.Engine.Base.Compute.RecordError("Element is owned by an user that is not the current user. No updates will be made."); + ObjectNotUpdatedError(element, bHoMObject); + return false; + } + try { element.IUpdate(bHoMObject, settings, pushConfig.SetLocationOnUpdate); diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs new file mode 100644 index 000000000..3ccced610 --- /dev/null +++ b/Revit_Core_Engine/Query/CheckedoutStatus.cs @@ -0,0 +1,50 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Analysis; +using BH.Engine.Adapters.Revit; +using BH.oM.Base; +using BH.oM.Base.Attributes; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BH.Revit.Engine.Core +{ + public static partial class Query + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + + [Description("Returns a list of elements that matcht the given CheckedoutStatus.")] + [Input("elements", "Revit elements")] + [Input("checkedoutStatus", "Revit unique Id of a Revit link instance. If not null, the link instance under this unique Id will be searched instead of the host document.")] + [Output("element", "Revit element matching the input Revit unique Ids.")] + public static List OwnershipStatus(this List elements, CheckoutStatus checkedoutStatus) + { + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == checkedoutStatus).ToList(); + } + /***************************************************/ + } +} From aad097519e0a078fd2d6cc54d9248842e5c428ce Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 15 Jul 2022 06:15:17 -0400 Subject: [PATCH 02/37] update --- Revit_Core_Adapter/CRUD/Update.cs | 7 ------- Revit_Core_Engine/Revit_Core_Engine.csproj | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Revit_Core_Adapter/CRUD/Update.cs b/Revit_Core_Adapter/CRUD/Update.cs index 46d9ca2b6..bcd00c5e5 100644 --- a/Revit_Core_Adapter/CRUD/Update.cs +++ b/Revit_Core_Adapter/CRUD/Update.cs @@ -41,13 +41,6 @@ public bool Update(Element element, IBHoMObject bHoMObject, RevitPushConfig push RevitSettings settings = this.RevitSettings.DefaultIfNull(); string tagsParameterName = settings.MappingSettings.TagsParameter; - if(WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByOtherUser) - { - BH.Engine.Base.Compute.RecordError("Element is owned by an user that is not the current user. No updates will be made."); - ObjectNotUpdatedError(element, bHoMObject); - return false; - } - try { element.IUpdate(bHoMObject, settings, pushConfig.SetLocationOnUpdate); diff --git a/Revit_Core_Engine/Revit_Core_Engine.csproj b/Revit_Core_Engine/Revit_Core_Engine.csproj index 527cfc0e8..1ec9694bb 100644 --- a/Revit_Core_Engine/Revit_Core_Engine.csproj +++ b/Revit_Core_Engine/Revit_Core_Engine.csproj @@ -401,6 +401,7 @@ + From af569d8fb165aae803f72febaea0e6e01b041771 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 15 Jul 2022 06:21:32 -0400 Subject: [PATCH 03/37] Update CheckedoutStatus.cs --- Revit_Core_Engine/Query/CheckedoutStatus.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs index 3ccced610..2c0231418 100644 --- a/Revit_Core_Engine/Query/CheckedoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckedoutStatus.cs @@ -37,10 +37,10 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("Returns a list of elements that matcht the given CheckedoutStatus.")] - [Input("elements", "Revit elements")] - [Input("checkedoutStatus", "Revit unique Id of a Revit link instance. If not null, the link instance under this unique Id will be searched instead of the host document.")] - [Output("element", "Revit element matching the input Revit unique Ids.")] + [Description("Returns a list of elements that match the given CheckedoutStatus.")] + [Input("elements", "Revit elements.")] + [Input("checkedoutStatus", "Revit built-in CheckedoutStatus Enum.")] + [Output("elements", "List of Revit element matching the given checkedoutStatus.")] public static List OwnershipStatus(this List elements, CheckoutStatus checkedoutStatus) { return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == checkedoutStatus).ToList(); From 7789cbd79843e19ecd0acb33fbefd21b9099d199 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 15 Jul 2022 08:59:33 -0400 Subject: [PATCH 04/37] Update CheckedoutStatus.cs --- Revit_Core_Engine/Query/CheckedoutStatus.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs index 2c0231418..84f415324 100644 --- a/Revit_Core_Engine/Query/CheckedoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckedoutStatus.cs @@ -37,13 +37,19 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("Returns a list of elements that match the given CheckedoutStatus.")] + [Description("Returns a list of elements that match the given CheckoutStatus.")] [Input("elements", "Revit elements.")] - [Input("checkedoutStatus", "Revit built-in CheckedoutStatus Enum.")] + [Input("checkoutStatus", "Revit built-in CheckoutStatus Enum.")] [Output("elements", "List of Revit element matching the given checkedoutStatus.")] - public static List OwnershipStatus(this List elements, CheckoutStatus checkedoutStatus) + public static IEnumerable CheckOwnershipStatusIsNotByOtherUser(this List elements) { - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == checkedoutStatus).ToList(); + foreach (var element in elements) + { + if(WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) != CheckoutStatus.OwnedByOtherUser) + { + yield return element; + } + } } /***************************************************/ } From 6062f5ece38c24ac55fb0a2c2ae7aa1147785193 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 15 Jul 2022 16:04:05 -0400 Subject: [PATCH 05/37] Update CheckedoutStatus.cs --- Revit_Core_Engine/Query/CheckedoutStatus.cs | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs index 84f415324..a217854e0 100644 --- a/Revit_Core_Engine/Query/CheckedoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckedoutStatus.cs @@ -36,20 +36,27 @@ public static partial class Query /***************************************************/ /**** Public methods ****/ /***************************************************/ - - [Description("Returns a list of elements that match the given CheckoutStatus.")] + + [Description("Returns a list of elements that are not owned by others.")] [Input("elements", "Revit elements.")] - [Input("checkoutStatus", "Revit built-in CheckoutStatus Enum.")] - [Output("elements", "List of Revit element matching the given checkedoutStatus.")] - public static IEnumerable CheckOwnershipStatusIsNotByOtherUser(this List elements) + [Output("elementsNotOwnedByOthers", "List of Revit elements matching the given checkedoutStatus.")] + public static List ElementsNotOwnedByOthers(this List elements) { - foreach (var element in elements) + var ownedElements = elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByOtherUser).ToList(); + + foreach (Element element in ownedElements) { - if(WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) != CheckoutStatus.OwnedByOtherUser) - { - yield return element; - } + ElementOwnedByOtherError(element); + continue; } + + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) != CheckoutStatus.OwnedByOtherUser).ToList(); + } + + + private static void ElementOwnedByOtherError(Element element) + { + BH.Engine.Base.Compute.RecordWarning($"Revit object could not be updated or modified due to it's CheckoutStatus. Revit ElementId: {element.Id} is owned by another user."); } /***************************************************/ } From 5f4853db6a6de9b735d343ca85ca5b2ec570fcf1 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Sun, 17 Jul 2022 10:51:01 -0400 Subject: [PATCH 06/37] Update CheckedoutStatus.cs --- Revit_Core_Engine/Query/CheckedoutStatus.cs | 139 ++++++++++++++++++-- 1 file changed, 128 insertions(+), 11 deletions(-) diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs index a217854e0..c854de54c 100644 --- a/Revit_Core_Engine/Query/CheckedoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckedoutStatus.cs @@ -37,27 +37,144 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("Returns a list of elements that are not owned by others.")] + [Description("")] [Input("elements", "Revit elements.")] - [Output("elementsNotOwnedByOthers", "List of Revit elements matching the given checkedoutStatus.")] - public static List ElementsNotOwnedByOthers(this List elements) + [Output("", "")] + public static List GetElementsOwnedByOtherUsers(this List elements) { - var ownedElements = elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByOtherUser).ToList(); - - foreach (Element element in ownedElements) + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByOtherUser).ToList(); + } + + [Description("")] + [Input("elements", "Revit elements.")] + [Output("", ".")] + public static List GetElementsOwnedByCurrentUser(this List elements) + { + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByCurrentUser).ToList(); + } + + [Description("")] + [Input("elements", "Revit elements.")] + [Output("", "")] + public static List GetElementsOwnedByNone(this List elements) + { + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.NotOwned).ToList(); + } + + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static bool IsOwnedByOtherUser(this Element element) + { + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByOtherUser) + { + return true; + } + + return false; + } + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static bool IsOwnedCurrentUser(this Element element) + { + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByCurrentUser) { - ElementOwnedByOtherError(element); - continue; + return true; } - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) != CheckoutStatus.OwnedByOtherUser).ToList(); + return false; } - - private static void ElementOwnedByOtherError(Element element) + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static bool IsOwnedByNone(this Element element) + { + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.NotOwned) + { + return true; + } + + return false; + } + + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static CheckoutStatus OwnershipStatus(this Element element) + { + return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id); + } + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static void Checkout(this Element element) + { + if (element.IsOwnedByNone()) + { + ISet elementsToCheckout = new List + { + element.Id + } as ISet; + + WorksharingUtils.CheckoutElements(element.Document, elementsToCheckout); + } + + else if (element.IsOwnedCurrentUser()) + { + ElementOwnedByCurrentUserNote(element); + } + + ElementOwnedByOtherUserWarning(element); + + } + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static void Checkout(this List elements) + { + Document document = elements.First().Document; + ISet elementsToCheckout = new List() as ISet; + + foreach (var element in elements.GetElementsOwnedByOtherUsers()) + { + ElementOwnedByOtherUserWarning(element); + } + + foreach (var element in elements.GetElementsOwnedByCurrentUser()) + { + ElementOwnedByCurrentUserNote(element); + } + + foreach (var element in elements.GetElementsOwnedByNone()) + { + elementsToCheckout.Add(element.Id); + } + + WorksharingUtils.CheckoutElements(document, elementsToCheckout); + } + + + private static void ElementOwnedByOtherUserWarning(Element element) { BH.Engine.Base.Compute.RecordWarning($"Revit object could not be updated or modified due to it's CheckoutStatus. Revit ElementId: {element.Id} is owned by another user."); } + + private static void ElementOwnedByCurrentUserNote(Element element) + { + BH.Engine.Base.Compute.RecordNote($"Revit object with ElementId: {element.Id} is owned by the current user."); + } + + private static void ElementOwnedByNoneNote(Element element) + { + BH.Engine.Base.Compute.RecordNote($"Revit object with ElementId: {element.Id} is not owned by any user."); + } /***************************************************/ } } From 66a3ab1a11e3dce48ec5fe045e23597d9050ef2c Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Sun, 17 Jul 2022 11:09:56 -0400 Subject: [PATCH 07/37] Update CheckedoutStatus.cs --- Revit_Core_Engine/Query/CheckedoutStatus.cs | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs index c854de54c..1edbb8674 100644 --- a/Revit_Core_Engine/Query/CheckedoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckedoutStatus.cs @@ -22,6 +22,7 @@ using Autodesk.Revit.DB; using Autodesk.Revit.DB.Analysis; +using Autodesk.Revit.UI; using BH.Engine.Adapters.Revit; using BH.oM.Base; using BH.oM.Base.Attributes; @@ -42,6 +43,8 @@ public static partial class Query [Output("", "")] public static List GetElementsOwnedByOtherUsers(this List elements) { + ReloadLatestWithMessage(elements.First().Document); + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByOtherUser).ToList(); } @@ -50,6 +53,8 @@ public static List GetElementsOwnedByOtherUsers(this List elem [Output("", ".")] public static List GetElementsOwnedByCurrentUser(this List elements) { + ReloadLatestWithMessage(elements.First().Document); + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByCurrentUser).ToList(); } @@ -58,6 +63,8 @@ public static List GetElementsOwnedByCurrentUser(this List ele [Output("", "")] public static List GetElementsOwnedByNone(this List elements) { + ReloadLatestWithMessage(elements.First().Document); + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.NotOwned).ToList(); } @@ -67,6 +74,8 @@ public static List GetElementsOwnedByNone(this List elements) [Output("", "")] public static bool IsOwnedByOtherUser(this Element element) { + ReloadLatestWithMessage(element.Document); + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByOtherUser) { return true; @@ -80,6 +89,8 @@ public static bool IsOwnedByOtherUser(this Element element) [Output("", "")] public static bool IsOwnedCurrentUser(this Element element) { + ReloadLatestWithMessage(element.Document); + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByCurrentUser) { return true; @@ -93,6 +104,8 @@ public static bool IsOwnedCurrentUser(this Element element) [Output("", "")] public static bool IsOwnedByNone(this Element element) { + ReloadLatestWithMessage(element.Document); + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.NotOwned) { return true; @@ -107,6 +120,8 @@ public static bool IsOwnedByNone(this Element element) [Output("", "")] public static CheckoutStatus OwnershipStatus(this Element element) { + ReloadLatestWithMessage(element.Document); + return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id); } @@ -115,6 +130,8 @@ public static CheckoutStatus OwnershipStatus(this Element element) [Output("", "")] public static void Checkout(this Element element) { + ReloadLatestWithMessage(element.Document); + if (element.IsOwnedByNone()) { ISet elementsToCheckout = new List @@ -140,6 +157,9 @@ public static void Checkout(this Element element) public static void Checkout(this List elements) { Document document = elements.First().Document; + + ReloadLatestWithMessage(document); + ISet elementsToCheckout = new List() as ISet; foreach (var element in elements.GetElementsOwnedByOtherUsers()) @@ -176,5 +196,32 @@ private static void ElementOwnedByNoneNote(Element element) BH.Engine.Base.Compute.RecordNote($"Revit object with ElementId: {element.Id} is not owned by any user."); } /***************************************************/ + + + public static void ReloadLatestWithMessage(Document doc) + { + // Tell user what we're doing + TaskDialog td = new TaskDialog("Alert") + { + MainInstruction = "The requested operation needs to reload changes from central in order to proceed.", + MainContent = "This will update your local with all changes currently in the central model. This operation " + + "may take some time depending on the number of changes available on the central.", + CommonButtons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel + }; + + TaskDialogResult result = td.Show(); + + if (result == TaskDialogResult.Ok) + { + // There are no currently customizable user options for ReloadLatest. + doc.ReloadLatest(new ReloadLatestOptions()); + TaskDialog.Show("Proceeding...", "Reload operation completed, proceeding with requested operation."); + } + else + { + TaskDialog.Show("Canceled.", "Reload operation canceled, so changes will not be made. Return to this command later when ready to reload."); + } + } + } } From f1470c4db7ed020f6ffd8196e9cfcdd81721305d Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Sun, 17 Jul 2022 15:40:01 -0400 Subject: [PATCH 08/37] Update CheckedoutStatus.cs --- Revit_Core_Engine/Query/CheckedoutStatus.cs | 109 +++++++++++--------- 1 file changed, 58 insertions(+), 51 deletions(-) diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs index 1edbb8674..9c89ccfbe 100644 --- a/Revit_Core_Engine/Query/CheckedoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckedoutStatus.cs @@ -38,13 +38,46 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ + [Description("")] + [Input("", "")] + [Output("", "")] + public static bool IsFileLocalModel(this Document doc) + { + return BasicFileInfo.Extract(doc.PathName).IsLocal; + } + + [Description("")] + [Input("", "")] + [Output("", "")] + public static bool IsFileCentralModel(this Document doc) + { + return BasicFileInfo.Extract(doc.PathName).IsCentral; + } + + [Description("")] + [Input("", "")] + [Output("", "")] + public static bool IsFileWorkshared(this Document doc) + { + return BasicFileInfo.Extract(doc.PathName).IsWorkshared; + } + + [Description("")] + [Input("", "")] + [Output("", "")] + public static bool IsAllLocalChangesSavedToCentralModel(this Document doc) + { + return BasicFileInfo.Extract(doc.PathName).AllLocalChangesSavedToCentral; + } + + + + [Description("")] [Input("elements", "Revit elements.")] [Output("", "")] public static List GetElementsOwnedByOtherUsers(this List elements) { - ReloadLatestWithMessage(elements.First().Document); - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByOtherUser).ToList(); } @@ -53,8 +86,6 @@ public static List GetElementsOwnedByOtherUsers(this List elem [Output("", ".")] public static List GetElementsOwnedByCurrentUser(this List elements) { - ReloadLatestWithMessage(elements.First().Document); - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByCurrentUser).ToList(); } @@ -63,19 +94,31 @@ public static List GetElementsOwnedByCurrentUser(this List ele [Output("", "")] public static List GetElementsOwnedByNone(this List elements) { - ReloadLatestWithMessage(elements.First().Document); - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.NotOwned).ToList(); } + [Description("")] + [Input("elements", "Revit elements.")] + [Output("", "")] + public static List GetElementsEditablePerCheckoutStatus(this List elements, bool returnWarnings) + { + if (returnWarnings) + { + foreach (var element in elements.GetElementsOwnedByOtherUsers()) + { + ElementOwnedByOtherUserWarning(element); + } + } + + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) != CheckoutStatus.OwnedByOtherUser).ToList(); + } + [Description("")] [Input("element", "Revit element.")] [Output("", "")] public static bool IsOwnedByOtherUser(this Element element) { - ReloadLatestWithMessage(element.Document); - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByOtherUser) { return true; @@ -87,10 +130,8 @@ public static bool IsOwnedByOtherUser(this Element element) [Description("")] [Input("element", "Revit element.")] [Output("", "")] - public static bool IsOwnedCurrentUser(this Element element) + public static bool IsOwnedByCurrentUser(this Element element) { - ReloadLatestWithMessage(element.Document); - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByCurrentUser) { return true; @@ -104,8 +145,6 @@ public static bool IsOwnedCurrentUser(this Element element) [Output("", "")] public static bool IsOwnedByNone(this Element element) { - ReloadLatestWithMessage(element.Document); - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.NotOwned) { return true; @@ -120,8 +159,6 @@ public static bool IsOwnedByNone(this Element element) [Output("", "")] public static CheckoutStatus OwnershipStatus(this Element element) { - ReloadLatestWithMessage(element.Document); - return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id); } @@ -130,19 +167,17 @@ public static CheckoutStatus OwnershipStatus(this Element element) [Output("", "")] public static void Checkout(this Element element) { - ReloadLatestWithMessage(element.Document); - if (element.IsOwnedByNone()) { - ISet elementsToCheckout = new List + List elementsToCheckout = new List { element.Id - } as ISet; + }; WorksharingUtils.CheckoutElements(element.Document, elementsToCheckout); } - else if (element.IsOwnedCurrentUser()) + else if (element.IsOwnedByCurrentUser()) { ElementOwnedByCurrentUserNote(element); } @@ -157,10 +192,7 @@ public static void Checkout(this Element element) public static void Checkout(this List elements) { Document document = elements.First().Document; - - ReloadLatestWithMessage(document); - - ISet elementsToCheckout = new List() as ISet; + List elementsToCheckout = new List(); foreach (var element in elements.GetElementsOwnedByOtherUsers()) { @@ -176,6 +208,7 @@ public static void Checkout(this List elements) { elementsToCheckout.Add(element.Id); } + WorksharingUtils.CheckoutElements(document, elementsToCheckout); } @@ -195,33 +228,7 @@ private static void ElementOwnedByNoneNote(Element element) { BH.Engine.Base.Compute.RecordNote($"Revit object with ElementId: {element.Id} is not owned by any user."); } + /***************************************************/ - - - public static void ReloadLatestWithMessage(Document doc) - { - // Tell user what we're doing - TaskDialog td = new TaskDialog("Alert") - { - MainInstruction = "The requested operation needs to reload changes from central in order to proceed.", - MainContent = "This will update your local with all changes currently in the central model. This operation " + - "may take some time depending on the number of changes available on the central.", - CommonButtons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel - }; - - TaskDialogResult result = td.Show(); - - if (result == TaskDialogResult.Ok) - { - // There are no currently customizable user options for ReloadLatest. - doc.ReloadLatest(new ReloadLatestOptions()); - TaskDialog.Show("Proceeding...", "Reload operation completed, proceeding with requested operation."); - } - else - { - TaskDialog.Show("Canceled.", "Reload operation canceled, so changes will not be made. Return to this command later when ready to reload."); - } - } - } } From 1b2e39e79e457c281c68bcb121d146705fce71c7 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Sun, 17 Jul 2022 21:49:07 -0400 Subject: [PATCH 09/37] removed methods that I probably won't need YAGNI --- Revit_Core_Engine/Query/CheckedoutStatus.cs | 36 --------------------- 1 file changed, 36 deletions(-) diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs index 9c89ccfbe..20cf7e69f 100644 --- a/Revit_Core_Engine/Query/CheckedoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckedoutStatus.cs @@ -37,42 +37,6 @@ public static partial class Query /***************************************************/ /**** Public methods ****/ /***************************************************/ - - [Description("")] - [Input("", "")] - [Output("", "")] - public static bool IsFileLocalModel(this Document doc) - { - return BasicFileInfo.Extract(doc.PathName).IsLocal; - } - - [Description("")] - [Input("", "")] - [Output("", "")] - public static bool IsFileCentralModel(this Document doc) - { - return BasicFileInfo.Extract(doc.PathName).IsCentral; - } - - [Description("")] - [Input("", "")] - [Output("", "")] - public static bool IsFileWorkshared(this Document doc) - { - return BasicFileInfo.Extract(doc.PathName).IsWorkshared; - } - - [Description("")] - [Input("", "")] - [Output("", "")] - public static bool IsAllLocalChangesSavedToCentralModel(this Document doc) - { - return BasicFileInfo.Extract(doc.PathName).AllLocalChangesSavedToCentral; - } - - - - [Description("")] [Input("elements", "Revit elements.")] [Output("", "")] From e06b28e94d8ca99cf1b25f8322ea92ab422b5f03 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Sun, 17 Jul 2022 21:59:50 -0400 Subject: [PATCH 10/37] Update CheckedoutStatus.cs --- Revit_Core_Engine/Query/CheckedoutStatus.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs index 20cf7e69f..eb7b7c407 100644 --- a/Revit_Core_Engine/Query/CheckedoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckedoutStatus.cs @@ -143,7 +143,7 @@ public static void Checkout(this Element element) else if (element.IsOwnedByCurrentUser()) { - ElementOwnedByCurrentUserNote(element); + ElementOwnedByCurrentUserWarning(element); } ElementOwnedByOtherUserWarning(element); @@ -165,7 +165,7 @@ public static void Checkout(this List elements) foreach (var element in elements.GetElementsOwnedByCurrentUser()) { - ElementOwnedByCurrentUserNote(element); + ElementOwnedByCurrentUserWarning(element); } foreach (var element in elements.GetElementsOwnedByNone()) @@ -183,14 +183,14 @@ private static void ElementOwnedByOtherUserWarning(Element element) BH.Engine.Base.Compute.RecordWarning($"Revit object could not be updated or modified due to it's CheckoutStatus. Revit ElementId: {element.Id} is owned by another user."); } - private static void ElementOwnedByCurrentUserNote(Element element) + private static void ElementOwnedByCurrentUserWarning(Element element) { - BH.Engine.Base.Compute.RecordNote($"Revit object with ElementId: {element.Id} is owned by the current user."); + BH.Engine.Base.Compute.RecordWarning($"Revit object with ElementId: {element.Id} is owned by the current user."); } - private static void ElementOwnedByNoneNote(Element element) + private static void ElementOwnedByNoneWarning(Element element) { - BH.Engine.Base.Compute.RecordNote($"Revit object with ElementId: {element.Id} is not owned by any user."); + BH.Engine.Base.Compute.RecordWarning($"Revit object with ElementId: {element.Id} is not owned by any user."); } /***************************************************/ From 86f6110620a1a31eb3dd7b15189c2ee948f737ed Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Sun, 17 Jul 2022 22:11:51 -0400 Subject: [PATCH 11/37] Update CheckedoutStatus.cs --- Revit_Core_Engine/Query/CheckedoutStatus.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs index eb7b7c407..c05dc3131 100644 --- a/Revit_Core_Engine/Query/CheckedoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckedoutStatus.cs @@ -117,7 +117,6 @@ public static bool IsOwnedByNone(this Element element) return false; } - [Description("")] [Input("element", "Revit element.")] [Output("", "")] From 17d05c3c8b26877f41190d780ae426ceb9968903 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Mon, 18 Jul 2022 08:02:32 -0400 Subject: [PATCH 12/37] Refactoring --- Revit_Core_Engine/Compute/Checkout.cs | 94 +++++++++ Revit_Core_Engine/Compute/Warnings.cs | 20 ++ Revit_Core_Engine/Query/CheckedoutStatus.cs | 197 ------------------ .../ElementsEditablePerCheckoutStatus.cs | 57 +++++ .../Query/ElementsOwnedByCurrentUser.cs | 50 +++++ .../Query/ElementsOwnedByNone.cs | 49 +++++ .../Query/ElementsOwnedByOtherUsers.cs | 49 +++++ .../Query/IsOwnedByCurrentUser.cs | 55 +++++ Revit_Core_Engine/Query/IsOwnedByNone.cs | 55 +++++ Revit_Core_Engine/Query/IsOwnedByOtherUser.cs | 55 +++++ Revit_Core_Engine/Query/OwnershipStatus.cs | 50 +++++ Revit_Core_Engine/Revit_Core_Engine.csproj | 10 +- 12 files changed, 543 insertions(+), 198 deletions(-) create mode 100644 Revit_Core_Engine/Compute/Checkout.cs delete mode 100644 Revit_Core_Engine/Query/CheckedoutStatus.cs create mode 100644 Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs create mode 100644 Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs create mode 100644 Revit_Core_Engine/Query/ElementsOwnedByNone.cs create mode 100644 Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs create mode 100644 Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs create mode 100644 Revit_Core_Engine/Query/IsOwnedByNone.cs create mode 100644 Revit_Core_Engine/Query/IsOwnedByOtherUser.cs create mode 100644 Revit_Core_Engine/Query/OwnershipStatus.cs diff --git a/Revit_Core_Engine/Compute/Checkout.cs b/Revit_Core_Engine/Compute/Checkout.cs new file mode 100644 index 000000000..ab82922a5 --- /dev/null +++ b/Revit_Core_Engine/Compute/Checkout.cs @@ -0,0 +1,94 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using BH.oM.Base.Attributes; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BH.Revit.Engine.Core +{ + public static partial class Compute + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static void Checkout(this Element element) + { + if (element.IsOwnedByNone()) + { + List elementsToCheckout = new List + { + element.Id + }; + + WorksharingUtils.CheckoutElements(element.Document, elementsToCheckout); + } + + else if (element.IsOwnedByCurrentUser()) + { + ElementOwnedByCurrentUserWarning(element); + } + + ElementOwnedByOtherUserWarning(element); + + } + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static void Checkout(this List elements) + { + Document document = elements.First().Document; + List elementsToCheckout = new List(); + + foreach (var element in elements.ElementsOwnedByOtherUsers()) + { + ElementOwnedByOtherUserWarning(element); + } + + foreach (var element in elements.ElementsOwnedByCurrentUser()) + { + ElementOwnedByCurrentUserWarning(element); + } + + foreach (var element in elements.ElementsOwnedByNone()) + { + elementsToCheckout.Add(element.Id); + } + + + WorksharingUtils.CheckoutElements(document, elementsToCheckout); + } + + /***************************************************/ + } +} + + + diff --git a/Revit_Core_Engine/Compute/Warnings.cs b/Revit_Core_Engine/Compute/Warnings.cs index 65c7ba210..360acceb5 100644 --- a/Revit_Core_Engine/Compute/Warnings.cs +++ b/Revit_Core_Engine/Compute/Warnings.cs @@ -514,6 +514,26 @@ internal static void TransformNotImplementedWarning(this Element element) } /***************************************************/ + + internal static void ElementOwnedByOtherUserWarning(Element element) + { + BH.Engine.Base.Compute.RecordWarning($"Revit object could not be updated or modified due to it's CheckoutStatus. Revit ElementId: {element.Id} is owned by another user."); + } + + /***************************************************/ + + internal static void ElementOwnedByCurrentUserWarning(Element element) + { + BH.Engine.Base.Compute.RecordWarning($"Revit object with ElementId: {element.Id} is owned by the current user."); + } + + /***************************************************/ + + internal static void ElementOwnedByNoneWarning(Element element) + { + BH.Engine.Base.Compute.RecordWarning($"Revit object with ElementId: {element.Id} is not owned by any user."); + } + /***************************************************/ } } diff --git a/Revit_Core_Engine/Query/CheckedoutStatus.cs b/Revit_Core_Engine/Query/CheckedoutStatus.cs deleted file mode 100644 index c05dc3131..000000000 --- a/Revit_Core_Engine/Query/CheckedoutStatus.cs +++ /dev/null @@ -1,197 +0,0 @@ -/* - * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. - * - * Each contributor holds copyright over their respective contributions. - * The project versioning (Git) records all such contribution source information. - * - * - * The BHoM is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3.0 of the License, or - * (at your option) any later version. - * - * The BHoM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this code. If not, see . - */ - -using Autodesk.Revit.DB; -using Autodesk.Revit.DB.Analysis; -using Autodesk.Revit.UI; -using BH.Engine.Adapters.Revit; -using BH.oM.Base; -using BH.oM.Base.Attributes; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; - -namespace BH.Revit.Engine.Core -{ - public static partial class Query - { - /***************************************************/ - /**** Public methods ****/ - /***************************************************/ - [Description("")] - [Input("elements", "Revit elements.")] - [Output("", "")] - public static List GetElementsOwnedByOtherUsers(this List elements) - { - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByOtherUser).ToList(); - } - - [Description("")] - [Input("elements", "Revit elements.")] - [Output("", ".")] - public static List GetElementsOwnedByCurrentUser(this List elements) - { - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByCurrentUser).ToList(); - } - - [Description("")] - [Input("elements", "Revit elements.")] - [Output("", "")] - public static List GetElementsOwnedByNone(this List elements) - { - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.NotOwned).ToList(); - } - - [Description("")] - [Input("elements", "Revit elements.")] - [Output("", "")] - public static List GetElementsEditablePerCheckoutStatus(this List elements, bool returnWarnings) - { - if (returnWarnings) - { - foreach (var element in elements.GetElementsOwnedByOtherUsers()) - { - ElementOwnedByOtherUserWarning(element); - } - } - - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) != CheckoutStatus.OwnedByOtherUser).ToList(); - } - - - [Description("")] - [Input("element", "Revit element.")] - [Output("", "")] - public static bool IsOwnedByOtherUser(this Element element) - { - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByOtherUser) - { - return true; - } - - return false; - } - - [Description("")] - [Input("element", "Revit element.")] - [Output("", "")] - public static bool IsOwnedByCurrentUser(this Element element) - { - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByCurrentUser) - { - return true; - } - - return false; - } - - [Description("")] - [Input("element", "Revit element.")] - [Output("", "")] - public static bool IsOwnedByNone(this Element element) - { - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.NotOwned) - { - return true; - } - - return false; - } - - [Description("")] - [Input("element", "Revit element.")] - [Output("", "")] - public static CheckoutStatus OwnershipStatus(this Element element) - { - return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id); - } - - [Description("")] - [Input("element", "Revit element.")] - [Output("", "")] - public static void Checkout(this Element element) - { - if (element.IsOwnedByNone()) - { - List elementsToCheckout = new List - { - element.Id - }; - - WorksharingUtils.CheckoutElements(element.Document, elementsToCheckout); - } - - else if (element.IsOwnedByCurrentUser()) - { - ElementOwnedByCurrentUserWarning(element); - } - - ElementOwnedByOtherUserWarning(element); - - } - - [Description("")] - [Input("element", "Revit element.")] - [Output("", "")] - public static void Checkout(this List elements) - { - Document document = elements.First().Document; - List elementsToCheckout = new List(); - - foreach (var element in elements.GetElementsOwnedByOtherUsers()) - { - ElementOwnedByOtherUserWarning(element); - } - - foreach (var element in elements.GetElementsOwnedByCurrentUser()) - { - ElementOwnedByCurrentUserWarning(element); - } - - foreach (var element in elements.GetElementsOwnedByNone()) - { - elementsToCheckout.Add(element.Id); - } - - - WorksharingUtils.CheckoutElements(document, elementsToCheckout); - } - - - private static void ElementOwnedByOtherUserWarning(Element element) - { - BH.Engine.Base.Compute.RecordWarning($"Revit object could not be updated or modified due to it's CheckoutStatus. Revit ElementId: {element.Id} is owned by another user."); - } - - private static void ElementOwnedByCurrentUserWarning(Element element) - { - BH.Engine.Base.Compute.RecordWarning($"Revit object with ElementId: {element.Id} is owned by the current user."); - } - - private static void ElementOwnedByNoneWarning(Element element) - { - BH.Engine.Base.Compute.RecordWarning($"Revit object with ElementId: {element.Id} is not owned by any user."); - } - - /***************************************************/ - } -} diff --git a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs new file mode 100644 index 000000000..eb667c52e --- /dev/null +++ b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs @@ -0,0 +1,57 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Analysis; +using Autodesk.Revit.UI; +using BH.Engine.Adapters.Revit; +using BH.oM.Base; +using BH.oM.Base.Attributes; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BH.Revit.Engine.Core +{ + public static partial class Query + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + [Description("")] + [Input("elements", "Revit elements.")] + [Output("", "")] + public static List ElementsEditablePerCheckoutStatus(this List elements, bool returnWarnings) + { + if (returnWarnings) + { + foreach (var element in elements.ElementsOwnedByOtherUsers()) + { + Compute.ElementOwnedByOtherUserWarning(element); + } + } + + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) != CheckoutStatus.OwnedByOtherUser).ToList(); + } + /***************************************************/ + } +} diff --git a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs new file mode 100644 index 000000000..3fe492ef8 --- /dev/null +++ b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs @@ -0,0 +1,50 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Analysis; +using Autodesk.Revit.UI; +using BH.Engine.Adapters.Revit; +using BH.oM.Base; +using BH.oM.Base.Attributes; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BH.Revit.Engine.Core +{ + public static partial class Query + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + + [Description("")] + [Input("elements", "Revit elements.")] + [Output("", ".")] + public static List ElementsOwnedByCurrentUser(this List elements) + { + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByCurrentUser).ToList(); + } + /***************************************************/ + } +} diff --git a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs new file mode 100644 index 000000000..18b273fd0 --- /dev/null +++ b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs @@ -0,0 +1,49 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Analysis; +using Autodesk.Revit.UI; +using BH.Engine.Adapters.Revit; +using BH.oM.Base; +using BH.oM.Base.Attributes; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BH.Revit.Engine.Core +{ + public static partial class Query + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + [Description("")] + [Input("elements", "Revit elements.")] + [Output("", "")] + public static List ElementsOwnedByNone(this List elements) + { + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.NotOwned).ToList(); + } + /***************************************************/ + } +} diff --git a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs new file mode 100644 index 000000000..d99d01693 --- /dev/null +++ b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs @@ -0,0 +1,49 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Analysis; +using Autodesk.Revit.UI; +using BH.Engine.Adapters.Revit; +using BH.oM.Base; +using BH.oM.Base.Attributes; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BH.Revit.Engine.Core +{ + public static partial class Query + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + [Description("")] + [Input("elements", "Revit elements.")] + [Output("", "")] + public static List ElementsOwnedByOtherUsers(this List elements) + { + return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByOtherUser).ToList(); + } + /***************************************************/ + } +} diff --git a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs new file mode 100644 index 000000000..15e725d46 --- /dev/null +++ b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs @@ -0,0 +1,55 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Analysis; +using Autodesk.Revit.UI; +using BH.Engine.Adapters.Revit; +using BH.oM.Base; +using BH.oM.Base.Attributes; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BH.Revit.Engine.Core +{ + public static partial class Query + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static bool IsOwnedByCurrentUser(this Element element) + { + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByCurrentUser) + { + return true; + } + + return false; + } + /***************************************************/ + } +} diff --git a/Revit_Core_Engine/Query/IsOwnedByNone.cs b/Revit_Core_Engine/Query/IsOwnedByNone.cs new file mode 100644 index 000000000..ef4cc69e6 --- /dev/null +++ b/Revit_Core_Engine/Query/IsOwnedByNone.cs @@ -0,0 +1,55 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Analysis; +using Autodesk.Revit.UI; +using BH.Engine.Adapters.Revit; +using BH.oM.Base; +using BH.oM.Base.Attributes; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BH.Revit.Engine.Core +{ + public static partial class Query + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static bool IsOwnedByNone(this Element element) + { + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.NotOwned) + { + return true; + } + + return false; + } + /***************************************************/ + } +} diff --git a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs new file mode 100644 index 000000000..49bc910aa --- /dev/null +++ b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs @@ -0,0 +1,55 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Analysis; +using Autodesk.Revit.UI; +using BH.Engine.Adapters.Revit; +using BH.oM.Base; +using BH.oM.Base.Attributes; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BH.Revit.Engine.Core +{ + public static partial class Query + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static bool IsOwnedByOtherUser(this Element element) + { + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByOtherUser) + { + return true; + } + + return false; + } + /***************************************************/ + } +} diff --git a/Revit_Core_Engine/Query/OwnershipStatus.cs b/Revit_Core_Engine/Query/OwnershipStatus.cs new file mode 100644 index 000000000..2780a1876 --- /dev/null +++ b/Revit_Core_Engine/Query/OwnershipStatus.cs @@ -0,0 +1,50 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2022, the respective contributors. All rights reserved. + * + * Each contributor holds copyright over their respective contributions. + * The project versioning (Git) records all such contribution source information. + * + * + * The BHoM is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3.0 of the License, or + * (at your option) any later version. + * + * The BHoM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this code. If not, see . + */ + +using Autodesk.Revit.DB; +using Autodesk.Revit.DB.Analysis; +using Autodesk.Revit.UI; +using BH.Engine.Adapters.Revit; +using BH.oM.Base; +using BH.oM.Base.Attributes; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; + +namespace BH.Revit.Engine.Core +{ + public static partial class Query + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + + [Description("")] + [Input("element", "Revit element.")] + [Output("", "")] + public static CheckoutStatus OwnershipStatus(this Element element) + { + return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id); + } + /***************************************************/ + } +} diff --git a/Revit_Core_Engine/Revit_Core_Engine.csproj b/Revit_Core_Engine/Revit_Core_Engine.csproj index 1ec9694bb..6ae8bf245 100644 --- a/Revit_Core_Engine/Revit_Core_Engine.csproj +++ b/Revit_Core_Engine/Revit_Core_Engine.csproj @@ -333,6 +333,7 @@ + @@ -401,7 +402,14 @@ - + + + + + + + + From 731c343c52e8dd53791ca764f715485679e56a29 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Mon, 18 Jul 2022 08:46:13 -0400 Subject: [PATCH 13/37] refactor --- .../{Compute => Modify}/Checkout.cs | 18 ++++++++---------- .../Query/ElementsEditablePerCheckoutStatus.cs | 5 +++-- .../Query/ElementsOwnedByCurrentUser.cs | 4 ++-- Revit_Core_Engine/Query/ElementsOwnedByNone.cs | 4 ++-- .../Query/ElementsOwnedByOtherUsers.cs | 4 ++-- .../Query/IsOwnedByCurrentUser.cs | 4 ++-- Revit_Core_Engine/Query/IsOwnedByNone.cs | 4 ++-- Revit_Core_Engine/Query/IsOwnedByOtherUser.cs | 4 ++-- Revit_Core_Engine/Query/OwnershipStatus.cs | 4 ++-- Revit_Core_Engine/Revit_Core_Engine.csproj | 2 +- 10 files changed, 26 insertions(+), 27 deletions(-) rename Revit_Core_Engine/{Compute => Modify}/Checkout.cs (83%) diff --git a/Revit_Core_Engine/Compute/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs similarity index 83% rename from Revit_Core_Engine/Compute/Checkout.cs rename to Revit_Core_Engine/Modify/Checkout.cs index ab82922a5..114d72137 100644 --- a/Revit_Core_Engine/Compute/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -28,16 +28,15 @@ namespace BH.Revit.Engine.Core { - public static partial class Compute + public static partial class Modify { /***************************************************/ /**** Public methods ****/ /***************************************************/ - [Description("")] + [Description("Modifies element CheckoutStatus if element is not currently owned by the current user or others.")] [Input("element", "Revit element.")] - [Output("", "")] public static void Checkout(this Element element) { if (element.IsOwnedByNone()) @@ -52,16 +51,15 @@ public static void Checkout(this Element element) else if (element.IsOwnedByCurrentUser()) { - ElementOwnedByCurrentUserWarning(element); + Compute.ElementOwnedByCurrentUserWarning(element); } - ElementOwnedByOtherUserWarning(element); + Compute.ElementOwnedByOtherUserWarning(element); } - [Description("")] - [Input("element", "Revit element.")] - [Output("", "")] + [Description("Modifies CheckoutStatus for each element selectd if element is not currently owned by the current user or others.")] + [Input("elements", "Revit elements.")] public static void Checkout(this List elements) { Document document = elements.First().Document; @@ -69,12 +67,12 @@ public static void Checkout(this List elements) foreach (var element in elements.ElementsOwnedByOtherUsers()) { - ElementOwnedByOtherUserWarning(element); + Compute.ElementOwnedByOtherUserWarning(element); } foreach (var element in elements.ElementsOwnedByCurrentUser()) { - ElementOwnedByCurrentUserWarning(element); + Compute.ElementOwnedByCurrentUserWarning(element); } foreach (var element in elements.ElementsOwnedByNone()) diff --git a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs index eb667c52e..5c5211a8c 100644 --- a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs +++ b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs @@ -37,9 +37,10 @@ public static partial class Query /***************************************************/ /**** Public methods ****/ /***************************************************/ - [Description("")] + [Description("Returns a sublist of elements, from the given list of elements, that are editable per the element's CheckoutStatus." + + "Return warnings option, if true, alerts the user of which elements are uneditable due to ownership by other users.")] [Input("elements", "Revit elements.")] - [Output("", "")] + [Output("elementsEditablePerCheckoutStatus", "List of elements that are editable per the element's CheckoutStatus.")] public static List ElementsEditablePerCheckoutStatus(this List elements, bool returnWarnings) { if (returnWarnings) diff --git a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs index 3fe492ef8..ca45260f9 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs @@ -38,9 +38,9 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("")] + [Description("Returns a sublist of elements, from the given list of elements, that are owned by the current user.")] [Input("elements", "Revit elements.")] - [Output("", ".")] + [Output("elementsOwnedByCurrentUser", "List of elements that are owned by the current user.")] public static List ElementsOwnedByCurrentUser(this List elements) { return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByCurrentUser).ToList(); diff --git a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs index 18b273fd0..eb3e07540 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs @@ -37,9 +37,9 @@ public static partial class Query /***************************************************/ /**** Public methods ****/ /***************************************************/ - [Description("")] + [Description("Returns a sublist of elements, from the given list of elements, that are unowned.")] [Input("elements", "Revit elements.")] - [Output("", "")] + [Output("elementsOwnedByNone", "List of elements that are unowned.")] public static List ElementsOwnedByNone(this List elements) { return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.NotOwned).ToList(); diff --git a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs index d99d01693..cd99d7475 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs @@ -37,9 +37,9 @@ public static partial class Query /***************************************************/ /**** Public methods ****/ /***************************************************/ - [Description("")] + [Description("Returns a sublist of elements, from the given list of elements, that are owned by other users.")] [Input("elements", "Revit elements.")] - [Output("", "")] + [Output("elementsOwnedByUsers", "List of elements that are owned by other users.")] public static List ElementsOwnedByOtherUsers(this List elements) { return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByOtherUser).ToList(); diff --git a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs index 15e725d46..0a42b42f5 100644 --- a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs @@ -38,9 +38,9 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("")] + [Description("Check if element is owned by the current user.")] [Input("element", "Revit element.")] - [Output("", "")] + [Output("ownedByCurrentUser", "True if the input Revit element is owned by current user, otherwise false.")] public static bool IsOwnedByCurrentUser(this Element element) { if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByCurrentUser) diff --git a/Revit_Core_Engine/Query/IsOwnedByNone.cs b/Revit_Core_Engine/Query/IsOwnedByNone.cs index ef4cc69e6..f635a83a4 100644 --- a/Revit_Core_Engine/Query/IsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/IsOwnedByNone.cs @@ -38,9 +38,9 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("")] + [Description("Check if element is currently unowned.")] [Input("element", "Revit element.")] - [Output("", "")] + [Output("ownedByNone", "True if the input Revit element is not owned, otherwise false.")] public static bool IsOwnedByNone(this Element element) { if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.NotOwned) diff --git a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs index 49bc910aa..8645a449c 100644 --- a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs @@ -38,9 +38,9 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("")] + [Description("Check if element is owned by another user.")] [Input("element", "Revit element.")] - [Output("", "")] + [Output("ownedByOtherUser", "True if the input Revit element is owned by another user, otherwise false.")] public static bool IsOwnedByOtherUser(this Element element) { if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByOtherUser) diff --git a/Revit_Core_Engine/Query/OwnershipStatus.cs b/Revit_Core_Engine/Query/OwnershipStatus.cs index 2780a1876..1d5a97f95 100644 --- a/Revit_Core_Engine/Query/OwnershipStatus.cs +++ b/Revit_Core_Engine/Query/OwnershipStatus.cs @@ -38,9 +38,9 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("")] + [Description("Returns element CheckoutStatus.")] [Input("element", "Revit element.")] - [Output("", "")] + [Output("checkoutStatus", "The worksharing ownership/CheckoutStatus of the element.")] public static CheckoutStatus OwnershipStatus(this Element element) { return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id); diff --git a/Revit_Core_Engine/Revit_Core_Engine.csproj b/Revit_Core_Engine/Revit_Core_Engine.csproj index 6ae8bf245..e824adb5e 100644 --- a/Revit_Core_Engine/Revit_Core_Engine.csproj +++ b/Revit_Core_Engine/Revit_Core_Engine.csproj @@ -333,7 +333,7 @@ - + From 7774c229f62f2fdfb60438aae378cd72c400d4db Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Mon, 18 Jul 2022 09:19:47 -0400 Subject: [PATCH 14/37] spelling and code compliance --- Revit_Core_Engine/Modify/Checkout.cs | 2 +- Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index 114d72137..bbf21466e 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -58,7 +58,7 @@ public static void Checkout(this Element element) } - [Description("Modifies CheckoutStatus for each element selectd if element is not currently owned by the current user or others.")] + [Description("Modifies CheckoutStatus for each element selected if element is not currently owned by the current user or others.")] [Input("elements", "Revit elements.")] public static void Checkout(this List elements) { diff --git a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs index 5c5211a8c..983c76534 100644 --- a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs +++ b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs @@ -40,6 +40,8 @@ public static partial class Query [Description("Returns a sublist of elements, from the given list of elements, that are editable per the element's CheckoutStatus." + "Return warnings option, if true, alerts the user of which elements are uneditable due to ownership by other users.")] [Input("elements", "Revit elements.")] + [Input("returnWarnings", "If it is desired, a value of 'True' will raise warnings on which elements" + +"in the list are uneditable due to ownership by other users.")] [Output("elementsEditablePerCheckoutStatus", "List of elements that are editable per the element's CheckoutStatus.")] public static List ElementsEditablePerCheckoutStatus(this List elements, bool returnWarnings) { From ca8079b216f60dbc2713e74ad55b01eb3234f36f Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Mon, 15 Aug 2022 10:38:51 -0400 Subject: [PATCH 15/37] pr comments checks --- Revit_Core_Engine/Compute/Warnings.cs | 7 ------- Revit_Core_Engine/Modify/Checkout.cs | 9 +++++++-- .../Query/{OwnershipStatus.cs => CheckoutStatus.cs} | 2 +- .../Query/ElementsEditablePerCheckoutStatus.cs | 8 ++++---- Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs | 2 +- Revit_Core_Engine/Query/ElementsOwnedByNone.cs | 2 +- Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs | 2 +- Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs | 4 ++-- Revit_Core_Engine/Query/IsOwnedByNone.cs | 4 ++-- Revit_Core_Engine/Query/IsOwnedByOtherUser.cs | 4 ++-- Revit_Core_Engine/Revit_Core_Engine.csproj | 2 +- 11 files changed, 22 insertions(+), 24 deletions(-) rename Revit_Core_Engine/Query/{OwnershipStatus.cs => CheckoutStatus.cs} (96%) diff --git a/Revit_Core_Engine/Compute/Warnings.cs b/Revit_Core_Engine/Compute/Warnings.cs index 360acceb5..1857c6d2e 100644 --- a/Revit_Core_Engine/Compute/Warnings.cs +++ b/Revit_Core_Engine/Compute/Warnings.cs @@ -526,13 +526,6 @@ internal static void ElementOwnedByCurrentUserWarning(Element element) { BH.Engine.Base.Compute.RecordWarning($"Revit object with ElementId: {element.Id} is owned by the current user."); } - - /***************************************************/ - - internal static void ElementOwnedByNoneWarning(Element element) - { - BH.Engine.Base.Compute.RecordWarning($"Revit object with ElementId: {element.Id} is not owned by any user."); - } /***************************************************/ } } diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index bbf21466e..7b4095722 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -65,7 +65,12 @@ public static void Checkout(this List elements) Document document = elements.First().Document; List elementsToCheckout = new List(); - foreach (var element in elements.ElementsOwnedByOtherUsers()) + foreach (Element element in elements) + { + + } + + /*foreach (var element in elements.ElementsOwnedByOtherUsers()) { Compute.ElementOwnedByOtherUserWarning(element); } @@ -78,7 +83,7 @@ public static void Checkout(this List elements) foreach (var element in elements.ElementsOwnedByNone()) { elementsToCheckout.Add(element.Id); - } + }*/ WorksharingUtils.CheckoutElements(document, elementsToCheckout); diff --git a/Revit_Core_Engine/Query/OwnershipStatus.cs b/Revit_Core_Engine/Query/CheckoutStatus.cs similarity index 96% rename from Revit_Core_Engine/Query/OwnershipStatus.cs rename to Revit_Core_Engine/Query/CheckoutStatus.cs index 1d5a97f95..2e851f948 100644 --- a/Revit_Core_Engine/Query/OwnershipStatus.cs +++ b/Revit_Core_Engine/Query/CheckoutStatus.cs @@ -41,7 +41,7 @@ public static partial class Query [Description("Returns element CheckoutStatus.")] [Input("element", "Revit element.")] [Output("checkoutStatus", "The worksharing ownership/CheckoutStatus of the element.")] - public static CheckoutStatus OwnershipStatus(this Element element) + public static CheckoutStatus CheckoutStatus(this Element element) { return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id); } diff --git a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs index 983c76534..e316aba70 100644 --- a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs +++ b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs @@ -40,12 +40,12 @@ public static partial class Query [Description("Returns a sublist of elements, from the given list of elements, that are editable per the element's CheckoutStatus." + "Return warnings option, if true, alerts the user of which elements are uneditable due to ownership by other users.")] [Input("elements", "Revit elements.")] - [Input("returnWarnings", "If it is desired, a value of 'True' will raise warnings on which elements" + [Input("recordWarnings", "If it is desired, a value of 'True' will raise warnings on which elements" +"in the list are uneditable due to ownership by other users.")] [Output("elementsEditablePerCheckoutStatus", "List of elements that are editable per the element's CheckoutStatus.")] - public static List ElementsEditablePerCheckoutStatus(this List elements, bool returnWarnings) + public static List ElementsEditablePerCheckoutStatus(this List elements, bool recordWarnings) { - if (returnWarnings) + if (recordWarnings) { foreach (var element in elements.ElementsOwnedByOtherUsers()) { @@ -53,7 +53,7 @@ public static List ElementsEditablePerCheckoutStatus(this List } } - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) != CheckoutStatus.OwnedByOtherUser).ToList(); + return elements.Where(e => !e.IsOwnedByOtherUser()).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs index ca45260f9..b71f3d163 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs @@ -43,7 +43,7 @@ public static partial class Query [Output("elementsOwnedByCurrentUser", "List of elements that are owned by the current user.")] public static List ElementsOwnedByCurrentUser(this List elements) { - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByCurrentUser).ToList(); + return elements.Where(e => e.IsOwnedByCurrentUser()).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs index eb3e07540..cb53488b4 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs @@ -42,7 +42,7 @@ public static partial class Query [Output("elementsOwnedByNone", "List of elements that are unowned.")] public static List ElementsOwnedByNone(this List elements) { - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.NotOwned).ToList(); + return elements.Where(e => e.IsOwnedByNone()).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs index cd99d7475..a0d7df37a 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs @@ -42,7 +42,7 @@ public static partial class Query [Output("elementsOwnedByUsers", "List of elements that are owned by other users.")] public static List ElementsOwnedByOtherUsers(this List elements) { - return elements.Where(e => WorksharingUtils.GetCheckoutStatus(e.Document, e.Id) == CheckoutStatus.OwnedByOtherUser).ToList(); + return elements.Where(e => e.IsOwnedByOtherUser()).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs index 0a42b42f5..0693472ec 100644 --- a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs @@ -43,12 +43,12 @@ public static partial class Query [Output("ownedByCurrentUser", "True if the input Revit element is owned by current user, otherwise false.")] public static bool IsOwnedByCurrentUser(this Element element) { - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByCurrentUser) + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == Autodesk.Revit.DB.CheckoutStatus.OwnedByCurrentUser) { return true; } - return false; + return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByCurrentUser; } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/IsOwnedByNone.cs b/Revit_Core_Engine/Query/IsOwnedByNone.cs index f635a83a4..e44784690 100644 --- a/Revit_Core_Engine/Query/IsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/IsOwnedByNone.cs @@ -43,12 +43,12 @@ public static partial class Query [Output("ownedByNone", "True if the input Revit element is not owned, otherwise false.")] public static bool IsOwnedByNone(this Element element) { - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.NotOwned) + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == Autodesk.Revit.DB.CheckoutStatus.NotOwned) { return true; } - return false; + return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.NotOwned; } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs index 8645a449c..964594636 100644 --- a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs @@ -43,12 +43,12 @@ public static partial class Query [Output("ownedByOtherUser", "True if the input Revit element is owned by another user, otherwise false.")] public static bool IsOwnedByOtherUser(this Element element) { - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == CheckoutStatus.OwnedByOtherUser) + if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser) { return true; } - return false; + return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser; } /***************************************************/ } diff --git a/Revit_Core_Engine/Revit_Core_Engine.csproj b/Revit_Core_Engine/Revit_Core_Engine.csproj index e824adb5e..0c7e5ce71 100644 --- a/Revit_Core_Engine/Revit_Core_Engine.csproj +++ b/Revit_Core_Engine/Revit_Core_Engine.csproj @@ -408,7 +408,7 @@ - + From 955d0b8148a200a30a7f7af06acdd5e76e253950 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Mon, 15 Aug 2022 13:58:00 -0400 Subject: [PATCH 16/37] OwnedBy Queries updated to simplify logic --- Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs | 5 ----- Revit_Core_Engine/Query/IsOwnedByNone.cs | 5 ----- Revit_Core_Engine/Query/IsOwnedByOtherUser.cs | 5 ----- 3 files changed, 15 deletions(-) diff --git a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs index 0693472ec..94b8db057 100644 --- a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs @@ -43,11 +43,6 @@ public static partial class Query [Output("ownedByCurrentUser", "True if the input Revit element is owned by current user, otherwise false.")] public static bool IsOwnedByCurrentUser(this Element element) { - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == Autodesk.Revit.DB.CheckoutStatus.OwnedByCurrentUser) - { - return true; - } - return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByCurrentUser; } /***************************************************/ diff --git a/Revit_Core_Engine/Query/IsOwnedByNone.cs b/Revit_Core_Engine/Query/IsOwnedByNone.cs index e44784690..679d6bf4c 100644 --- a/Revit_Core_Engine/Query/IsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/IsOwnedByNone.cs @@ -43,11 +43,6 @@ public static partial class Query [Output("ownedByNone", "True if the input Revit element is not owned, otherwise false.")] public static bool IsOwnedByNone(this Element element) { - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == Autodesk.Revit.DB.CheckoutStatus.NotOwned) - { - return true; - } - return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.NotOwned; } /***************************************************/ diff --git a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs index 964594636..e4b945f62 100644 --- a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs @@ -43,11 +43,6 @@ public static partial class Query [Output("ownedByOtherUser", "True if the input Revit element is owned by another user, otherwise false.")] public static bool IsOwnedByOtherUser(this Element element) { - if (WorksharingUtils.GetCheckoutStatus(element.Document, element.Id) == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser) - { - return true; - } - return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser; } /***************************************************/ From 2261422d750780f166f9d4ff7f0193f0b9863355 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Mon, 15 Aug 2022 14:19:51 -0400 Subject: [PATCH 17/37] pr changes --- Revit_Core_Engine/Compute/Notes.cs | 4 +++ Revit_Core_Engine/Compute/Warnings.cs | 6 ---- Revit_Core_Engine/Modify/Checkout.cs | 49 ++++++++------------------- 3 files changed, 18 insertions(+), 41 deletions(-) diff --git a/Revit_Core_Engine/Compute/Notes.cs b/Revit_Core_Engine/Compute/Notes.cs index 0ad77d0e5..8acbeb685 100644 --- a/Revit_Core_Engine/Compute/Notes.cs +++ b/Revit_Core_Engine/Compute/Notes.cs @@ -43,6 +43,10 @@ internal static void MaterialNotInLibraryNote(this Material material) BH.Engine.Base.Compute.RecordNote(message); } + internal static void ElementOwnedByCurrentUserNote(Element element) + { + BH.Engine.Base.Compute.RecordNote($"Revit object with ElementId: {element.Id} is owned by the current user."); + } /***************************************************/ } } diff --git a/Revit_Core_Engine/Compute/Warnings.cs b/Revit_Core_Engine/Compute/Warnings.cs index 1857c6d2e..33d16fbf9 100644 --- a/Revit_Core_Engine/Compute/Warnings.cs +++ b/Revit_Core_Engine/Compute/Warnings.cs @@ -521,12 +521,6 @@ internal static void ElementOwnedByOtherUserWarning(Element element) } /***************************************************/ - - internal static void ElementOwnedByCurrentUserWarning(Element element) - { - BH.Engine.Base.Compute.RecordWarning($"Revit object with ElementId: {element.Id} is owned by the current user."); - } - /***************************************************/ } } diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index 7b4095722..3dc38f8c9 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -39,23 +39,7 @@ public static partial class Modify [Input("element", "Revit element.")] public static void Checkout(this Element element) { - if (element.IsOwnedByNone()) - { - List elementsToCheckout = new List - { - element.Id - }; - - WorksharingUtils.CheckoutElements(element.Document, elementsToCheckout); - } - - else if (element.IsOwnedByCurrentUser()) - { - Compute.ElementOwnedByCurrentUserWarning(element); - } - - Compute.ElementOwnedByOtherUserWarning(element); - + Checkout(new List() { element }); } [Description("Modifies CheckoutStatus for each element selected if element is not currently owned by the current user or others.")] @@ -67,25 +51,20 @@ public static void Checkout(this List elements) foreach (Element element in elements) { - - } - - /*foreach (var element in elements.ElementsOwnedByOtherUsers()) - { - Compute.ElementOwnedByOtherUserWarning(element); - } - - foreach (var element in elements.ElementsOwnedByCurrentUser()) - { - Compute.ElementOwnedByCurrentUserWarning(element); + switch (element.CheckoutStatus()) + { + case CheckoutStatus.NotOwned: + elementsToCheckout.Add(element.Id); + break; + case CheckoutStatus.OwnedByCurrentUser: + Compute.ElementOwnedByCurrentUserNote(element); + break; + case CheckoutStatus.OwnedByOtherUser: + Compute.ElementOwnedByOtherUserWarning(element); + break; + } } - - foreach (var element in elements.ElementsOwnedByNone()) - { - elementsToCheckout.Add(element.Id); - }*/ - - + WorksharingUtils.CheckoutElements(document, elementsToCheckout); } From 088d22afbb412046a991b220bcd67985ca81e130 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Mon, 15 Aug 2022 15:30:41 -0400 Subject: [PATCH 18/37] Update Checkout.cs --- Revit_Core_Engine/Modify/Checkout.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index 3dc38f8c9..2ac75c1c2 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -44,7 +44,8 @@ public static void Checkout(this Element element) [Description("Modifies CheckoutStatus for each element selected if element is not currently owned by the current user or others.")] [Input("elements", "Revit elements.")] - public static void Checkout(this List elements) + [Output("elementsCheckedOut", "List of elements checked out (ownership modified to be by current user) by this process.")] + public static List Checkout(this List elements) { Document document = elements.First().Document; List elementsToCheckout = new List(); @@ -66,6 +67,7 @@ public static void Checkout(this List elements) } WorksharingUtils.CheckoutElements(document, elementsToCheckout); + return elementsToCheckout; } /***************************************************/ From 6a4596e8428b2010dccedc4821d3715aca8b0c7b Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Tue, 16 Aug 2022 10:12:16 -0400 Subject: [PATCH 19/37] updates per pr comments --- Revit_Core_Engine/Modify/Checkout.cs | 2 +- Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index 2ac75c1c2..ea370ba1a 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -65,7 +65,7 @@ public static List Checkout(this List elements) break; } } - + WorksharingUtils.CheckoutElements(document, elementsToCheckout); return elementsToCheckout; } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs index a0d7df37a..d746f4d39 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs @@ -42,7 +42,7 @@ public static partial class Query [Output("elementsOwnedByUsers", "List of elements that are owned by other users.")] public static List ElementsOwnedByOtherUsers(this List elements) { - return elements.Where(e => e.IsOwnedByOtherUser()).ToList(); + return elements.Where(e => e.CheckoutStatus()== Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser).ToList(); } /***************************************************/ } From 4e8b64c1b18f9ed721620088fec916b8daa15ae8 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Tue, 16 Aug 2022 13:52:58 -0400 Subject: [PATCH 20/37] pr comments --- Revit_Core_Engine/Compute/Warnings.cs | 2 +- Revit_Core_Engine/Modify/Checkout.cs | 10 +--------- Revit_Core_Engine/Query/CheckoutStatus.cs | 2 +- .../Query/ElementsEditablePerCheckoutStatus.cs | 2 +- Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs | 2 +- Revit_Core_Engine/Query/ElementsOwnedByNone.cs | 2 +- Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs | 4 ++-- Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs | 2 +- Revit_Core_Engine/Query/IsOwnedByNone.cs | 2 +- Revit_Core_Engine/Query/IsOwnedByOtherUser.cs | 2 +- 10 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Revit_Core_Engine/Compute/Warnings.cs b/Revit_Core_Engine/Compute/Warnings.cs index 33d16fbf9..bb11ab987 100644 --- a/Revit_Core_Engine/Compute/Warnings.cs +++ b/Revit_Core_Engine/Compute/Warnings.cs @@ -517,7 +517,7 @@ internal static void TransformNotImplementedWarning(this Element element) internal static void ElementOwnedByOtherUserWarning(Element element) { - BH.Engine.Base.Compute.RecordWarning($"Revit object could not be updated or modified due to it's CheckoutStatus. Revit ElementId: {element.Id} is owned by another user."); + BH.Engine.Base.Compute.RecordWarning($"Revit object could not be updated or modified due to its CheckoutStatus. Revit ElementId: {element.Id} is owned by another user."); } /***************************************************/ diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index ea370ba1a..ddcd6ff0c 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -34,16 +34,8 @@ public static partial class Modify /**** Public methods ****/ /***************************************************/ - - [Description("Modifies element CheckoutStatus if element is not currently owned by the current user or others.")] - [Input("element", "Revit element.")] - public static void Checkout(this Element element) - { - Checkout(new List() { element }); - } - [Description("Modifies CheckoutStatus for each element selected if element is not currently owned by the current user or others.")] - [Input("elements", "Revit elements.")] + [Input("elements", "Revit elements to query for its checkout status.")] [Output("elementsCheckedOut", "List of elements checked out (ownership modified to be by current user) by this process.")] public static List Checkout(this List elements) { diff --git a/Revit_Core_Engine/Query/CheckoutStatus.cs b/Revit_Core_Engine/Query/CheckoutStatus.cs index 2e851f948..d287a857a 100644 --- a/Revit_Core_Engine/Query/CheckoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckoutStatus.cs @@ -39,7 +39,7 @@ public static partial class Query /***************************************************/ [Description("Returns element CheckoutStatus.")] - [Input("element", "Revit element.")] + [Input("element", "Revit element to query for its checkout status.")] [Output("checkoutStatus", "The worksharing ownership/CheckoutStatus of the element.")] public static CheckoutStatus CheckoutStatus(this Element element) { diff --git a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs index e316aba70..4029abe93 100644 --- a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs +++ b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs @@ -39,7 +39,7 @@ public static partial class Query /***************************************************/ [Description("Returns a sublist of elements, from the given list of elements, that are editable per the element's CheckoutStatus." + "Return warnings option, if true, alerts the user of which elements are uneditable due to ownership by other users.")] - [Input("elements", "Revit elements.")] + [Input("elements", "Revit elements to query for its checkout status.")] [Input("recordWarnings", "If it is desired, a value of 'True' will raise warnings on which elements" +"in the list are uneditable due to ownership by other users.")] [Output("elementsEditablePerCheckoutStatus", "List of elements that are editable per the element's CheckoutStatus.")] diff --git a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs index b71f3d163..3fc4411fd 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs @@ -39,7 +39,7 @@ public static partial class Query /***************************************************/ [Description("Returns a sublist of elements, from the given list of elements, that are owned by the current user.")] - [Input("elements", "Revit elements.")] + [Input("elements", "Revit elements to query for its checkout status.")] [Output("elementsOwnedByCurrentUser", "List of elements that are owned by the current user.")] public static List ElementsOwnedByCurrentUser(this List elements) { diff --git a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs index cb53488b4..1a4ac454f 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs @@ -38,7 +38,7 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ [Description("Returns a sublist of elements, from the given list of elements, that are unowned.")] - [Input("elements", "Revit elements.")] + [Input("elements", "Revit elements to query for its checkout status.")] [Output("elementsOwnedByNone", "List of elements that are unowned.")] public static List ElementsOwnedByNone(this List elements) { diff --git a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs index d746f4d39..ed2e2254c 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs @@ -38,11 +38,11 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ [Description("Returns a sublist of elements, from the given list of elements, that are owned by other users.")] - [Input("elements", "Revit elements.")] + [Input("elements", "Revit elements to query for its checkout status.")] [Output("elementsOwnedByUsers", "List of elements that are owned by other users.")] public static List ElementsOwnedByOtherUsers(this List elements) { - return elements.Where(e => e.CheckoutStatus()== Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser).ToList(); + return elements.Where(e => e.IsOwnedByOtherUser()).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs index 94b8db057..c6e57d3a1 100644 --- a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs @@ -39,7 +39,7 @@ public static partial class Query /***************************************************/ [Description("Check if element is owned by the current user.")] - [Input("element", "Revit element.")] + [Input("element", "Revit element to query for its checkout status.")] [Output("ownedByCurrentUser", "True if the input Revit element is owned by current user, otherwise false.")] public static bool IsOwnedByCurrentUser(this Element element) { diff --git a/Revit_Core_Engine/Query/IsOwnedByNone.cs b/Revit_Core_Engine/Query/IsOwnedByNone.cs index 679d6bf4c..90cf2530a 100644 --- a/Revit_Core_Engine/Query/IsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/IsOwnedByNone.cs @@ -39,7 +39,7 @@ public static partial class Query /***************************************************/ [Description("Check if element is currently unowned.")] - [Input("element", "Revit element.")] + [Input("element", "Revit element to query for its checkout status.")] [Output("ownedByNone", "True if the input Revit element is not owned, otherwise false.")] public static bool IsOwnedByNone(this Element element) { diff --git a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs index e4b945f62..a45a19bc5 100644 --- a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs @@ -39,7 +39,7 @@ public static partial class Query /***************************************************/ [Description("Check if element is owned by another user.")] - [Input("element", "Revit element.")] + [Input("element", "Revit element to query for its checkout status.")] [Output("ownedByOtherUser", "True if the input Revit element is owned by another user, otherwise false.")] public static bool IsOwnedByOtherUser(this Element element) { From d5fcc1e909a5dc05f251e3aef6ae2c5680e6dff4 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Tue, 16 Aug 2022 15:02:39 -0400 Subject: [PATCH 21/37] Update ElementsEditablePerCheckoutStatus.cs --- .../Query/ElementsEditablePerCheckoutStatus.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs index 4029abe93..c151817ff 100644 --- a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs +++ b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs @@ -45,15 +45,19 @@ public static partial class Query [Output("elementsEditablePerCheckoutStatus", "List of elements that are editable per the element's CheckoutStatus.")] public static List ElementsEditablePerCheckoutStatus(this List elements, bool recordWarnings) { + List elementsOwnedByOthers = elements.ElementsOwnedByOtherUsers().ToList(); + + List elementsNotOwnedByOthers = elements.Except(elementsOwnedByOthers).ToList(); + if (recordWarnings) { - foreach (var element in elements.ElementsOwnedByOtherUsers()) + foreach (var element in elementsOwnedByOthers) { Compute.ElementOwnedByOtherUserWarning(element); } } - return elements.Where(e => !e.IsOwnedByOtherUser()).ToList(); + return elementsNotOwnedByOthers; } /***************************************************/ } From 6e015123e9b57a6d595edc9fef45f4940b69a029 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Wed, 24 Aug 2022 10:51:43 -0400 Subject: [PATCH 22/37] spelling --- Revit_Core_Engine/Compute/Notes.cs | 4 ++-- Revit_Core_Engine/Modify/SetInsulation.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Revit_Core_Engine/Compute/Notes.cs b/Revit_Core_Engine/Compute/Notes.cs index 8acbeb685..eb078af0e 100644 --- a/Revit_Core_Engine/Compute/Notes.cs +++ b/Revit_Core_Engine/Compute/Notes.cs @@ -35,7 +35,7 @@ public static partial class Compute internal static void MaterialNotInLibraryNote(this Material material) { - string message = "Material could not be found in BHoM Libary."; + string message = "Material could not be found in BHoM Library."; if (material != null) message = string.Format("{0} Material Id: {1}", message, material.Id.IntegerValue); @@ -49,6 +49,6 @@ internal static void ElementOwnedByCurrentUserNote(Element element) } /***************************************************/ } -} +} diff --git a/Revit_Core_Engine/Modify/SetInsulation.cs b/Revit_Core_Engine/Modify/SetInsulation.cs index 95428d390..eb6a59f5c 100644 --- a/Revit_Core_Engine/Modify/SetInsulation.cs +++ b/Revit_Core_Engine/Modify/SetInsulation.cs @@ -36,7 +36,7 @@ public static partial class Modify /**** Public methods ****/ /***************************************************/ - [Description("Add or update existing insulation of the duct or pipe with given inuslation type and thickness.")] + [Description("Add or update existing insulation of the duct or pipe with given insulation type and thickness.")] [Input("host", "Host element to add or update the insulation on.")] [Input("insulationType", "Type of insulation to be added or updated on the host object. Null value removes insulation from the host if it exist.")] [Input("insulationThickness", "Thickness of insulation to be added or updated on the host object.")] From b0ed293a97635143f0887193443814bace58b195 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Wed, 31 Aug 2022 16:22:51 -0400 Subject: [PATCH 23/37] updated for null handling --- Revit_Core_Engine/Modify/Checkout.cs | 6 ++++++ Revit_Core_Engine/Query/CheckoutStatus.cs | 7 ++++++- .../Query/ElementsEditablePerCheckoutStatus.cs | 18 ++++++++++++------ .../Query/ElementsOwnedByCurrentUser.cs | 6 ++++++ Revit_Core_Engine/Query/ElementsOwnedByNone.cs | 8 +++++++- .../Query/ElementsOwnedByOtherUsers.cs | 6 ++++++ .../Query/IsOwnedByCurrentUser.cs | 6 ++++++ Revit_Core_Engine/Query/IsOwnedByNone.cs | 6 ++++++ Revit_Core_Engine/Query/IsOwnedByOtherUser.cs | 6 ++++++ 9 files changed, 61 insertions(+), 8 deletions(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index ddcd6ff0c..d3fefb68d 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -39,6 +39,12 @@ public static partial class Modify [Output("elementsCheckedOut", "List of elements checked out (ownership modified to be by current user) by this process.")] public static List Checkout(this List elements) { + if (elements == null || elements.Count <= 0) + { + BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); + return null; + } + Document document = elements.First().Document; List elementsToCheckout = new List(); diff --git a/Revit_Core_Engine/Query/CheckoutStatus.cs b/Revit_Core_Engine/Query/CheckoutStatus.cs index d287a857a..38c8bfe5b 100644 --- a/Revit_Core_Engine/Query/CheckoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckoutStatus.cs @@ -41,8 +41,13 @@ public static partial class Query [Description("Returns element CheckoutStatus.")] [Input("element", "Revit element to query for its checkout status.")] [Output("checkoutStatus", "The worksharing ownership/CheckoutStatus of the element.")] - public static CheckoutStatus CheckoutStatus(this Element element) + public static CheckoutStatus? CheckoutStatus(this Element element) { + if (element == null) + { + BH.Engine.Base.Compute.RecordError("Element cannot be null or empty."); + return null; + } return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id); } /***************************************************/ diff --git a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs index c151817ff..fa92233f4 100644 --- a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs +++ b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs @@ -37,18 +37,24 @@ public static partial class Query /***************************************************/ /**** Public methods ****/ /***************************************************/ - [Description("Returns a sublist of elements, from the given list of elements, that are editable per the element's CheckoutStatus." + + [Description("Returns a sublist of elements, from the given list of elements, that are editable per the element's CheckoutStatus. " + "Return warnings option, if true, alerts the user of which elements are uneditable due to ownership by other users.")] [Input("elements", "Revit elements to query for its checkout status.")] - [Input("recordWarnings", "If it is desired, a value of 'True' will raise warnings on which elements" - +"in the list are uneditable due to ownership by other users.")] + [Input("recordWarnings", "If it is desired, a value of 'True' will raise warnings on which elements " + + "in the list are uneditable due to ownership by other users.")] [Output("elementsEditablePerCheckoutStatus", "List of elements that are editable per the element's CheckoutStatus.")] public static List ElementsEditablePerCheckoutStatus(this List elements, bool recordWarnings) { + if (elements == null || elements.Count <= 0) + { + BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); + return null; + } + List elementsOwnedByOthers = elements.ElementsOwnedByOtherUsers().ToList(); - List elementsNotOwnedByOthers = elements.Except(elementsOwnedByOthers).ToList(); - + List editableElements = elements.Except(elementsOwnedByOthers).ToList(); + if (recordWarnings) { foreach (var element in elementsOwnedByOthers) @@ -57,7 +63,7 @@ public static List ElementsEditablePerCheckoutStatus(this List } } - return elementsNotOwnedByOthers; + return editableElements; } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs index 3fc4411fd..604a5b4af 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs @@ -43,6 +43,12 @@ public static partial class Query [Output("elementsOwnedByCurrentUser", "List of elements that are owned by the current user.")] public static List ElementsOwnedByCurrentUser(this List elements) { + if (elements == null || elements.Count <= 0) + { + BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); + return null; + } + return elements.Where(e => e.IsOwnedByCurrentUser()).ToList(); } /***************************************************/ diff --git a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs index 1a4ac454f..d45e1c1b8 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs @@ -42,7 +42,13 @@ public static partial class Query [Output("elementsOwnedByNone", "List of elements that are unowned.")] public static List ElementsOwnedByNone(this List elements) { - return elements.Where(e => e.IsOwnedByNone()).ToList(); + if (elements == null || elements.Count <= 0) + { + BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); + return null; + } + + return elements.Where(e => e.IsOwnedByNone() == true).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs index ed2e2254c..0643797ae 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs @@ -42,6 +42,12 @@ public static partial class Query [Output("elementsOwnedByUsers", "List of elements that are owned by other users.")] public static List ElementsOwnedByOtherUsers(this List elements) { + if (elements == null || elements.Count <= 0) + { + BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); + return null; + } + return elements.Where(e => e.IsOwnedByOtherUser()).ToList(); } /***************************************************/ diff --git a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs index c6e57d3a1..26e956ce0 100644 --- a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs @@ -43,6 +43,12 @@ public static partial class Query [Output("ownedByCurrentUser", "True if the input Revit element is owned by current user, otherwise false.")] public static bool IsOwnedByCurrentUser(this Element element) { + if (element == null) + { + BH.Engine.Base.Compute.RecordError("Element cannot be null or empty."); + return false; + } + return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByCurrentUser; } /***************************************************/ diff --git a/Revit_Core_Engine/Query/IsOwnedByNone.cs b/Revit_Core_Engine/Query/IsOwnedByNone.cs index 90cf2530a..51d89dadd 100644 --- a/Revit_Core_Engine/Query/IsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/IsOwnedByNone.cs @@ -43,6 +43,12 @@ public static partial class Query [Output("ownedByNone", "True if the input Revit element is not owned, otherwise false.")] public static bool IsOwnedByNone(this Element element) { + if (element == null) + { + BH.Engine.Base.Compute.RecordError("Element cannot be null or empty."); + return false; + } + return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.NotOwned; } /***************************************************/ diff --git a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs index a45a19bc5..b6ae31fb2 100644 --- a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs @@ -43,6 +43,12 @@ public static partial class Query [Output("ownedByOtherUser", "True if the input Revit element is owned by another user, otherwise false.")] public static bool IsOwnedByOtherUser(this Element element) { + if (element == null) + { + BH.Engine.Base.Compute.RecordError("Element cannot be null or empty."); + return false; + } + return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser; } /***************************************************/ From 213d7de4393fd24cd582e0a8287e8d4433a3c9e6 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Wed, 31 Aug 2022 16:34:22 -0400 Subject: [PATCH 24/37] added check for multiple documents on revit elements --- Revit_Core_Engine/Modify/Checkout.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index d3fefb68d..0f9e14567 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -44,7 +44,15 @@ public static List Checkout(this List elements) BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); return null; } - + + bool elementsOfSameDocument = elements.Select(x => x.Document).Distinct().Count() == 1; + + if (!elementsOfSameDocument) + { + BH.Engine.Base.Compute.RecordError("Elements cannot be from different Revit documents."); + return null; + } + Document document = elements.First().Document; List elementsToCheckout = new List(); From 5183e4992569e8352d086cd10cd74b383d9d7ee0 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 2 Sep 2022 08:27:59 -0400 Subject: [PATCH 25/37] added nullable type to LINQ --- Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs | 2 +- Revit_Core_Engine/Query/ElementsOwnedByNone.cs | 2 +- Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs | 2 +- Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs | 2 +- Revit_Core_Engine/Query/IsOwnedByNone.cs | 2 +- Revit_Core_Engine/Query/IsOwnedByOtherUser.cs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs index 604a5b4af..749a4d4ab 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs @@ -49,7 +49,7 @@ public static List ElementsOwnedByCurrentUser(this List elemen return null; } - return elements.Where(e => e.IsOwnedByCurrentUser()).ToList(); + return elements?.Where(e => e.IsOwnedByCurrentUser()).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs index d45e1c1b8..d528a7354 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs @@ -48,7 +48,7 @@ public static List ElementsOwnedByNone(this List elements) return null; } - return elements.Where(e => e.IsOwnedByNone() == true).ToList(); + return elements?.Where(e => e.IsOwnedByNone() == true).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs index 0643797ae..0a28f0aad 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs @@ -48,7 +48,7 @@ public static List ElementsOwnedByOtherUsers(this List element return null; } - return elements.Where(e => e.IsOwnedByOtherUser()).ToList(); + return elements?.Where(e => e.IsOwnedByOtherUser()).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs index 26e956ce0..45177d2da 100644 --- a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs @@ -49,7 +49,7 @@ public static bool IsOwnedByCurrentUser(this Element element) return false; } - return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByCurrentUser; + return element?.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByCurrentUser; } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/IsOwnedByNone.cs b/Revit_Core_Engine/Query/IsOwnedByNone.cs index 51d89dadd..11a5e7faa 100644 --- a/Revit_Core_Engine/Query/IsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/IsOwnedByNone.cs @@ -49,7 +49,7 @@ public static bool IsOwnedByNone(this Element element) return false; } - return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.NotOwned; + return element?.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.NotOwned; } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs index b6ae31fb2..b7e271ae8 100644 --- a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs @@ -49,7 +49,7 @@ public static bool IsOwnedByOtherUser(this Element element) return false; } - return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser; + return element?.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser; } /***************************************************/ } From 8f9e128a8b1480063bb1ae2f720eca7968735c83 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 2 Sep 2022 08:36:18 -0400 Subject: [PATCH 26/37] LINQ over elements to check that all of same document --- Revit_Core_Engine/Modify/Checkout.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index 0f9e14567..1ccfc599c 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -45,15 +45,16 @@ public static List Checkout(this List elements) return null; } - bool elementsOfSameDocument = elements.Select(x => x.Document).Distinct().Count() == 1; + var elementsOfSameDocument = elements.Select(x => x.Document); - if (!elementsOfSameDocument) + if (elementsOfSameDocument.Distinct().Count() > 1) { BH.Engine.Base.Compute.RecordError("Elements cannot be from different Revit documents."); return null; } - Document document = elements.First().Document; + Document document = elementsOfSameDocument.Distinct().First(); + List elementsToCheckout = new List(); foreach (Element element in elements) From 4ba086d2d2bbcedc6bed104f485c2fc836bcecd1 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 2 Sep 2022 09:01:07 -0400 Subject: [PATCH 27/37] Small change to linq --- Revit_Core_Engine/Modify/Checkout.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index 1ccfc599c..812576616 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -53,7 +53,7 @@ public static List Checkout(this List elements) return null; } - Document document = elementsOfSameDocument.Distinct().First(); + Document document = elementsOfSameDocument.First(); List elementsToCheckout = new List(); From 8edcf480d6a16db1a938ce9b69b650c4678a78b4 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 2 Sep 2022 10:32:08 -0400 Subject: [PATCH 28/37] Cange Checkout.cs method to return List --- Revit_Core_Engine/Modify/Checkout.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index 812576616..29e89a7c8 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -37,7 +37,7 @@ public static partial class Modify [Description("Modifies CheckoutStatus for each element selected if element is not currently owned by the current user or others.")] [Input("elements", "Revit elements to query for its checkout status.")] [Output("elementsCheckedOut", "List of elements checked out (ownership modified to be by current user) by this process.")] - public static List Checkout(this List elements) + public static List Checkout(this List elements) { if (elements == null || elements.Count <= 0) { @@ -55,14 +55,14 @@ public static List Checkout(this List elements) Document document = elementsOfSameDocument.First(); - List elementsToCheckout = new List(); + List elementsToCheckout = new List(); foreach (Element element in elements) { switch (element.CheckoutStatus()) { case CheckoutStatus.NotOwned: - elementsToCheckout.Add(element.Id); + elementsToCheckout.Add(element); break; case CheckoutStatus.OwnedByCurrentUser: Compute.ElementOwnedByCurrentUserNote(element); @@ -73,7 +73,7 @@ public static List Checkout(this List elements) } } - WorksharingUtils.CheckoutElements(document, elementsToCheckout); + WorksharingUtils.CheckoutElements(document, elementsToCheckout.Select(x => x.Id).ToList()); return elementsToCheckout; } From e3ecec56e6bde92a377fc7653e3e8564be791b00 Mon Sep 17 00:00:00 2001 From: Travis Potter Date: Fri, 2 Sep 2022 10:35:15 -0400 Subject: [PATCH 29/37] Update Revit_Core_Engine/Query/CheckoutStatus.cs Co-authored-by: Pawel Baran --- Revit_Core_Engine/Query/CheckoutStatus.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Query/CheckoutStatus.cs b/Revit_Core_Engine/Query/CheckoutStatus.cs index 38c8bfe5b..d992e41c1 100644 --- a/Revit_Core_Engine/Query/CheckoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckoutStatus.cs @@ -45,7 +45,7 @@ public static partial class Query { if (element == null) { - BH.Engine.Base.Compute.RecordError("Element cannot be null or empty."); + BH.Engine.Base.Compute.RecordError("Element cannot be null."); return null; } return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id); From 2fc448e2cfca22494560912ef19d7103bf35fac0 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 2 Sep 2022 10:51:30 -0400 Subject: [PATCH 30/37] update to be able to checkout from multiple documents. --- Revit_Core_Engine/Modify/Checkout.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index 29e89a7c8..e360a036b 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -45,16 +45,6 @@ public static List Checkout(this List elements) return null; } - var elementsOfSameDocument = elements.Select(x => x.Document); - - if (elementsOfSameDocument.Distinct().Count() > 1) - { - BH.Engine.Base.Compute.RecordError("Elements cannot be from different Revit documents."); - return null; - } - - Document document = elementsOfSameDocument.First(); - List elementsToCheckout = new List(); foreach (Element element in elements) @@ -73,10 +63,13 @@ public static List Checkout(this List elements) } } - WorksharingUtils.CheckoutElements(document, elementsToCheckout.Select(x => x.Id).ToList()); + foreach (var group in elementsToCheckout.GroupBy(x => x.Document)) + { + WorksharingUtils.CheckoutElements(group.Key, group.Select(x => x.Id).ToList()); + } + return elementsToCheckout; } - /***************************************************/ } } From 5434f7b900d29a453249d1e12cb1b2ec23288b22 Mon Sep 17 00:00:00 2001 From: Travis Potter Date: Fri, 2 Sep 2022 11:20:15 -0400 Subject: [PATCH 31/37] Update Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs Co-authored-by: Pawel Baran --- Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs index 45177d2da..25a8fbb81 100644 --- a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs @@ -45,7 +45,7 @@ public static bool IsOwnedByCurrentUser(this Element element) { if (element == null) { - BH.Engine.Base.Compute.RecordError("Element cannot be null or empty."); + BH.Engine.Base.Compute.RecordError("Element cannot be null."); return false; } From 0971801072a517a6643dff5bafb0023e6db34698 Mon Sep 17 00:00:00 2001 From: Travis Potter Date: Fri, 2 Sep 2022 11:20:25 -0400 Subject: [PATCH 32/37] Update Revit_Core_Engine/Query/IsOwnedByNone.cs Co-authored-by: Pawel Baran --- Revit_Core_Engine/Query/IsOwnedByNone.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Query/IsOwnedByNone.cs b/Revit_Core_Engine/Query/IsOwnedByNone.cs index 11a5e7faa..31ded104e 100644 --- a/Revit_Core_Engine/Query/IsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/IsOwnedByNone.cs @@ -45,7 +45,7 @@ public static bool IsOwnedByNone(this Element element) { if (element == null) { - BH.Engine.Base.Compute.RecordError("Element cannot be null or empty."); + BH.Engine.Base.Compute.RecordError("Element cannot be null."); return false; } From f263e07a5710f8c8a7d5dfdf87002d43fabe6101 Mon Sep 17 00:00:00 2001 From: Travis Potter Date: Fri, 2 Sep 2022 11:20:30 -0400 Subject: [PATCH 33/37] Update Revit_Core_Engine/Query/IsOwnedByOtherUser.cs Co-authored-by: Pawel Baran --- Revit_Core_Engine/Query/IsOwnedByOtherUser.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs index b7e271ae8..60454e4da 100644 --- a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs @@ -45,7 +45,7 @@ public static bool IsOwnedByOtherUser(this Element element) { if (element == null) { - BH.Engine.Base.Compute.RecordError("Element cannot be null or empty."); + BH.Engine.Base.Compute.RecordError("Element cannot be null."); return false; } From 9cf4d6d0021c189f3f60ea0b1d30eac264b1d335 Mon Sep 17 00:00:00 2001 From: Travis Potter Date: Fri, 2 Sep 2022 11:20:57 -0400 Subject: [PATCH 34/37] Update Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs Co-authored-by: Pawel Baran --- Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs index 0a28f0aad..8b122410c 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs @@ -42,9 +42,9 @@ public static partial class Query [Output("elementsOwnedByUsers", "List of elements that are owned by other users.")] public static List ElementsOwnedByOtherUsers(this List elements) { - if (elements == null || elements.Count <= 0) + if (elements == null) { - BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); + BH.Engine.Base.Compute.RecordError("Element list cannot be null."); return null; } From 9fbd348ad5082a95a16c70ac966b84505260d092 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 2 Sep 2022 11:26:34 -0400 Subject: [PATCH 35/37] removing list empty check --- Revit_Core_Engine/Modify/Checkout.cs | 4 ++-- Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs | 4 ++-- Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs | 4 ++-- Revit_Core_Engine/Query/ElementsOwnedByNone.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index e360a036b..e71efb7ab 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -39,9 +39,9 @@ public static partial class Modify [Output("elementsCheckedOut", "List of elements checked out (ownership modified to be by current user) by this process.")] public static List Checkout(this List elements) { - if (elements == null || elements.Count <= 0) + if (elements == null) { - BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); + BH.Engine.Base.Compute.RecordError("Element list cannot be null."); return null; } diff --git a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs index fa92233f4..ef7712e5c 100644 --- a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs +++ b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs @@ -45,9 +45,9 @@ public static partial class Query [Output("elementsEditablePerCheckoutStatus", "List of elements that are editable per the element's CheckoutStatus.")] public static List ElementsEditablePerCheckoutStatus(this List elements, bool recordWarnings) { - if (elements == null || elements.Count <= 0) + if (elements == null) { - BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); + BH.Engine.Base.Compute.RecordError("Element list cannot be null."); return null; } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs index 749a4d4ab..e09b71d04 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs @@ -43,9 +43,9 @@ public static partial class Query [Output("elementsOwnedByCurrentUser", "List of elements that are owned by the current user.")] public static List ElementsOwnedByCurrentUser(this List elements) { - if (elements == null || elements.Count <= 0) + if (elements == null) { - BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); + BH.Engine.Base.Compute.RecordError("Element list cannot be null."); return null; } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs index d528a7354..a84630815 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs @@ -42,9 +42,9 @@ public static partial class Query [Output("elementsOwnedByNone", "List of elements that are unowned.")] public static List ElementsOwnedByNone(this List elements) { - if (elements == null || elements.Count <= 0) + if (elements == null) { - BH.Engine.Base.Compute.RecordError("Element list cannot be null or empty."); + BH.Engine.Base.Compute.RecordError("Element list cannot be null."); return null; } From 11f5efa41b2e82dbbedf49de7e898d4e1bcf063c Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 2 Sep 2022 11:37:01 -0400 Subject: [PATCH 36/37] updating error comments --- Revit_Core_Engine/Modify/Checkout.cs | 2 +- Revit_Core_Engine/Query/CheckoutStatus.cs | 2 +- Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs | 2 +- Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs | 4 ++-- Revit_Core_Engine/Query/ElementsOwnedByNone.cs | 4 ++-- Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs | 4 ++-- Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs | 4 ++-- Revit_Core_Engine/Query/IsOwnedByNone.cs | 2 +- Revit_Core_Engine/Query/IsOwnedByOtherUser.cs | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Revit_Core_Engine/Modify/Checkout.cs b/Revit_Core_Engine/Modify/Checkout.cs index e71efb7ab..99634b24e 100644 --- a/Revit_Core_Engine/Modify/Checkout.cs +++ b/Revit_Core_Engine/Modify/Checkout.cs @@ -41,7 +41,7 @@ public static List Checkout(this List elements) { if (elements == null) { - BH.Engine.Base.Compute.RecordError("Element list cannot be null."); + BH.Engine.Base.Compute.RecordError("Check out process of list of elements failed because the list of elements provided was null."); return null; } diff --git a/Revit_Core_Engine/Query/CheckoutStatus.cs b/Revit_Core_Engine/Query/CheckoutStatus.cs index d992e41c1..485c1c845 100644 --- a/Revit_Core_Engine/Query/CheckoutStatus.cs +++ b/Revit_Core_Engine/Query/CheckoutStatus.cs @@ -45,7 +45,7 @@ public static partial class Query { if (element == null) { - BH.Engine.Base.Compute.RecordError("Element cannot be null."); + BH.Engine.Base.Compute.RecordError("Querying checkout status of element failed because the element provided was null."); return null; } return WorksharingUtils.GetCheckoutStatus(element.Document, element.Id); diff --git a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs index ef7712e5c..abcf8ebe1 100644 --- a/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs +++ b/Revit_Core_Engine/Query/ElementsEditablePerCheckoutStatus.cs @@ -47,7 +47,7 @@ public static List ElementsEditablePerCheckoutStatus(this List { if (elements == null) { - BH.Engine.Base.Compute.RecordError("Element list cannot be null."); + BH.Engine.Base.Compute.RecordError("Querying checkout status of list of elements for editable status failed because the list of elements provided was null."); return null; } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs index e09b71d04..87609f5a8 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByCurrentUser.cs @@ -45,11 +45,11 @@ public static List ElementsOwnedByCurrentUser(this List elemen { if (elements == null) { - BH.Engine.Base.Compute.RecordError("Element list cannot be null."); + BH.Engine.Base.Compute.RecordError("Querying checkout status of list of elements for ownership by current user failed because the list of elements provided was null."); return null; } - return elements?.Where(e => e.IsOwnedByCurrentUser()).ToList(); + return elements.Where(e => e.IsOwnedByCurrentUser()).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs index a84630815..78df508f0 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByNone.cs @@ -44,11 +44,11 @@ public static List ElementsOwnedByNone(this List elements) { if (elements == null) { - BH.Engine.Base.Compute.RecordError("Element list cannot be null."); + BH.Engine.Base.Compute.RecordError("Querying checkout status of list of elements for ownership by none failed because the list of elements provided was null."); return null; } - return elements?.Where(e => e.IsOwnedByNone() == true).ToList(); + return elements.Where(e => e.IsOwnedByNone() == true).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs index 8b122410c..b96ee5b0c 100644 --- a/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs +++ b/Revit_Core_Engine/Query/ElementsOwnedByOtherUsers.cs @@ -44,11 +44,11 @@ public static List ElementsOwnedByOtherUsers(this List element { if (elements == null) { - BH.Engine.Base.Compute.RecordError("Element list cannot be null."); + BH.Engine.Base.Compute.RecordError("Querying checkout status of list of elements for ownership by others failed because the list of elements provided was null."); return null; } - return elements?.Where(e => e.IsOwnedByOtherUser()).ToList(); + return elements.Where(e => e.IsOwnedByOtherUser()).ToList(); } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs index 25a8fbb81..f42ae66cb 100644 --- a/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByCurrentUser.cs @@ -45,11 +45,11 @@ public static bool IsOwnedByCurrentUser(this Element element) { if (element == null) { - BH.Engine.Base.Compute.RecordError("Element cannot be null."); + BH.Engine.Base.Compute.RecordError("Querying checkout status of element for ownership by current user failed because the element provided was null."); return false; } - return element?.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByCurrentUser; + return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByCurrentUser; } /***************************************************/ } diff --git a/Revit_Core_Engine/Query/IsOwnedByNone.cs b/Revit_Core_Engine/Query/IsOwnedByNone.cs index 31ded104e..d6285f65d 100644 --- a/Revit_Core_Engine/Query/IsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/IsOwnedByNone.cs @@ -45,7 +45,7 @@ public static bool IsOwnedByNone(this Element element) { if (element == null) { - BH.Engine.Base.Compute.RecordError("Element cannot be null."); + BH.Engine.Base.Compute.RecordError("Querying checkout status of element for ownership by none failed because the element provided was null."); return false; } diff --git a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs index 60454e4da..10d36a421 100644 --- a/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs +++ b/Revit_Core_Engine/Query/IsOwnedByOtherUser.cs @@ -45,11 +45,11 @@ public static bool IsOwnedByOtherUser(this Element element) { if (element == null) { - BH.Engine.Base.Compute.RecordError("Element cannot be null."); + BH.Engine.Base.Compute.RecordError("Querying checkout status of element for ownership by others failed because the element provided was null."); return false; } - return element?.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser; + return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.OwnedByOtherUser; } /***************************************************/ } From ea5e8663709514f149b17235a4592bc20ecf80e8 Mon Sep 17 00:00:00 2001 From: travispotterBH Date: Fri, 2 Sep 2022 11:42:32 -0400 Subject: [PATCH 37/37] Update IsOwnedByNone.cs --- Revit_Core_Engine/Query/IsOwnedByNone.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Query/IsOwnedByNone.cs b/Revit_Core_Engine/Query/IsOwnedByNone.cs index d6285f65d..d62cdeb35 100644 --- a/Revit_Core_Engine/Query/IsOwnedByNone.cs +++ b/Revit_Core_Engine/Query/IsOwnedByNone.cs @@ -49,7 +49,7 @@ public static bool IsOwnedByNone(this Element element) return false; } - return element?.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.NotOwned; + return element.CheckoutStatus() == Autodesk.Revit.DB.CheckoutStatus.NotOwned; } /***************************************************/ }