CorrectionFactor.Temperature fails when project does not use °F

CorrectionFactor.Temperature fails when project does not use °F

mhannonQ65N2
Collaborator Collaborator
727 Views
5 Replies
Message 1 of 6

CorrectionFactor.Temperature fails when project does not use °F

mhannonQ65N2
Collaborator
Collaborator

When the document does not use °F for HVAC Temperature, the property Autodesk.Revit.DB.Electrical.CorrectionFactor.Temperature throws the following exeption.

 

Autodesk.Revit.Exceptions.InvalidOperationException
  HResult=0x80131500
  Message=Can't find temperature unit 'F'.
  Source=RevitAPI
  StackTrace:
   at Autodesk.Revit.DB.Electrical.CorrectionFactor.get_Temperature()
   at Namespace.MyClass..ctor(CorrectionFactor correctionFactor, ...) in C:\Folders\MyClass.cs:line {number}

 

The exception has a FunctionId property with the following values.

 

FunctionId	{Autodesk.Revit.Exceptions.FunctionId}	Autodesk.Revit.Exceptions.FunctionId
	File	"d:\\ship\\2019_px64\\source\\api\\revitapi\\objects\\mep\\APIWireType.cpp"	string
	Function	"Autodesk::Revit::DB::Electrical::CorrectionFactor::Temperature::get"	string
	Line	965	int

 

 

When HVAC Temperature is configured to display multiple decimal places, it throws this exception:

 

System.FormatException
  HResult=0x80131537
  Message=Input string was not in a correct format.
  Source=mscorlib
  StackTrace:
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
   at Autodesk.Revit.DB.Electrical.CorrectionFactor.get_Temperature()
   at Namespace.MyClass..ctor(CorrectionFactor correctionFactor, ...) in C:\Folders\MyClass.cs:line {number}

  This exception was originally thrown at this call stack:
    System.Number.StringToNumber(string, System.Globalization.NumberStyles, ref System.Number.NumberBuffer, System.Globalization.NumberFormatInfo, bool)
    System.Number.ParseInt64(string, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo)
    Autodesk.Revit.DB.Electrical.CorrectionFactor.Temperature.get()
    Namespace.MyClass..ctor(CorrectionFactor correctionFactor, ...) in C:\Folders\MyClass.cs:line {number}

 

 

Here's a potential minimum reproducible case, assuming that there's a property/field Document of type Autodesk.Revit.DB.Document (so perhaps in a macro).

 

long temperature = Document.Settings.ElectricalSetting.WireMaterialTypes
	.Cast<WireMaterialType>()
	.First()
	.TemperatureRatings
	.Cast<TemperatureRatingType>()
	.First()
	.CorrectionFactors
	.Cast<CorrectionFactor>()
	.First()
	.Temperature;

 

 

0 Likes
728 Views
5 Replies
Replies (5)
Message 2 of 6

jfaulkner-evolve
Enthusiast
Enthusiast

What is the Autodesk recommended solution for situation?

0 Likes
Message 3 of 6

jeremytammik
Autodesk
Autodesk

Dear Matthew,

 

Thank you for your report and very clear and succinct reproducible case. Sorry I didn't notice it earlier.

 

Thanks also to Jason for pointing out this thread and escalating it to the Autodesk DAS (Developer Advocacy and Support) developer support queue as ticket #16642407 [CorrectionFactor.Temperature fails when project does not use degrees Fahrenheit].

 

Sorry to hear about this.

 

I tested the behaviour you report and can reproduce it. I attached a zip file containing a complete minimal add-in source code and solution file screen as well as snapshots of the exception thrown in the Visual Studio debugger and reported back via the add-in to Revit.

 

I logged the issue REVIT-163864 [CorrectionFactor.Temperature throws when not using degrees Fahrenheit -- 16642407] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Best regards,

 

Jeremy

  



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 4 of 6

tyler_gorton
Observer
Observer

I am working with Revit 2022 and still seeing this problem. Any chance this is fixed in an upcoming patch and for later versions?

0 Likes
Message 5 of 6

ricaun
Advisor
Advisor

I know WireSize.Ampacity have some problem as well because is a long type, and if your document unit for the Ampacity have accuracy like 0.01, the WireSize.Ampacity throws exception.

 

But if you change the unit in the project before access the WireSize.Ampacity, the issue does not happen and I rollback the accuracy after.

 

I suppose you can do the same for the CorrectionFactor.Temperature problem, as a workaround.

 

In Revit 2026 the WireType and others became Obsolete.

 

CorrectionFactor is deprecated in Revit 2026 and will be removed in a future version of Revit. There is no replacement because Revit no longer supports this.

 

I guess the Autodesk patch was to delete everything. 😂

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 6 of 6

tyler_gorton
Observer
Observer

thanks for the info, ricuan. i ended up finding that another exception is thrown if there are no correction factors defined for a material's temperature rating. i think half my code is now try-catch blocks!

0 Likes