Quantcast
Channel: All Revit API Forum posts
Viewing all articles
Browse latest Browse all 67020

Re: NewFamilyInstance location as millmeter

$
0
0

All length related Revit database units use imperial units, i.e., feet, so that part is trivial and a non-issue:

 

http://thebuildingcoder.typepad.com/blog/2011/03/internal-imperial-units.html

 

I regularly convert back and forth to millimetres, as you can see from the following lines from The Building Coder samples::

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/Util.cs#L579-L624

 

    const double _inchToMm = 25.4;
    const double _footToMm = 12 * _inchToMm;
    const double _footToMeter = _footToMm * 0.001;

    const double _cubicFootToCubicMeter
      = _footToMeter * _footToMeter * _footToMeter;

    /// <summary>
    /// Convert a given length in feet to millimetres.
    /// </summary>
    public static double FootToMm( double length )
    {
      return length * _footToMm;
    }

    /// <summary>
    /// Convert a given length in feet to metres.
    /// </summary>
    public static double FootToMetre( double length )
    {
      return length * _footToMeter;
    }

    /// <summary>
    /// Convert a given length in millimetres to feet.
    /// </summary>
    public static double MmToFoot( double length )
    {
      return length / _footToMm;
    }

    /// <summary>
    /// Convert a given point or vector from millimetres to feet.
    /// </summary>
    public static XYZ MmToFoot( XYZ v )
    {
      return v.Divide( _footToMm );
    }

    /// <summary>
    /// Convert a given volume in feet to cubic meters.
    /// </summary>
    public static double CubicFootToCubicMeter( double volume )
    {
      return volume * _cubicFootToCubicMeter;
    }

 

Does any kind of problem remain after you have converted your units to feet?

 

If so, please raise a new issue for that, and never mention millimetres again when dealing with the Revit API  :-)

 

Thank you!

 

Cheers,

 

Jeremy


Viewing all articles
Browse latest Browse all 67020

Latest Images

Trending Articles



Latest Images