Skip to content

Commit f64c626

Browse files
authored
Versioning added for RevitParameter (#300)
2 parents 85442e9 + 8776cec commit f64c626

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

BHoMUpgrader82/Converter.cs

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@
2121
*/
2222

2323
using System;
24-
using System.Collections;
2524
using System.Collections.Generic;
26-
using System.ComponentModel;
27-
using System.Linq;
28-
using System.Text;
29-
using BH.Upgrader.Base;
30-
using System.Threading.Tasks;
31-
using System.Xml.Linq;
3225

3326
namespace BH.Upgrader.v82
3427
{
@@ -42,6 +35,7 @@ public Converter() : base()
4235
{
4336
PreviousVersion = "8.1";
4437
ToNewObject.Add("BH.oM.Security.Elements.CameraDevice", UpgradeCameraDevice);
38+
ToNewObject.Add("BH.oM.Adapters.Revit.Parameters.RevitParameter", UpgradeRevitParameter);
4539
}
4640

4741
/***************************************************/
@@ -65,8 +59,8 @@ private static Dictionary<string, object> UpgradeCameraDevice(Dictionary<string,
6559

6660
if (oldVersion.ContainsKey("EyePosition") && oldVersion.ContainsKey("TargetPosition"))
6761
{
68-
var ptA = oldVersion["EyePosition"] as Dictionary<string, object>;
69-
var ptB = oldVersion["TargetPosition"] as Dictionary<string, object>;
62+
Dictionary<string, object> ptA = oldVersion["EyePosition"] as Dictionary<string, object>;
63+
Dictionary<string, object> ptB = oldVersion["TargetPosition"] as Dictionary<string, object>;
7064
if (ptA != null && ptB != null)
7165
distance = DistanceBetweenPoints(ptA, ptB);
7266
}
@@ -97,5 +91,32 @@ private static double DistanceBetweenPoints(Dictionary<string, object> pt1, Dict
9791
}
9892

9993
/***************************************************/
94+
95+
private static Dictionary<string, object> UpgradeRevitParameter(Dictionary<string, object> oldVersion)
96+
{
97+
Dictionary<string, object> newVersion = new Dictionary<string, object>(oldVersion);
98+
if (newVersion.ContainsKey("UnitType"))
99+
{
100+
newVersion["Quantity"] = newVersion["UnitType"];
101+
newVersion.Remove("UnitType");
102+
}
103+
else
104+
newVersion["Quantity"] = "";
105+
106+
newVersion["Unit"] = "";
107+
108+
if (!newVersion.ContainsKey("Name"))
109+
newVersion["Name"] = "";
110+
111+
if (!newVersion.ContainsKey("Value"))
112+
newVersion["Value"] = null;
113+
114+
if (!newVersion.ContainsKey("IsReadOnly"))
115+
newVersion["IsReadOnly"] = false;
116+
117+
return newVersion;
118+
}
119+
120+
/***************************************************/
100121
}
101122
}

0 commit comments

Comments
 (0)