Conversion from Revit Units

Conversion from Revit Units

dem1st
Enthusiast Enthusiast
947 Views
2 Replies
Message 1 of 3

Conversion from Revit Units

dem1st
Enthusiast
Enthusiast

Is Area double on Integer? How to get the right number (when exporting to Excel) ? For now it is either random number or 0.

 

//in this case the output is not square meters but some other number

List<double> _pArea = new List<double>();
foreach (Element e in _elementsDB)
{ _pArea.Add(UnitUtils.ConvertToInternalUnits(e.LookupParameter("Area").AsDouble(), DisplayUnitType.DUT_SQUARE_METERS));
}

//in this case the output is 0

List<int> _pAreaInt = new List<int>();
foreach (Element e in _elementsDB)
{
_pAreaInt.Add(e.LookupParameter("Area").AsInteger());
}

 

0 Likes
948 Views
2 Replies
Replies (2)
Message 2 of 3

Omar_Amen
Advocate
Advocate

Hi @dem1st ,
the unit that the Revit API uses is Feet so the value of your area should be in square feets!
you can convert it easly to m2,mm2,...etc
manually or by
public static class UnitUtils 
retrieve the value using
public string AsValueString( FormatOptions formatOptions ) 
then check it first in debugging
if it not equals "0"
then you can parse it to int or double...etc

Message 3 of 3

Omar_Amen
Advocate
Advocate

@dem1st  may you also try 
ConvertFromInternalUnits( 
instead of 
ConvertToInternalUnits(