123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /*-------------------------------------------------------------------------
- * 功能描述:Converter
- * 作者:xulisong
- * 创建时间: 2019/6/17 12:01:36
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using JBIM;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using JBIM.Definition;
- using SAGA.RevitUtils.Extends;
- namespace RevitToJBim.Common
- {
- public static class BimConvert
- {
- public static readonly int CoordinateDecimalDigits = 2;
- public static double Round(double coordinateDecimal)
- {
- return Math.Round(coordinateDecimal, CoordinateDecimalDigits);
- }
- /// <summary>
- /// 英尺转换成现在阶段使用单位
- /// </summary>
- /// <param name="footValue"></param>
- /// <returns></returns>
- public static double FtToUse(this double footValue)
- {
- return Round(footValue.FromApi());
- }
- /// <summary>
- /// 将点转换成毫米单位形式
- /// </summary>
- /// <param name="xyz"></param>
- /// <param name="ignoreZ">转换是否忽略Z</param>
- /// <returns></returns>
- public static XYZ ConvertToXYZ(Autodesk.Revit.DB.XYZ xyz,bool ignoreZ=false)
- {
- if (xyz == null) return null;
- var result = new XYZ()
- {
- X = FtToUse(xyz.X),
- Y = FtToUse(xyz.Y)
- };
- if (!ignoreZ)
- {
- result.Z = FtToUse(xyz.Z);
- }
- return result;
- }
- /// <summary>
- /// 转换成向量
- /// </summary>
- /// <param name="xyz"></param>
- /// <returns></returns>
- public static XYZ ConvertToDirection(Autodesk.Revit.DB.XYZ xyz)
- {
- return new XYZ() { X = xyz.X, Y = xyz.Y, Z = xyz.Z, };
- }
- /// <summary>
- /// 将点转换成毫米单位形式
- /// </summary>
- /// <param name="xyzs"></param>
- /// <param name="ignoreZ">转换是否忽略Z</param>
- /// <returns></returns>
- public static List<XYZ> ConvertToXYZs(List<Autodesk.Revit.DB.XYZ> xyzs, bool ignoreZ=false)
- {
- return xyzs.Select(xyz=>ConvertToXYZ(xyz, ignoreZ)).Where(t=>t!=null).ToList();
- }
-
- }
- }
|