From d36309bafbd72ee7a570b531d732e1ed5baebe7b Mon Sep 17 00:00:00 2001 From: Pawel Baran Date: Mon, 13 Jan 2020 15:32:16 +0100 Subject: [PATCH 1/4] Reinstance of Revit_Toolkit-Issue486-AdapterRefactoringLvl4 --- Adapter_Revit_UI/AdapterActions/Execute.cs | 5 +- Adapter_Revit_UI/AdapterActions/Push.cs | 34 ++++- Adapter_Revit_UI/Adapter_Revit_UI.csproj | 15 ++- Adapter_Revit_UI/CRUD/Create.cs | 8 +- Adapter_Revit_UI/CRUD/Delete.cs | 2 +- Adapter_Revit_UI/CRUD/Read.cs | 7 +- Adapter_Revit_UI/CRUD/Update.cs | 2 +- Adapter_Revit_UI/RevitUIAdapter.cs | 30 ++++- Adapter_Revit_UI/Types/DependencyTypes.cs | 75 ----------- Engine_Revit_UI/Modify/SetIdentifiers.cs | 4 +- Revit_Adapter/AdapterActions/Execute.cs | 11 +- Revit_Adapter/AdapterActions/Pull.cs | 90 ++++++++++++++ Revit_Adapter/AdapterActions/Push.cs | 106 ++++++++++++++++ .../AdapterActions/Remove.cs | 53 ++++---- Revit_Adapter/InternalRevitAdapter.cs | 3 +- Revit_Adapter/PackageType.cs | 4 +- Revit_Adapter/RevitAdapter.cs | 116 +----------------- Revit_Adapter/Revit_Adapter.csproj | 17 ++- Revit_Engine/Convert/AdapterIdName.cs | 46 +++++++ Revit_Engine/Create/Elements/BHoMObject.cs | 4 +- Revit_Engine/Create/Elements/Panel.cs | 4 +- Revit_Engine/Modify/RemoveIdentifiers.cs | 4 +- Revit_Engine/Query/Duplicate.cs | 6 +- Revit_Engine/Query/UniqueId.cs | 4 +- Revit_Engine/Revit_Engine.csproj | 2 +- Revit_UI/AdapterActions/Pull.cs | 4 +- Revit_UI/AdapterActions/Push.cs | 4 +- Revit_UI/RevitListener.cs | 17 ++- Revit_UI/Revit_UI.csproj | 4 + Revit_oM/RevitConfig.cs | 43 +++++++ Revit_oM/Revit_oM.csproj | 7 +- Revit_oM/Settings/UpdateTagsSettings.cs | 39 ++++++ 32 files changed, 499 insertions(+), 271 deletions(-) delete mode 100644 Adapter_Revit_UI/Types/DependencyTypes.cs create mode 100644 Revit_Adapter/AdapterActions/Pull.cs create mode 100644 Revit_Adapter/AdapterActions/Push.cs rename Adapter_Revit_UI/Types/Comparer.cs => Revit_Adapter/AdapterActions/Remove.cs (58%) create mode 100644 Revit_Engine/Convert/AdapterIdName.cs create mode 100644 Revit_oM/RevitConfig.cs create mode 100644 Revit_oM/Settings/UpdateTagsSettings.cs diff --git a/Adapter_Revit_UI/AdapterActions/Execute.cs b/Adapter_Revit_UI/AdapterActions/Execute.cs index 5796e336b..f3cdd6ddf 100644 --- a/Adapter_Revit_UI/AdapterActions/Execute.cs +++ b/Adapter_Revit_UI/AdapterActions/Execute.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2018, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -20,6 +20,7 @@ * along with this code. If not, see . */ +using BH.oM.Adapter; using System.Collections.Generic; namespace BH.UI.Revit.Adapter @@ -30,7 +31,7 @@ public partial class RevitUIAdapter /**** IAdapter Interface ****/ /***************************************************/ - public override bool Execute(string command, Dictionary parameters = null, Dictionary config = null) + public override bool Execute(string command, Dictionary parameters = null, ActionConfig actionConfig = null) { string commandUpper = command.ToUpper(); diff --git a/Adapter_Revit_UI/AdapterActions/Push.cs b/Adapter_Revit_UI/AdapterActions/Push.cs index b202a706b..37c71deba 100644 --- a/Adapter_Revit_UI/AdapterActions/Push.cs +++ b/Adapter_Revit_UI/AdapterActions/Push.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -26,6 +26,8 @@ using System.Reflection; using BH.oM.Base; +using BH.oM.Adapter; +using BH.oM.Adapters.Revit; namespace BH.UI.Revit.Adapter { @@ -36,11 +38,33 @@ public partial class RevitUIAdapter /**** Protected Methods ****/ /***************************************************/ - public override List Push(IEnumerable objects, string tag = "", Dictionary config = null) + public override List Push(IEnumerable objects, string tag = "", PushType pushType = PushType.AdapterDefault, ActionConfig actionConfig = null) { bool success = true; - List objectsToPush = Config.CloneBeforePush ? objects.Select(x => x is BHoMObject ? ((BHoMObject)x).GetShallowClone() : x).ToList() : objects.ToList(); //ToList() necessary for the return collection to function properly for cloned objects + // ----------------------------------------// + // SET-UP // + // ----------------------------------------// + + // If unset, set the pushType to AdapterSettings' value (base AdapterSettings default is FullCRUD). + if (pushType == PushType.AdapterDefault) + pushType = m_AdapterSettings.DefaultPushType; + + //Initialize Revit config + RevitConfig revitConfig = actionConfig as RevitConfig; + + // Process the objects (verify they are valid; DeepClone them, wrap them, etc). + IEnumerable objectsToPush = ProcessObjectsForPush(objects, revitConfig); // Note: default Push only supports IBHoMObjects. + + if (objectsToPush.Count() == 0) + { + BH.Engine.Reflection.Compute.RecordError("Input objects were invalid."); + return new List(); + } + + // ----------------------------------------// + // ACTUAL PUSH // + // ----------------------------------------// Type iBHoMObjectType = typeof(IBHoMObject); MethodInfo miToList = typeof(Enumerable).GetMethod("Cast"); @@ -52,10 +76,10 @@ public override List Push(IEnumerable objects, string tag = "" var list = miListObject.Invoke(typeGroup, new object[] { typeGroup }); if (iBHoMObjectType.IsAssignableFrom(typeGroup.Key)) - success &= Create(list as dynamic); + success &= ICreate(list as dynamic); } - return success ? objectsToPush : new List(); + return success ? objectsToPush.Cast().ToList() : new List(); } /***************************************************/ diff --git a/Adapter_Revit_UI/Adapter_Revit_UI.csproj b/Adapter_Revit_UI/Adapter_Revit_UI.csproj index afd4460c6..624413b0d 100644 --- a/Adapter_Revit_UI/Adapter_Revit_UI.csproj +++ b/Adapter_Revit_UI/Adapter_Revit_UI.csproj @@ -103,6 +103,16 @@ Adapter_Revit_UI_2020 + + False + ..\..\BHoM_Adapter\Build\Adapter_Engine.dll + False + + + False + ..\..\BHoM_Adapter\Build\Adapter_oM.dll + False + False ..\..\BHoM\Build\Analytical_oM.dll @@ -115,7 +125,8 @@ ..\..\BHoM\Build\BHoM.dll False - + + False ..\..\BHoM_Adapter\Build\BHoM_Adapter.dll False @@ -201,8 +212,6 @@ - - diff --git a/Adapter_Revit_UI/CRUD/Create.cs b/Adapter_Revit_UI/CRUD/Create.cs index d2b92c531..aee616a99 100644 --- a/Adapter_Revit_UI/CRUD/Create.cs +++ b/Adapter_Revit_UI/CRUD/Create.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -34,6 +34,7 @@ using BH.oM.Adapters.Revit.Settings; using BH.oM.Adapters.Revit.Interface; using BH.oM.Adapters.Revit.Properties; +using BH.oM.Adapter; namespace BH.UI.Revit.Adapter { @@ -43,7 +44,7 @@ public partial class RevitUIAdapter : BH.Adapter.Revit.InternalRevitAdapter /**** Protected Methods ****/ /***************************************************/ - protected override bool Create(IEnumerable objects) + protected override bool ICreate(IEnumerable objects, ActionConfig actionConfig = null) { if (Document == null) { @@ -288,7 +289,7 @@ private static void SetIdentifiers(IBHoMObject bHoMObject, Element element) return; SetCustomData(bHoMObject, BH.Engine.Adapters.Revit.Convert.ElementId, element.Id.IntegerValue); - SetCustomData(bHoMObject, BH.Engine.Adapters.Revit.Convert.AdapterId, element.UniqueId); + SetCustomData(bHoMObject, BH.Engine.Adapters.Revit.Convert.AdapterIdName, element.UniqueId); if (element is Family) { @@ -351,6 +352,7 @@ private static void SetCustomData(IBHoMObject bHoMObject, string customDataName, bHoMObject.CustomData[customDataName] = value; } + /***************************************************/ /**** Private Classes ****/ /***************************************************/ diff --git a/Adapter_Revit_UI/CRUD/Delete.cs b/Adapter_Revit_UI/CRUD/Delete.cs index 879d035cc..d7fb6671a 100644 --- a/Adapter_Revit_UI/CRUD/Delete.cs +++ b/Adapter_Revit_UI/CRUD/Delete.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. diff --git a/Adapter_Revit_UI/CRUD/Read.cs b/Adapter_Revit_UI/CRUD/Read.cs index fd32e87ce..1f8690af8 100644 --- a/Adapter_Revit_UI/CRUD/Read.cs +++ b/Adapter_Revit_UI/CRUD/Read.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -35,6 +35,7 @@ using BH.UI.Revit.Engine; using BH.oM.Data.Requests; using BH.oM.Adapters.Revit.Properties; +using BH.oM.Adapter; namespace BH.UI.Revit.Adapter { @@ -44,7 +45,7 @@ public partial class RevitUIAdapter /**** Protected Methods ****/ /***************************************************/ - protected override IEnumerable Read(Type type, IList ids) + protected override IEnumerable IRead(Type type, IList ids, ActionConfig actionConfig = null) { if (Document == null) { @@ -116,7 +117,7 @@ protected override IEnumerable Read(Type type, IList ids) /***************************************************/ - protected override IEnumerable Read(FilterRequest filterRequest) + protected override IEnumerable Read(FilterRequest filterRequest, ActionConfig actionConfig = null) { Document document = Document; diff --git a/Adapter_Revit_UI/CRUD/Update.cs b/Adapter_Revit_UI/CRUD/Update.cs index 8c14cb44e..224c8873c 100644 --- a/Adapter_Revit_UI/CRUD/Update.cs +++ b/Adapter_Revit_UI/CRUD/Update.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2018, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. diff --git a/Adapter_Revit_UI/RevitUIAdapter.cs b/Adapter_Revit_UI/RevitUIAdapter.cs index 0c0eb4593..3c698ab9b 100644 --- a/Adapter_Revit_UI/RevitUIAdapter.cs +++ b/Adapter_Revit_UI/RevitUIAdapter.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -24,6 +24,11 @@ using Autodesk.Revit.UI; using BH.Adapter.Revit; +using BH.oM.Adapters.Revit.Elements; +using BH.oM.Structure.Elements; +using BH.oM.Structure.SectionProperties; +using System; +using System.Collections.Generic; namespace BH.UI.Revit.Adapter { @@ -47,11 +52,30 @@ public partial class RevitUIAdapter : InternalRevitAdapter public RevitUIAdapter(UIControlledApplication uIControlledApplication, Document document) : base() { - AdapterId = BH.Engine.Adapters.Revit.Convert.AdapterId; - Config.UseAdapterId = false; + AdapterIdName = BH.Engine.Adapters.Revit.Convert.AdapterIdName; + m_AdapterSettings.UseAdapterId = false; m_Document = document; m_UIControlledApplication = uIControlledApplication; + + + AdapterComparers = new Dictionary + { + //{typeof(ISectionProperty), new BHoMObjectNameOrToStringComparer() }, + //{typeof(IProfile), new BHoMObjectNameOrToStringComparer() }, + //{typeof(ISurfaceProperty), new BHoMObjectNameOrToStringComparer() }, + //{typeof(Material), new BHoMObjectNameComparer() }, + //{typeof(Level), new BHoMObjectNameComparer() }, + }; + + DependencyTypes = new Dictionary> + { + {typeof(oM.Adapters.Revit.Elements.Viewport), new List { typeof(oM.Adapters.Revit.Elements.Sheet), typeof(oM.Adapters.Revit.Elements.ViewPlan) } }, + {typeof(oM.Adapters.Revit.Elements.Sheet), new List { typeof(oM.Adapters.Revit.Elements.ViewPlan)} } + //{typeof(ISectionProperty), new List { typeof(Material), typeof(IProfile) } }, + //{typeof(PanelPlanar), new List { typeof(ISurfaceProperty), typeof(Level) } }, + //{typeof(ISurfaceProperty), new List { typeof(Material) } } + }; } diff --git a/Adapter_Revit_UI/Types/DependencyTypes.cs b/Adapter_Revit_UI/Types/DependencyTypes.cs deleted file mode 100644 index 0a2d1dcb4..000000000 --- a/Adapter_Revit_UI/Types/DependencyTypes.cs +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2018, 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 System; -using System.Collections.Generic; - -using BH.oM.Adapters.Revit.Elements; - -namespace BH.UI.Revit.Adapter -{ - public partial class RevitUIAdapter - { - /***************************************************/ - /**** BHoM Adapter Interface ****/ - /***************************************************/ - - protected override List DependencyTypes() - { - Type type = typeof(T); - - if (m_DependencyTypes.ContainsKey(type)) - return m_DependencyTypes[type]; - - else if (m_DependencyTypes.ContainsKey(type.BaseType)) - return m_DependencyTypes[type.BaseType]; - - else - { - foreach (Type interType in type.GetInterfaces()) - { - if (m_DependencyTypes.ContainsKey(interType)) - return m_DependencyTypes[interType]; - } - } - - - return new List(); - } - - - /***************************************************/ - /**** Private Fields ****/ - /***************************************************/ - - private static Dictionary> m_DependencyTypes = new Dictionary> - { - {typeof(Viewport), new List { typeof(Sheet), typeof(ViewPlan) } }, - {typeof(Sheet), new List { typeof(ViewPlan)} } - //{typeof(ISectionProperty), new List { typeof(Material), typeof(IProfile) } }, - //{typeof(PanelPlanar), new List { typeof(ISurfaceProperty), typeof(Level) } }, - //{typeof(ISurfaceProperty), new List { typeof(Material) } } - }; - - /***************************************************/ - } -} \ No newline at end of file diff --git a/Engine_Revit_UI/Modify/SetIdentifiers.cs b/Engine_Revit_UI/Modify/SetIdentifiers.cs index 6000827da..62df80989 100644 --- a/Engine_Revit_UI/Modify/SetIdentifiers.cs +++ b/Engine_Revit_UI/Modify/SetIdentifiers.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -40,7 +40,7 @@ public static IBHoMObject SetIdentifiers(this IBHoMObject bHoMObject, Element el IBHoMObject obj = bHoMObject.GetShallowClone() as IBHoMObject; obj = obj.SetCustomData(BH.Engine.Adapters.Revit.Convert.ElementId, element.Id.IntegerValue); - obj = obj.SetCustomData(BH.Engine.Adapters.Revit.Convert.AdapterId, element.UniqueId); + obj = obj.SetCustomData(BH.Engine.Adapters.Revit.Convert.AdapterIdName, element.UniqueId); int worksetID = WorksetId.InvalidWorksetId.IntegerValue; if (element.Document != null && element.Document.IsWorkshared) diff --git a/Revit_Adapter/AdapterActions/Execute.cs b/Revit_Adapter/AdapterActions/Execute.cs index 31eff4c0c..f54d7e126 100644 --- a/Revit_Adapter/AdapterActions/Execute.cs +++ b/Revit_Adapter/AdapterActions/Execute.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2018, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -20,6 +20,8 @@ * along with this code. If not, see . */ +using BH.oM.Adapter; +using BH.oM.Adapters.Revit; using System.Collections.Generic; namespace BH.Adapter.Revit @@ -30,12 +32,15 @@ public partial class RevitAdapter /**** Public Methods ****/ /***************************************************/ - public override bool Execute(string command, Dictionary parameters = null, Dictionary config = null) + public override bool Execute(string command, Dictionary parameters = null, ActionConfig actionConfig = null) { + //Initialize Revit config + RevitConfig revitConfig = actionConfig as RevitConfig; + if (InternalAdapter != null) { InternalAdapter.RevitSettings = RevitSettings; - return InternalAdapter.Execute(command, parameters, config); + return InternalAdapter.Execute(command, parameters, revitConfig); } return false; diff --git a/Revit_Adapter/AdapterActions/Pull.cs b/Revit_Adapter/AdapterActions/Pull.cs new file mode 100644 index 000000000..a859682a4 --- /dev/null +++ b/Revit_Adapter/AdapterActions/Pull.cs @@ -0,0 +1,90 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2020, 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 BH.oM.Adapters.Revit; +using BH.oM.Adapter; +using BH.Adapter.Socket; +using BH.oM.Base; +using BH.oM.Data.Requests; +using BH.oM.Reflection.Debugging; +using BH.oM.Adapters.Revit.Settings; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using BH.oM.Reflection.Attributes; +using System.ComponentModel; + +namespace BH.Adapter.Revit +{ + public partial class RevitAdapter : BHoMAdapter + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + + public override IEnumerable Pull(IRequest request, PullType pullType = PullType.AdapterDefault, ActionConfig actionConfig = null) + { + //Initialize Revit config + RevitConfig revitConfig = actionConfig as RevitConfig; + + //If internal adapter is loaded call it directly + if (InternalAdapter != null) + { + InternalAdapter.RevitSettings = RevitSettings; + return InternalAdapter.Pull(request, pullType, revitConfig); + } + + //Reset the wait event + m_WaitEvent.Reset(); + + if (!CheckConnection()) + return new List(); + + if (!(request is FilterRequest)) + return new List(); + + //Send data through the socket link + m_LinkIn.SendData(new List() { PackageType.Pull, request as FilterRequest, revitConfig, RevitSettings }); + + //Wait until the return message has been recieved + if (!m_WaitEvent.WaitOne(TimeSpan.FromMinutes(m_WaitTime))) + Engine.Reflection.Compute.RecordError("The connection with Revit timed out. If working on a big model, try to increase the max wait time"); + + //Grab the return objects from the latest package + List returnObjs = new List(m_ReturnPackage); + + //Clear the return list + m_ReturnPackage.Clear(); + + //Raise returned events + RaiseEvents(); + + //Return the package + return returnObjs; + + } + + /***************************************************/ + } +} diff --git a/Revit_Adapter/AdapterActions/Push.cs b/Revit_Adapter/AdapterActions/Push.cs new file mode 100644 index 000000000..81621fdda --- /dev/null +++ b/Revit_Adapter/AdapterActions/Push.cs @@ -0,0 +1,106 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2020, 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 BH.oM.Adapters.Revit; +using BH.oM.Adapter; +using BH.Adapter.Socket; +using BH.oM.Base; +using BH.oM.Data.Requests; +using BH.oM.Reflection.Debugging; +using BH.oM.Adapters.Revit.Settings; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using BH.oM.Reflection.Attributes; +using System.ComponentModel; + +namespace BH.Adapter.Revit +{ + public partial class RevitAdapter : BHoMAdapter + { + /***************************************************/ + /**** Public methods ****/ + /***************************************************/ + + public override List Push(IEnumerable objects, string tag = "", PushType pushType = PushType.AdapterDefault, ActionConfig actionConfig = null) + { + // ----------------------------------------// + // SET-UP // + // ----------------------------------------// + + // If unset, set the pushType to AdapterSettings' value (base AdapterSettings default is FullCRUD). + if (pushType == PushType.AdapterDefault) + pushType = m_AdapterSettings.DefaultPushType; + + //Initialize Revit config + RevitConfig revitConfig = actionConfig as RevitConfig; + + // Process the objects (verify they are valid; DeepClone them, wrap them, etc). + IEnumerable objectsToPush = ProcessObjectsForPush(objects, revitConfig); // Note: default Push only supports IBHoMObjects. + + if (objectsToPush.Count() == 0) + { + Engine.Reflection.Compute.RecordError("Input objects were invalid."); + return new List(); + } + + // ----------------------------------------// + // ACTUAL PUSH // + // ----------------------------------------// + + //If internal adapter is loaded call it directly + if (InternalAdapter != null) + { + InternalAdapter.RevitSettings = RevitSettings; + return InternalAdapter.Push(objects, tag, pushType, revitConfig); + } + + //Reset the wait event + m_WaitEvent.Reset(); + + if (!CheckConnection()) + return new List(); + + //Send data through the socket link + m_LinkIn.SendData(new List() { PackageType.Push, objects.ToList(), revitConfig, RevitSettings }, tag); + + //Wait until the return message has been recieved + if (!m_WaitEvent.WaitOne(TimeSpan.FromMinutes(m_WaitTime))) + BH.Engine.Reflection.Compute.RecordError("The connection with Revit timed out. If working on a big model, try to increase the max wait time"); + + //Grab the return objects from the latest package + List returnObjs = m_ReturnPackage.ToList(); + + //Clear the return list + m_ReturnPackage.Clear(); + + RaiseEvents(); + + //Return the package + return returnObjs; + } + + /***************************************************/ + } +} diff --git a/Adapter_Revit_UI/Types/Comparer.cs b/Revit_Adapter/AdapterActions/Remove.cs similarity index 58% rename from Adapter_Revit_UI/Types/Comparer.cs rename to Revit_Adapter/AdapterActions/Remove.cs index 18a90d508..4f57a4c7e 100644 --- a/Adapter_Revit_UI/Types/Comparer.cs +++ b/Revit_Adapter/AdapterActions/Remove.cs @@ -1,6 +1,6 @@ -/* +/* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2018, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -20,47 +20,44 @@ * along with this code. If not, see . */ - +using BH.oM.Adapter; +using BH.Adapter.Socket; +using BH.oM.Base; +using BH.oM.Data.Requests; +using BH.oM.Reflection.Debugging; +using BH.oM.Adapters.Revit.Settings; using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; +using System.Threading; +using BH.oM.Reflection.Attributes; +using System.ComponentModel; +using BH.oM.Adapters.Revit; -namespace BH.UI.Revit.Adapter +namespace BH.Adapter.Revit { - public partial class RevitUIAdapter + public partial class RevitAdapter : BHoMAdapter { /***************************************************/ - /**** BHoM Adapter Interface ****/ + /**** Public methods ****/ /***************************************************/ - protected override IEqualityComparer Comparer() + public override int Remove(IRequest request, ActionConfig actionConfig = null) { - Type type = typeof(T); + //Initialize Revit config + RevitConfig revitConfig = actionConfig as RevitConfig; - if (m_Comparers.ContainsKey(type)) - { - return m_Comparers[type] as IEqualityComparer; - } - else + //If internal adapter is loaded call it directly + if (InternalAdapter != null) { - return EqualityComparer.Default; + InternalAdapter.RevitSettings = RevitSettings; + return InternalAdapter.Remove(request, revitConfig); } + throw new NotImplementedException(); } - - /***************************************************/ - /**** Private Fields ****/ - /***************************************************/ - - private static Dictionary m_Comparers = new Dictionary - { - //{typeof(ISectionProperty), new BHoMObjectNameOrToStringComparer() }, - //{typeof(IProfile), new BHoMObjectNameOrToStringComparer() }, - //{typeof(ISurfaceProperty), new BHoMObjectNameOrToStringComparer() }, - //{typeof(Material), new BHoMObjectNameComparer() }, - //{typeof(Level), new BHoMObjectNameComparer() }, - }; - /***************************************************/ } } diff --git a/Revit_Adapter/InternalRevitAdapter.cs b/Revit_Adapter/InternalRevitAdapter.cs index e0dd4dc9b..87a3e7101 100644 --- a/Revit_Adapter/InternalRevitAdapter.cs +++ b/Revit_Adapter/InternalRevitAdapter.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2018, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -20,6 +20,7 @@ * along with this code. If not, see . */ +using BH.Adapter; using BH.oM.Adapters.Revit.Settings; namespace BH.Adapter.Revit diff --git a/Revit_Adapter/PackageType.cs b/Revit_Adapter/PackageType.cs index ff43da985..601d25451 100644 --- a/Revit_Adapter/PackageType.cs +++ b/Revit_Adapter/PackageType.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2018, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -27,6 +27,6 @@ public enum PackageType Push, Pull, ConnectionCheck, - UpdateProperty, + UpdateTags, } } diff --git a/Revit_Adapter/RevitAdapter.cs b/Revit_Adapter/RevitAdapter.cs index a056b5bcc..82f9945a1 100644 --- a/Revit_Adapter/RevitAdapter.cs +++ b/Revit_Adapter/RevitAdapter.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -32,6 +32,7 @@ using System.Threading; using BH.oM.Reflection.Attributes; using System.ComponentModel; +using BH.oM.Adapter; namespace BH.Adapter.Revit { @@ -80,102 +81,6 @@ public RevitAdapter(RevitSettings revitSettings = null, bool active = false) /**** Public methods ****/ /***************************************************/ - public override List Push(IEnumerable objects, string tag = "", Dictionary config = null) - { - //If internal adapter is loaded call it directly - if (InternalAdapter != null) - { - InternalAdapter.RevitSettings = RevitSettings; - return InternalAdapter.Push(objects, tag, config); - } - - //Reset the wait event - m_WaitEvent.Reset(); - - if (!CheckConnection()) - return new List(); - - config = config == null ? new Dictionary() : null; - - //Send data through the socket link - m_LinkIn.SendData(new List() { PackageType.Push, objects.ToList(), config, RevitSettings }, tag); - - //Wait until the return message has been recieved - if (!m_WaitEvent.WaitOne(TimeSpan.FromMinutes(m_WaitTime))) - BH.Engine.Reflection.Compute.RecordError("The connection with Revit timed out. If working on a big model, try to increase the max wait time"); - - //Grab the return objects from the latest package - List returnObjs = m_ReturnPackage.Cast().ToList(); - - //Clear the return list - m_ReturnPackage.Clear(); - - RaiseEvents(); - - //Return the package - return returnObjs; - - } - - /***************************************************/ - - public override IEnumerable Pull(IRequest request, Dictionary config = null) - { - //If internal adapter is loaded call it directly - if (InternalAdapter != null) - { - InternalAdapter.RevitSettings = RevitSettings; - return InternalAdapter.Pull(request, config); - } - - //Reset the wait event - m_WaitEvent.Reset(); - - if (!CheckConnection()) - return new List(); - - config = config == null ? new Dictionary() : null; - - if (!(request is FilterRequest)) - return new List(); - - //Send data through the socket link - m_LinkIn.SendData(new List() { PackageType.Pull, request as FilterRequest, config, RevitSettings }); - - //Wait until the return message has been recieved - if (!m_WaitEvent.WaitOne(TimeSpan.FromMinutes(m_WaitTime))) - Engine.Reflection.Compute.RecordError("The connection with Revit timed out. If working on a big model, try to increase the max wait time"); - - //Grab the return objects from the latest package - List returnObjs = new List(m_ReturnPackage); - - //Clear the return list - m_ReturnPackage.Clear(); - - //Raise returned events - RaiseEvents(); - - //Return the package - return returnObjs; - - } - - /***************************************************/ - - public override int Delete(IRequest request, Dictionary config = null) - { - //If internal adapter is loaded call it directly - if (InternalAdapter != null) - { - InternalAdapter.RevitSettings = RevitSettings; - return InternalAdapter.Delete(request, config); - } - - throw new NotImplementedException(); - } - - /***************************************************/ - public bool IsValid() { if (m_LinkIn == null || m_LinkOut == null) @@ -243,23 +148,6 @@ private void RaiseEvents() m_ReturnEvents = new List(); } - - /***************************************************/ - /**** Protected Methods ****/ - /***************************************************/ - - protected override bool Create(IEnumerable objects) - { - throw new NotImplementedException(); - } - - /***************************************************/ - - protected override IEnumerable Read(Type type, IList ids) - { - throw new NotImplementedException(); - } - /***************************************************/ } } diff --git a/Revit_Adapter/Revit_Adapter.csproj b/Revit_Adapter/Revit_Adapter.csproj index 1f86a90b3..44ec2a672 100644 --- a/Revit_Adapter/Revit_Adapter.csproj +++ b/Revit_Adapter/Revit_Adapter.csproj @@ -30,13 +30,23 @@ 4 + + False + ..\..\BHoM_Adapter\Build\Adapter_Engine.dll + False + + + False + ..\..\BHoM_Adapter\Build\Adapter_oM.dll + False + ..\..\BHoM\Build\BHoM.dll False - + + False ..\..\BHoM_Adapter\Build\BHoM_Adapter.dll - False ..\..\BHoM_Engine\Build\BHoM_Engine.dll @@ -72,7 +82,10 @@ + + + diff --git a/Revit_Engine/Convert/AdapterIdName.cs b/Revit_Engine/Convert/AdapterIdName.cs new file mode 100644 index 000000000..f17826a7d --- /dev/null +++ b/Revit_Engine/Convert/AdapterIdName.cs @@ -0,0 +1,46 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2020, 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 . + */ + +namespace BH.Engine.Adapters.Revit +{ + public static partial class Convert + { + /***************************************************/ + /**** Public Properties ****/ + /***************************************************/ + + public const string AdapterIdName = "Revit_id"; + public const string ElementId = "Revit_elementId"; + public const string WorksetId = "Revit_worksetId"; + public const string SpaceId = "SpaceID"; //FG Change per #191 - ongoing discussion on best use of this still ongoing + public const string AdjacentSpaceId = "AdjacentSpaceID"; //FG Change per #191 - ongoing discussion on best use of this still ongoing + public const string FamilyName = "Revit_familyName"; + public const string FamilyTypeName = "Revit_familyTypeName"; + public const string CategoryName = "Revit_categoryName"; + public const string ViewName = "Revit_viewName"; + public const string Edges = "Revit_edges"; + public const string ViewTemplate = "View Template"; + public const string FamilyPlacementTypeName = "Revit_familyPlacementTypeName"; + + /***************************************************/ + } +} \ No newline at end of file diff --git a/Revit_Engine/Create/Elements/BHoMObject.cs b/Revit_Engine/Create/Elements/BHoMObject.cs index e79c33e24..f0abeefc9 100644 --- a/Revit_Engine/Create/Elements/BHoMObject.cs +++ b/Revit_Engine/Create/Elements/BHoMObject.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020 the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -60,7 +60,7 @@ public static BHoMObject BHoMObject(string uniqueId) }; - obj.CustomData.Add(Convert.AdapterId, uniqueId); + obj.CustomData.Add(Convert.AdapterIdName, uniqueId); return obj; } diff --git a/Revit_Engine/Create/Elements/Panel.cs b/Revit_Engine/Create/Elements/Panel.cs index c391f1c7a..4aac68ccf 100644 --- a/Revit_Engine/Create/Elements/Panel.cs +++ b/Revit_Engine/Create/Elements/Panel.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -65,7 +65,7 @@ public static Panel Panel(ICurve curve, double height, string familyTypeName) PolyCurve polycurve = Geometry.Create.PolyCurve(new ICurve[] { curve, Geometry.Create.Line(minPoint1, maxPoint1) , crv, Geometry.Create.Line(maxPoint2, minPoint2) }); OriginContextFragment originContext = new OriginContextFragment(); - originContext.Origin = Convert.AdapterId; + originContext.Origin = Convert.AdapterIdName; originContext.TypeName = familyTypeName; Panel panel = Environment.Create.Panel(type: PanelType.Wall, externalEdges: polycurve.ToEdges()); diff --git a/Revit_Engine/Modify/RemoveIdentifiers.cs b/Revit_Engine/Modify/RemoveIdentifiers.cs index eb6e7f222..17266d847 100644 --- a/Revit_Engine/Modify/RemoveIdentifiers.cs +++ b/Revit_Engine/Modify/RemoveIdentifiers.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -43,7 +43,7 @@ public static IBHoMObject RemoveIdentifiers(this IBHoMObject bHoMObject) IBHoMObject obj = bHoMObject.GetShallowClone(); - obj.CustomData.Remove(Convert.AdapterId); + obj.CustomData.Remove(Convert.AdapterIdName); obj.CustomData.Remove(Convert.ElementId); return obj; diff --git a/Revit_Engine/Query/Duplicate.cs b/Revit_Engine/Query/Duplicate.cs index b14358ab5..251ea391f 100644 --- a/Revit_Engine/Query/Duplicate.cs +++ b/Revit_Engine/Query/Duplicate.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -34,7 +34,7 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("Duplicates given BHoMObject and removes its identity data (ElementId, AdapterId).")] + [Description("Duplicates given BHoMObject and removes its identity data (ElementId, AdapterIdName).")] [Input("bHoMObject", "BHoMObject")] [Output("BHoMObject")] public static IBHoMObject Duplicate(this IBHoMObject bHoMObject) @@ -45,7 +45,7 @@ public static IBHoMObject Duplicate(this IBHoMObject bHoMObject) IBHoMObject obj = bHoMObject.GetShallowClone(); obj.CustomData.Remove(Convert.ElementId); - obj.CustomData.Remove(Convert.AdapterId); + obj.CustomData.Remove(Convert.AdapterIdName); return obj; diff --git a/Revit_Engine/Query/UniqueId.cs b/Revit_Engine/Query/UniqueId.cs index a7cda7e44..9207dd734 100644 --- a/Revit_Engine/Query/UniqueId.cs +++ b/Revit_Engine/Query/UniqueId.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -42,7 +42,7 @@ public static string UniqueId(this IBHoMObject bHoMObject) return null; object value = null; - if (bHoMObject.CustomData.TryGetValue(Convert.AdapterId, out value)) + if (bHoMObject.CustomData.TryGetValue(Convert.AdapterIdName, out value)) { if (value is string) return (string)value; diff --git a/Revit_Engine/Revit_Engine.csproj b/Revit_Engine/Revit_Engine.csproj index 6001c8f68..325272e86 100644 --- a/Revit_Engine/Revit_Engine.csproj +++ b/Revit_Engine/Revit_Engine.csproj @@ -92,7 +92,7 @@ - + diff --git a/Revit_UI/AdapterActions/Pull.cs b/Revit_UI/AdapterActions/Pull.cs index a0e639c02..6ceef7c77 100644 --- a/Revit_UI/AdapterActions/Pull.cs +++ b/Revit_UI/AdapterActions/Pull.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2018, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -49,7 +49,7 @@ public void Execute(UIApplication app) RevitUIAdapter adapter = listener.GetAdapter(app.ActiveUIDocument.Document); //Push the data - IEnumerable objs = adapter.Pull(listener.LatestRequest, listener.LatestConfig); + IEnumerable objs = adapter.Pull(listener.LatestRequest, oM.Adapter.PullType.AdapterDefault, listener.LatestConfig); //Clear the previous data listener.LatestConfig = null; diff --git a/Revit_UI/AdapterActions/Push.cs b/Revit_UI/AdapterActions/Push.cs index 60291d82b..4ee3e13ef 100644 --- a/Revit_UI/AdapterActions/Push.cs +++ b/Revit_UI/AdapterActions/Push.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2018, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -50,7 +50,7 @@ public void Execute(UIApplication app) RevitUIAdapter adapter = listener.GetAdapter(app.ActiveUIDocument.Document); //Push the data - List objs = adapter.Push(listener.LatestPackage, listener.LatestTag, listener.LatestConfig); + List objs = adapter.Push(listener.LatestPackage, listener.LatestTag, oM.Adapter.PushType.AdapterDefault, listener.LatestConfig); //Clear the lastest package list listener.LatestPackage.Clear(); diff --git a/Revit_UI/RevitListener.cs b/Revit_UI/RevitListener.cs index 9b41e2bfd..638feda97 100644 --- a/Revit_UI/RevitListener.cs +++ b/Revit_UI/RevitListener.cs @@ -1,6 +1,6 @@ /* * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2019, the respective contributors. All rights reserved. + * Copyright (c) 2015 - 2020, the respective contributors. All rights reserved. * * Each contributor holds copyright over their respective contributions. * The project versioning (Git) records all such contribution source information. @@ -27,6 +27,7 @@ using Autodesk.Revit.DB; using Autodesk.Revit.UI; +using BH.oM.Adapters.Revit; using BH.Adapter.Revit; using BH.Adapter.Socket; using BH.oM.Base; @@ -53,7 +54,7 @@ public class RevitListener : IExternalApplication /***************************************************/ - public Dictionary LatestConfig { get; set; } = null; + public RevitConfig LatestConfig { get; set; } = null; /***************************************************/ @@ -240,9 +241,9 @@ private void M_linkIn_DataObservers(oM.Socket.DataPackage package) eve = m_PullEvent; LatestRequest = package.Data[1] as IRequest; break; - case PackageType.UpdateProperty: + case PackageType.UpdateTags: if (!CheckPackageSize(package)) return; - eve = m_UpdatePropertyEvent; + eve = m_UpdateTagsEvent; var tuple = package.Data[1] as Tuple; LatestRequest = tuple.Item1; LatestKeyValuePair = new KeyValuePair(tuple.Item2, tuple.Item3); @@ -253,7 +254,11 @@ private void M_linkIn_DataObservers(oM.Socket.DataPackage package) } LatestTag = package.Tag; - LatestConfig = package.Data[2] as Dictionary; + RevitConfig revitConfig = new RevitConfig(); + revitConfig.MockUpData = package.Data[2]; + LatestConfig = revitConfig; + + //TODO: make sure this works AdapterSettings = package.Data[3] as RevitSettings; } @@ -281,7 +286,7 @@ private bool CheckPackageSize(oM.Socket.DataPackage package) private SocketLink_Tcp m_LinkOut; private ExternalEvent m_PushEvent; private ExternalEvent m_PullEvent; - private ExternalEvent m_UpdatePropertyEvent; + private ExternalEvent m_UpdateTagsEvent; private Dictionary m_Adapters = new Dictionary(); public object m_PackageLock = new object(); diff --git a/Revit_UI/Revit_UI.csproj b/Revit_UI/Revit_UI.csproj index fc4d0ecd9..889e9d7e6 100644 --- a/Revit_UI/Revit_UI.csproj +++ b/Revit_UI/Revit_UI.csproj @@ -117,6 +117,10 @@ Revit_UI_2020 + + False + ..\..\BHoM_Adapter\Build\Adapter_oM.dll + False ..\..\BHoM\Build\BHoM.dll diff --git a/Revit_oM/RevitConfig.cs b/Revit_oM/RevitConfig.cs new file mode 100644 index 000000000..1d01555f6 --- /dev/null +++ b/Revit_oM/RevitConfig.cs @@ -0,0 +1,43 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2020, 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 System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using BH.oM.Adapter; + +namespace BH.oM.Adapters.Revit +{ + public class RevitConfig: ActionConfig + { + /***************************************************/ + /**** Public Properties ****/ + /***************************************************/ + + public object MockUpData { get; set; } = null; + + /***************************************************/ + } +} diff --git a/Revit_oM/Revit_oM.csproj b/Revit_oM/Revit_oM.csproj index b3deec579..09a754ddb 100644 --- a/Revit_oM/Revit_oM.csproj +++ b/Revit_oM/Revit_oM.csproj @@ -31,6 +31,10 @@ 4 + + False + ..\..\BHoM_Adapter\Build\Adapter_oM.dll + ..\..\BHoM\Build\BHoM.dll @@ -66,6 +70,7 @@ + @@ -73,7 +78,7 @@ - + diff --git a/Revit_oM/Settings/UpdateTagsSettings.cs b/Revit_oM/Settings/UpdateTagsSettings.cs new file mode 100644 index 000000000..497cc6775 --- /dev/null +++ b/Revit_oM/Settings/UpdateTagsSettings.cs @@ -0,0 +1,39 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2020, 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 BH.oM.Base; + +namespace BH.oM.Adapters.Revit.Settings +{ + public class UpdateTagsSettings : BHoMObject + { + /***************************************************/ + /**** Public Properties ****/ + /***************************************************/ + + public string ParameterName { get; set; } = null; + public object Value { get; set; } = null; + public static UpdateTagsSettings Default = new UpdateTagsSettings(); + + /***************************************************/ + } +} From e533f6b6eeab75c2202c73dd9f924e1c3ffc3c1f Mon Sep 17 00:00:00 2001 From: Pawel Baran Date: Wed, 15 Jan 2020 10:00:40 +0100 Subject: [PATCH 2/4] Cleanup --- Revit_UI/RevitListener.cs | 6 +++--- Revit_oM/RevitConfig.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Revit_UI/RevitListener.cs b/Revit_UI/RevitListener.cs index 638feda97..21c02f4d5 100644 --- a/Revit_UI/RevitListener.cs +++ b/Revit_UI/RevitListener.cs @@ -254,11 +254,11 @@ private void M_linkIn_DataObservers(oM.Socket.DataPackage package) } LatestTag = package.Tag; + + //TODO: package.Data[2] is useless at the moment RevitConfig revitConfig = new RevitConfig(); - revitConfig.MockUpData = package.Data[2]; LatestConfig = revitConfig; - - //TODO: make sure this works + AdapterSettings = package.Data[3] as RevitSettings; } diff --git a/Revit_oM/RevitConfig.cs b/Revit_oM/RevitConfig.cs index 1d01555f6..ad8034409 100644 --- a/Revit_oM/RevitConfig.cs +++ b/Revit_oM/RevitConfig.cs @@ -36,7 +36,7 @@ public class RevitConfig: ActionConfig /**** Public Properties ****/ /***************************************************/ - public object MockUpData { get; set; } = null; + /***************************************************/ } From cf2c163da1e984e9fe5cbfa0a76a7a81771b8335 Mon Sep 17 00:00:00 2001 From: Alessio Lombardi Date: Wed, 15 Jan 2020 10:07:30 +0000 Subject: [PATCH 3/4] Updated Execute action as per base Adapter changes. As per https://github.com/BHoM/BHoM_Adapter/pull/164/commits/d6517b8c3bccfe2d39f1d3c4e51533779ba16b75 --- Adapter_Revit_UI/AdapterActions/Execute.cs | 18 +++--------------- Adapter_Revit_UI/Adapter_Revit_UI.csproj | 5 +++++ Revit_Adapter/AdapterActions/Execute.cs | 7 ++++--- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Adapter_Revit_UI/AdapterActions/Execute.cs b/Adapter_Revit_UI/AdapterActions/Execute.cs index f3cdd6ddf..c4c643fc4 100644 --- a/Adapter_Revit_UI/AdapterActions/Execute.cs +++ b/Adapter_Revit_UI/AdapterActions/Execute.cs @@ -21,6 +21,7 @@ */ using BH.oM.Adapter; +using BH.oM.Reflection; using System.Collections.Generic; namespace BH.UI.Revit.Adapter @@ -31,23 +32,10 @@ public partial class RevitUIAdapter /**** IAdapter Interface ****/ /***************************************************/ - public override bool Execute(string command, Dictionary parameters = null, ActionConfig actionConfig = null) + public override Output Execute(IExecuteCommand command, ActionConfig actionConfig = null) { - string commandUpper = command.ToUpper(); - - if (commandUpper == "DONOTHING") - return DoNothing(); - - return false; + return null; } - /***************************************************/ - - public bool DoNothing() - { - return true; - } - - /***************************************************/ } } \ No newline at end of file diff --git a/Adapter_Revit_UI/Adapter_Revit_UI.csproj b/Adapter_Revit_UI/Adapter_Revit_UI.csproj index 624413b0d..8c627e96b 100644 --- a/Adapter_Revit_UI/Adapter_Revit_UI.csproj +++ b/Adapter_Revit_UI/Adapter_Revit_UI.csproj @@ -157,6 +157,11 @@ ..\..\BHoM_Engine\Build\Reflection_Engine.dll False + + False + ..\..\BHoM\Build\Reflection_oM.dll + False + ..\libs\2018\RevitAPI.dll False diff --git a/Revit_Adapter/AdapterActions/Execute.cs b/Revit_Adapter/AdapterActions/Execute.cs index f54d7e126..cfd93f709 100644 --- a/Revit_Adapter/AdapterActions/Execute.cs +++ b/Revit_Adapter/AdapterActions/Execute.cs @@ -22,6 +22,7 @@ using BH.oM.Adapter; using BH.oM.Adapters.Revit; +using BH.oM.Reflection; using System.Collections.Generic; namespace BH.Adapter.Revit @@ -32,7 +33,7 @@ public partial class RevitAdapter /**** Public Methods ****/ /***************************************************/ - public override bool Execute(string command, Dictionary parameters = null, ActionConfig actionConfig = null) + public override Output Execute(IExecuteCommand command, ActionConfig actionConfig = null) { //Initialize Revit config RevitConfig revitConfig = actionConfig as RevitConfig; @@ -40,10 +41,10 @@ public override bool Execute(string command, Dictionary paramete if (InternalAdapter != null) { InternalAdapter.RevitSettings = RevitSettings; - return InternalAdapter.Execute(command, parameters, revitConfig); + return InternalAdapter.Execute(command, revitConfig); } - return false; + return null; } /***************************************************/ From 118a493e4a968758ed28e46a6ecf2c57862361e5 Mon Sep 17 00:00:00 2001 From: Alessio Lombardi Date: Thu, 16 Jan 2020 12:03:24 +0000 Subject: [PATCH 4/4] Execute returns `Output, bool>`. Removed unused. --- Adapter_Revit_UI/AdapterActions/Execute.cs | 41 ---------------------- Adapter_Revit_UI/Adapter_Revit_UI.csproj | 1 - Revit_Adapter/AdapterActions/Execute.cs | 2 +- 3 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 Adapter_Revit_UI/AdapterActions/Execute.cs diff --git a/Adapter_Revit_UI/AdapterActions/Execute.cs b/Adapter_Revit_UI/AdapterActions/Execute.cs deleted file mode 100644 index c4c643fc4..000000000 --- a/Adapter_Revit_UI/AdapterActions/Execute.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2020, 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 BH.oM.Adapter; -using BH.oM.Reflection; -using System.Collections.Generic; - -namespace BH.UI.Revit.Adapter -{ - public partial class RevitUIAdapter - { - /***************************************************/ - /**** IAdapter Interface ****/ - /***************************************************/ - - public override Output Execute(IExecuteCommand command, ActionConfig actionConfig = null) - { - return null; - } - - } -} \ No newline at end of file diff --git a/Adapter_Revit_UI/Adapter_Revit_UI.csproj b/Adapter_Revit_UI/Adapter_Revit_UI.csproj index 8c627e96b..e71892749 100644 --- a/Adapter_Revit_UI/Adapter_Revit_UI.csproj +++ b/Adapter_Revit_UI/Adapter_Revit_UI.csproj @@ -214,7 +214,6 @@ - diff --git a/Revit_Adapter/AdapterActions/Execute.cs b/Revit_Adapter/AdapterActions/Execute.cs index cfd93f709..664bfe244 100644 --- a/Revit_Adapter/AdapterActions/Execute.cs +++ b/Revit_Adapter/AdapterActions/Execute.cs @@ -33,7 +33,7 @@ public partial class RevitAdapter /**** Public Methods ****/ /***************************************************/ - public override Output Execute(IExecuteCommand command, ActionConfig actionConfig = null) + public override Output, bool> Execute(IExecuteCommand command, ActionConfig actionConfig = null) { //Initialize Revit config RevitConfig revitConfig = actionConfig as RevitConfig;