From 9c7818ea85e4656fab79d4340ba308cabd06db01 Mon Sep 17 00:00:00 2001 From: Michal Pekacki Date: Wed, 2 Sep 2026 12:12:08 +0200 Subject: [PATCH] upgade placement settings added --- BHoMUpgrades/CustomUpgrades/v93.cs | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/BHoMUpgrades/CustomUpgrades/v93.cs b/BHoMUpgrades/CustomUpgrades/v93.cs index 41af7c4..9d339fe 100644 --- a/BHoMUpgrades/CustomUpgrades/v93.cs +++ b/BHoMUpgrades/CustomUpgrades/v93.cs @@ -21,6 +21,7 @@ */ using BH.oM.Versioning; +using System; using System.Collections.Generic; namespace BH.Upgraders @@ -114,6 +115,62 @@ public static Dictionary UpgradeAreaTagSettings(Dictionary UpgradePlacementSettings(Dictionary oldVersion) + { + if (oldVersion == null) + return null; + + Dictionary newVersion = new Dictionary(oldVersion); + + if (newVersion.ContainsKey("PlacementCollections")) + { + newVersion.Remove("ElementPlacementSettings"); + return newVersion; + } + + if (!newVersion.TryGetValue("ElementPlacementSettings", out object oldPlacementsObject)) + return newVersion; + + List placements = new List(); + IEnumerable oldPlacements = oldPlacementsObject as IEnumerable; + if (oldPlacements != null) + { + foreach (object item in oldPlacements) + { + if (item is Dictionary placementDict) + { + if (placementDict.TryGetValue("_t", out object type) && + type?.ToString() == "BH.Revit.oM.ElementRelationships.ElementPlacementSettings") + { + placementDict["_t"] = "BH.Revit.oM.ElementRelationships.ElementPlacement"; + } + + placements.Add(placementDict); + } + else + { + placements.Add(item); + } + } + } + + Dictionary defaultCollection = new Dictionary + { + { "_t", "BH.Revit.oM.ElementRelationships.PlacementCollection" }, + { "BHoM_Guid", Guid.NewGuid() }, + { "Name", "Default Collection" }, + { "Placements", placements } + }; + + newVersion["PlacementCollections"] = new List { defaultCollection }; + newVersion.Remove("ElementPlacementSettings"); + + return newVersion; + } + /***************************************************/ /**** Private Methods ****/ /***************************************************/