<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unit converted parameter value not matching parsed string value in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11350466#M17554</link>
    <description>&lt;P&gt;You need to add some fuzz:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.google.com/search?q=fuzz&amp;amp;as_sitesearch=thebuildingcoder.typepad.com" target="_blank"&gt;https://www.google.com/search?q=fuzz&amp;amp;as_sitesearch=thebuildingcoder.typepad.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Aug 2022 06:04:31 GMT</pubDate>
    <dc:creator>jeremy_tammik</dc:creator>
    <dc:date>2022-08-10T06:04:31Z</dc:date>
    <item>
      <title>Unit converted parameter value not matching parsed string value</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11350164#M17553</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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&amp;nbsp;&lt;STRONG&gt;WW_Width&lt;/STRONG&gt; 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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;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}");
		}
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what my console shows as a result but I don't get why I'm getting a mismatch.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;WW_Width
UnitType: UT_Length
StorageType: Double

Value: 2448
Parsed string: 2448
Values match: False&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 01:27:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11350164#M17553</guid>
      <dc:creator>floretti</dc:creator>
      <dc:date>2022-08-10T01:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Unit converted parameter value not matching parsed string value</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11350466#M17554</link>
      <description>&lt;P&gt;You need to add some fuzz:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.google.com/search?q=fuzz&amp;amp;as_sitesearch=thebuildingcoder.typepad.com" target="_blank"&gt;https://www.google.com/search?q=fuzz&amp;amp;as_sitesearch=thebuildingcoder.typepad.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 06:04:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11350466#M17554</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2022-08-10T06:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Unit converted parameter value not matching parsed string value</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11353053#M17555</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;&amp;nbsp;Thanks for the steer in the right direction. I wasn't aware of that issue with doubles/floats. Instead of directly comparing the doubles, I'm subtracting one from the other and checking if the difference is under a certain tolerance (e.g. A - B &amp;lt; 0.001) and that works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/1398753/comparing-double-values-in-c-sharp" target="_blank" rel="noopener"&gt;This article&lt;/A&gt; explains it well in case anyone faces this issue in the future.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 07:31:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11353053#M17555</guid>
      <dc:creator>floretti</dc:creator>
      <dc:date>2022-08-11T07:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Unit converted parameter value not matching parsed string value</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11353185#M17556</link>
      <description>&lt;P&gt;Brilliant! Glad that it helped, and thank you for the appreciation and nice helpful pointer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 09:04:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11353185#M17556</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2022-08-11T09:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Unit converted parameter value not matching parsed string value</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11353394#M17557</link>
      <description>&lt;P&gt;I'm always very thankful to these forums and the help I get here as I have no one around me to ask these questions to when I'm stuck.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 11:23:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/unit-converted-parameter-value-not-matching-parsed-string-value/m-p/11353394#M17557</guid>
      <dc:creator>floretti</dc:creator>
      <dc:date>2022-08-11T11:23:55Z</dc:date>
    </item>
  </channel>
</rss>

