Converter.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:Converter
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/17 12:01:36
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using JBIM;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using JBIM.Definition;
  14. using SAGA.RevitUtils.Extends;
  15. namespace RevitToJBim.Common
  16. {
  17. public static class BimConvert
  18. {
  19. public static readonly int CoordinateDecimalDigits = 2;
  20. public static double Round(double coordinateDecimal)
  21. {
  22. return Math.Round(coordinateDecimal, CoordinateDecimalDigits);
  23. }
  24. /// <summary>
  25. /// 英尺转换成现在阶段使用单位
  26. /// </summary>
  27. /// <param name="footValue"></param>
  28. /// <returns></returns>
  29. public static double FtToUse(this double footValue)
  30. {
  31. return Round(footValue.FromApi());
  32. }
  33. /// <summary>
  34. /// 将点转换成毫米单位形式
  35. /// </summary>
  36. /// <param name="xyz"></param>
  37. /// <returns></returns>
  38. public static XYZ ConvertToXYZ(Autodesk.Revit.DB.XYZ xyz)
  39. {
  40. return new XYZ() {X = FtToUse(xyz.X), Y = FtToUse(xyz.Y), Z = FtToUse(xyz.Z), };
  41. }
  42. /// <summary>
  43. /// 将点转换成毫米单位形式
  44. /// </summary>
  45. /// <param name="xyzes"></param>
  46. /// <returns></returns>
  47. public static List<XYZ> ConvertToXYZs(List<Autodesk.Revit.DB.XYZ> xyzs)
  48. {
  49. return xyzs.Select(xyz=>ConvertToXYZ(xyz)).ToList();
  50. }
  51. }
  52. }