Skip to content

Versioning added for RevitParameter #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions BHoMUpgrader82/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@
*/

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using BH.Upgrader.Base;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace BH.Upgrader.v82
{
Expand All @@ -42,6 +35,7 @@ public Converter() : base()
{
PreviousVersion = "8.1";
ToNewObject.Add("BH.oM.Security.Elements.CameraDevice", UpgradeCameraDevice);
ToNewObject.Add("BH.oM.Adapters.Revit.Parameters.RevitParameter", UpgradeRevitParameter);
}

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

if (oldVersion.ContainsKey("EyePosition") && oldVersion.ContainsKey("TargetPosition"))
{
var ptA = oldVersion["EyePosition"] as Dictionary<string, object>;
var ptB = oldVersion["TargetPosition"] as Dictionary<string, object>;
Dictionary<string, object> ptA = oldVersion["EyePosition"] as Dictionary<string, object>;
Dictionary<string, object> ptB = oldVersion["TargetPosition"] as Dictionary<string, object>;
if (ptA != null && ptB != null)
distance = DistanceBetweenPoints(ptA, ptB);
}
Expand Down Expand Up @@ -97,5 +91,32 @@ private static double DistanceBetweenPoints(Dictionary<string, object> pt1, Dict
}

/***************************************************/

private static Dictionary<string, object> UpgradeRevitParameter(Dictionary<string, object> oldVersion)
{
Dictionary<string, object> newVersion = new Dictionary<string, object>(oldVersion);
if (newVersion.ContainsKey("UnitType"))
{
newVersion["Quantity"] = newVersion["UnitType"];
newVersion.Remove("UnitType");
}
else
newVersion["Quantity"] = "";

newVersion["Unit"] = "";

if (!newVersion.ContainsKey("Name"))
newVersion["Name"] = "";

if (!newVersion.ContainsKey("Value"))
newVersion["Value"] = null;

if (!newVersion.ContainsKey("IsReadOnly"))
newVersion["IsReadOnly"] = false;

return newVersion;
}

/***************************************************/
}
}
Loading