- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
Thanks for your time first of all. Strictly speaking this is not a Revit API issue I'm facing but after some research I couldn't find the answer here or anywhere else but it's still a challenge related to Revit.
I'm comparing a family parameter value with values in a spreadsheet so I can update the parameter accordingly if they don't match but I'm getting weird results when comparing them. The snippet below shows how I'm extracting the double value of the WW_Width parameter and converting it to millimetres. Then I compare it to the a parsed string with the exact same value as a double but I get a false result to whether or not they match.
var famPars = doc.FamilyManager.Parameters;
var famTypes = doc.FamilyManager.Types;
foreach (FamilyParameter param in famPars)
{
foreach (FamilyType famtype in famTypes)
{
if (param.Definition.Name == "WW_Width")
{
console.ShowBoldMessage("WW_Width");
console.ShowMessage($"UnitType: {param.Definition.UnitType}");
console.ShowMessage($"StorageType: {param.StorageType}\n");
double valueInMM = UnitUtils.ConvertFromInternalUnits((double)famtype.AsDouble(param),
DisplayUnitType.DUT_MILLIMETERS);
double parsedString = double.Parse("2448");
console.ShowMessage($"Value: {valueInMM}");
console.ShowMessage($"Parsed string: {parsedString}");
console.ShowMessage($"Values match: {valueInMM == parsedString}");
}
}
}
This is what my console shows as a result but I don't get why I'm getting a mismatch.
WW_Width
UnitType: UT_Length
StorageType: Double
Value: 2448
Parsed string: 2448
Values match: False
Solved! Go to Solution.