Very Strange Temperature Conversion

I’m trying to put F into a family parameter but when I put 180 in it came up with a huge number. I tried messing around and eventually got this code to work. Does anyone know why this is happening? I was expecting to need to convert it to K but I’m not aware of what the below formula is converting it to.
Temperature%20conversion%2001

Hi crapai
Try this formula to convert from Fahrenheit to Kelvin


Converting it to Kelvin was the first thing I tried and like I said it didn’t come up with the correct answer. This is the F I get when I converted it to K.Temperature%20conversion%2002

The formula I posted in the original post is the one that gets me the accurate F in the revit family. I was wondering what revit wants here because it is not K.

Would you be able to upload the FamilyType or, if it contains proprietary info, a version that has the specific parameter you’re trying to write to?

JDRM - Radiant Ceiling Panel.rfa (368 KB)

Yeah, there’s something weird with Dynamo.
In Revit it works fine, when I switch from F° to C° to K°, the value is converted correctly.

In Dynamo when I have Kelvin it’s coherent:

But when I switch to C° or F° I need to reconnect the nodes and the value shown in Element.Parameter is correct, while with Element.GetParameterValueByName I get a weird number (both cases, C° and F° around 1,3).

I ran my own tests and came up with the same answer as @lucamanzoni
Accessing the values straight through the API yields correct values, however…

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

element = UnwrapElement(IN[0])
param_name = IN[1]

param = element.LookupParameter(param_name)
param_dut = param.DisplayUnitType
param_ut = param.Definition.UnitType
valid_dut = UnitUtils.GetValidDisplayUnits(param_ut)

dut_f = DisplayUnitType.DUT_FAHRENHEIT
dut_c = DisplayUnitType.DUT_CELSIUS
dut_k = DisplayUnitType.DUT_KELVIN
dut_r = DisplayUnitType.DUT_RANKINE

val_internal = param.AsDouble()
val_convert_f = UnitUtils.ConvertFromInternalUnits(val_internal, dut_f)
val_convert_c = UnitUtils.ConvertFromInternalUnits(val_internal, dut_c)
val_convert_k = UnitUtils.ConvertFromInternalUnits(val_internal, dut_k)
val_convert_r = UnitUtils.ConvertFromInternalUnits(val_internal, dut_r)

OUT = [[dut_f, val_convert_f],
	   [dut_c, val_convert_c],
	   [dut_k, val_convert_k],
	   [dut_r, val_convert_r],
	   ['INTERNAL', val_internal]]

Internal Units.dyn (6.9 KB)

This is showing that the value is stored internally in Kelvin, which aligns with what is stated on Autodesk’s website. None of the values for valid display unit types (fahrenheit, celsius, kelvin, rankine) are anywhere near the ~1.3 value.

2 Likes

Ran some more tests and now I’m even more confused. I changed my project’s units to metric and tried a few things…

Setting the temperature in Celsius within Revit yields expected results:
0 C -> 273.15 K
100 C -> 373.15 K
200 C -> 473.15 K

I then tried setting the parameter’s value within Dynamo:
Set to 1 -> Yields 1 C in Revit
Set to 2 -> Yields 275.15 C in Revit
Set to 3 -> Yields 549.3 C in Revit
Set to 4 -> Yields 823.45 C in Revit
Set to 5 -> Yields 1097.6 C in Revit

Take the below equation where x is the value we are providing in Dynamo:
f(x) = 273.15 * (x-1) + x

f(3) = 273.15 * (3-1) + 3
     = 273.15 * (2) + 3
     = 546.3 + 3
     = 549.3

Looks like you came to the same formula that I did except with Celsius.

I noticed that:
1 = 1
2 = 461.67
3 = 922.34

This eventually led to the formula in my OP.

Looks like what dynamo is doing may be based on the rankine scale since 1 fahrenheit is 460.67 on the rankine scale. It’s not converting it to Rankine, but it is somehow related to it.