using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.DB; using Szmedi.Toolkit.Revit.Approval; namespace Szmedi.RevitToolkit.Approval.Assists { internal static class ParameterAssists { /// /// 获取标识 /// /// /// public static string GetIdProperty(this Element e) { var list = e.GetParameters("深圳构件标识"); var str = string.Empty; if (list.Count > 0) { foreach (var param in list) { if (param.AsString() != string.Empty) { str = param.AsString(); } } return str == string.Empty ? "未填写标识" : str; } return "未定义标识"; } ///// ///// 公式计算结果 ///// ///// ///// ///// //public static double EvaluateFormula(string formula, Dictionary parameters) //{ // double result = default; // try // { // var e = new NCalc.Expression(formula); // e.Parameters = parameters; // var obj = e.Evaluate(); // result = Convert.ToDouble(obj); // } // catch (Exception ex) // { // } // return result; //} public static ParameterType GetParameterType(this MetroCommonParameter property) { if (property.ParamType == "文本") { return ParameterType.Text; } else if (property.ParamType == "数值") { if (property.Unit == "mm") { return ParameterType.Length; } else if (property.Unit is "年" or "月" or "日") { return ParameterType.Integer; } else if (property.Unit is "元" or "万元") { return ParameterType.Currency; } return ParameterType.Number; } return ParameterType.Text; } } }