NewFamilyInstance location as millmeter

NewFamilyInstance location as millmeter

kmkxperia
Advocate Advocate
657 Views
3 Replies
Message 1 of 4

NewFamilyInstance location as millmeter

kmkxperia
Advocate
Advocate

I am creating the wall Opening using NewFamilyInstance(location, familySymbol, wall, level, StructuralType.NonStructural) but I am facing one issue

 

Location that it takes looks like is taking in Feets ie X(10,10,0) but my template is in Metric now I am finding it difficult to put the Opening at the exact Position on the wall.

i tried Dividing the coordinates with 304.8 to convert it to feet but no luck.

Check the attached image for the Location I am looking on the wall.Cordinate.png

Accepted solutions (1)
658 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk
Accepted solution

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/U...

 

    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



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

Message 3 of 4

aignatovich
Advisor
Advisor

Hi!

 

What about UnitUtils.ConvertFromInternalUnits and UnitUtils.ConvertToInternalUnits methods?

 

They are very useful, I didn' convert values on myself since Revit 2014 released

0 Likes
Message 4 of 4

jeremytammik
Autodesk
Autodesk

Thank you for pointing them out!

 

Here is a discussion of an issue with them including some sample code:

 

http://thebuildingcoder.typepad.com/blog/2016/08/unitutils-converting-units-for-unit-weight.html

 

Cheers,

 

Jeremy



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

0 Likes