public static string FamilyParamValueString(FamilyType t, FamilyParameter fp, Document doc) { string value = t.AsValueString(fp); switch (fp.StorageType) { case StorageType.Double: value = t.AsValueString(fp); break; /* case StorageType.ElementId: * ElementId id = t.AsElementId(fp); * Element e = doc.GetElement(id); * value = id.IntegerValue.ToString() + " (" + e.Name + ")"; * break;*/ case StorageType.Integer: value = t.AsInteger(fp).ToString(); break; case StorageType.String: value = t.AsString(fp); break; } return(value); }
public static bool CheckID(this Document doc) { string v = string.Empty; if (doc.IsFamilyDocument) { if (doc.FamilyManager.get_Parameter(ProjectParams.CC_ID.Guid) != null) { FamilyParameter p = doc.FamilyManager.get_Parameter(ProjectParams.CC_ID.Guid); FamilyType t = doc.FamilyManager.CurrentType; try { v = t.AsString(p); } catch { } } } else { if (doc.ProjectInformation.get_Parameter(ProjectParams.CC_ID.Guid) != null) { Parameter p = doc.ProjectInformation.get_Parameter(ProjectParams.CC_ID.Guid); try { v = p.AsString(); } catch { } } } if (v == string.Empty) { return(false); } if (v == null) { return(false); } if (v.Length < 30) { return(false); } return(true); }
static string FamilyParamValueString( FamilyType t, FamilyParameter fp, Document doc) { string value = t.AsValueString(fp); switch (fp.StorageType) { case StorageType.Double: value = Util.RealString( (double)t.AsDouble(fp)) + " (double)"; break; case StorageType.ElementId: ElementId id = t.AsElementId(fp); Element e = doc.GetElement(id); value = id.IntegerValue.ToString() + " (" + Util.ElementDescription(e) + ")"; break; case StorageType.Integer: value = t.AsInteger(fp).ToString() + " (int)"; break; case StorageType.String: value = "'" + t.AsString(fp) + "' (string)"; break; } return(value); }
public static string ParameterToString(Document doc, FamilyParameter param, FamilyType type) { if (!type.HasValue(param)) { return("无"); } if (param.Definition.ParameterType == ParameterType.Invalid) { return("不可用"); } switch (param.StorageType) { case StorageType.Double: #if R2014 var uStr = FormatUtils.Format(doc, param.Definition.UnitType, type.AsDouble(param).Value); #else var uStr = UnitFormatUtils.Format(doc.GetUnits(), param.Definition.UnitType, type.AsDouble(param).Value, false, false); #endif return(uStr); //var uStr = string.Empty; //if (param.Definition.ParameterType == ParameterType.Length) //{ // uStr = GetParamaterUnit(param.DisplayUnitType); //} //var dStr = param.AsValueString(); //if (!String.IsNullOrEmpty(uStr) && !dStr.EndsWith(uStr)) dStr += uStr; //return dStr; case StorageType.Integer: var v = type.AsInteger(param).Value; if (param.Definition.ParameterType == ParameterType.YesNo) { if (v == 0) { return("否"); } return("是"); } #if R2014 return(FormatUtils.Format(doc, param.Definition.UnitType, v)); #else return(UnitFormatUtils.Format(doc.GetUnits(), param.Definition.UnitType, v, false, false)); #endif case StorageType.String: return(type.AsString(param)); case StorageType.ElementId: ElementId idVal = type.AsElementId(param); return(AsElementName(doc, idVal)); case StorageType.None: default: return("无"); } }
public FamilyParameterValueWrapper(FamilyParameter parameter, FamilyType familyType, Document doc) { _parameter = parameter; _familyType = familyType; _doc = doc; // Значение параметра \"{parameter.Definition.Name}\" Title = string.Format(Language.GetItem(ModPlusConnector.Instance.Name, "p4"), parameter.Definition.Name); ParameterName = parameter.Definition.Name; FamilyTypeName = familyType.Name; switch (parameter.StorageType) { case StorageType.String: Source = familyType.AsString(parameter); break; case StorageType.Integer: Source = familyType.AsInteger(parameter).ToString(); break; case StorageType.Double: var d = familyType.AsDouble(parameter); if (d.HasValue) { Source = UnitUtils.ConvertFromInternalUnits( d.Value, #if R2017 || R2018 || R2019 || R2020 parameter.DisplayUnitType) #else parameter.GetUnitTypeId()) #endif .ToString(CultureInfo.InvariantCulture); } break; } Destination = string.Empty; }
private static string GetParameterValue(this FamilyType t, FamilyParameter p) { string paramValue = null; switch (p.StorageType) { case StorageType.Integer: if (ParameterType.YesNo == p.Definition.ParameterType) { if (t.AsInteger(p) == 1) { paramValue = "YES"; } else { paramValue = "NO"; } } else { paramValue = t.AsValueString(p); } break; case StorageType.Double: paramValue = t.AsValueString(p); break; case StorageType.String: paramValue = t.AsString(p); break; default: paramValue = null; break; } return(paramValue); }
static string FamilyParamValueString( FamilyType t, FamilyParameter fp, Document doc) { string value = t.AsValueString( fp ); switch( fp.StorageType ) { case StorageType.Double: value = Util.RealString( ( double ) t.AsDouble( fp ) ) + " (double)"; break; case StorageType.ElementId: ElementId id = t.AsElementId( fp ); Element e = doc.GetElement( id ); value = id.IntegerValue.ToString() + " (" + Util.ElementDescription( e ) + ")"; break; case StorageType.Integer: value = t.AsInteger( fp ).ToString() + " (int)"; break; case StorageType.String: value = "'" + t.AsString( fp ) + "' (string)"; break; } return value; }
private object ParamSwitch(FamilyParameter param, FamilyType type) { object value = String.Empty; try { var paramType = param.StorageType; switch (paramType) { case StorageType.String: value = type.AsString(param); if (value != null) { value = value as String; } break; case StorageType.Integer: value = type.AsValueString(param); break; case StorageType.Double: value = type.AsValueString(param); break; case StorageType.ElementId: value = String.Empty; break; } } catch (Exception) { } return value; }
private List <FamilyTypeData> GetTypes(Family family, Document doc, string path) { Document familyDoc = doc.EditFamily(family); FamilyManager familyManager = familyDoc.FamilyManager; FamilyTypeSet familyTypes = familyManager.Types; FamilyTypeSetIterator iterator = familyTypes.ForwardIterator(); iterator.Reset(); List <FamilyTypeData> types = new List <FamilyTypeData>(); while (iterator.MoveNext()) { using (Transaction trans = new Transaction(familyDoc, "Getting Parameter")) { trans.Start(); familyManager.CurrentType = iterator.Current as FamilyType; FamilyType type = familyManager.CurrentType; string paramDescription = string.Empty; //FamilyParameter paramDescription; try { paramDescription = type.AsString(familyManager.get_Parameter("Description")); if (string.IsNullOrEmpty(paramDescription)) { try { paramDescription = type.AsString(familyManager.get_Parameter("Beschreibung")); } catch (Exception e) { Console.WriteLine(e); } } } catch (Exception e) { Console.WriteLine(e); } string paramMountType = string.Empty; try { paramMountType = type.AsString(familyManager.get_Parameter("Installationsart")); } catch (Exception e) { Console.WriteLine(e); } string paramPlacement = string.Empty; try { paramPlacement = type.AsString(familyManager.get_Parameter("Installationsort")); } catch (Exception e) { Console.WriteLine(e); } string paramInstallationMedium = string.Empty; try { paramInstallationMedium = type.AsString(familyManager.get_Parameter("Installations Medium")); } catch (Exception e) { Console.WriteLine(e); } string paramDiameter = string.Empty; try { paramDiameter = type.AsString(familyManager.get_Parameter("E_Durchmesser")); } catch (Exception e) { Console.WriteLine(e); } string paramWidth = string.Empty; try { paramWidth = type.AsString(familyManager.get_Parameter("E_Breite")); } catch (Exception e) { Console.WriteLine(e); } string paramHeight = string.Empty; try { paramHeight = type.AsString(familyManager.get_Parameter("E_Hohe")); } catch (Exception e) { Console.WriteLine(e); } string paramDepth = string.Empty; try { paramDepth = type.AsString(familyManager.get_Parameter("E_Tiefe")); } catch (Exception e) { Console.WriteLine(e); } string param_eBKP_H = string.Empty; try { param_eBKP_H = type.AsString(familyManager.get_Parameter("eBKP-H")); } catch (Exception e) { Console.WriteLine(e); } string paramBKP = string.Empty; try { paramBKP = type.AsString(familyManager.get_Parameter("BKP")); } catch (Exception e) { Console.WriteLine(e); } string paramManufacturer = string.Empty; try { paramManufacturer = type.AsString(familyManager.get_Parameter("Fabrikat")); } catch (Exception e) { Console.WriteLine(e); } string paramProduct = string.Empty; try { paramProduct = type.AsString(familyManager.get_Parameter("Produkt")); } catch (Exception e) { Console.WriteLine(e); } string paramProductNumber = string.Empty; try { paramProductNumber = type.AsString(familyManager.get_Parameter("Produkte-Nr.")); } catch (Exception e) { Console.WriteLine(e); } string paramE_Number = string.Empty; try { paramE_Number = type.AsString(familyManager.get_Parameter("E-Nummer")); } catch (Exception e) { Console.WriteLine(e); } string paramRevitCategory = String.Empty; try { paramRevitCategory = type.AsString(familyManager.get_Parameter("Revit Kategorie")); } catch (Exception e) { Console.WriteLine(e); } string paramOmniClass = string.Empty; try { paramOmniClass = type.AsString(familyManager.get_Parameter("OmniClass-Nummer")); } catch (Exception e) { Console.WriteLine(e); } if (true /*type != null && paramMountType!= null && paramPlacement!= null && paramInstallationMedium!=null*/) { FamilyTypeData typeData = new FamilyTypeData { Name = type.Name, Description = string.IsNullOrEmpty(paramDescription)? emptyParameter: paramDescription, MountType = string.IsNullOrEmpty(paramMountType)? emptyParameter: paramMountType, Placement = string.IsNullOrEmpty(paramPlacement)? emptyParameter :paramPlacement, InstallationMedium = string.IsNullOrEmpty(paramInstallationMedium) ? emptyParameter : paramInstallationMedium, Path = path, CombinedTypeData = paramDescription + "\n" + type.Name, Diameter = string.IsNullOrEmpty(paramDiameter)? emptyParameter: paramDiameter, Width = string.IsNullOrEmpty(paramWidth) ? emptyParameter : paramWidth, Hight = string.IsNullOrEmpty(paramHeight) ? emptyParameter : paramHeight, Depth = string.IsNullOrEmpty(paramDepth) ? emptyParameter : paramDepth, eBKP_H = string.IsNullOrEmpty(param_eBKP_H) ? emptyParameter : param_eBKP_H, BKP = string.IsNullOrEmpty(paramBKP) ? emptyParameter : paramBKP, Manufacturer = string.IsNullOrEmpty(paramManufacturer) ? emptyParameter : paramManufacturer, Product = string.IsNullOrEmpty(paramProduct) ? emptyParameter : paramProduct, ProductNumber = string.IsNullOrEmpty(paramProductNumber) ? emptyParameter : paramProductNumber, E_Number = string.IsNullOrEmpty(paramE_Number) ? emptyParameter : paramE_Number, RevitCategory = string.IsNullOrEmpty(paramRevitCategory) ? emptyParameter : paramRevitCategory, OmniClass = string.IsNullOrEmpty(paramOmniClass) ? emptyParameter : paramOmniClass }; types.Add(typeData); } //TaskDialog.Show("Params", paramDescription.Definition.Name + " * " + type.AsString(paramDescription)); //TaskDialog.Show("Params", paramMountType.Definition.Name + " * " + type.AsString(paramMountType)); //TaskDialog.Show("Params", paramPlacement.Definition.Name + " * " + type.AsString(paramPlacement)); //TaskDialog.Show("Params", paramInstallationMedium.Definition.Name + " * " + type.AsString(paramInstallationMedium)); trans.Commit(); } } return(types); }
public CFamilyParameter(FamilyParameter oParam, FamilyType oFamType) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Invalid comparison between Unknown and I4 //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Invalid comparison between Unknown and I4 //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Invalid comparison between Unknown and I4 //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Invalid comparison between Unknown and I4 //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Invalid comparison between Unknown and I4 //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) this.Name = oParam.get_Definition().get_Name(); this.ParamStorageType = oParam.get_StorageType(); this.TypeName = oFamType.get_Name(); this.ID = oParam.get_Id().get_IntegerValue(); if (oFamType.HasValue(oParam)) { if ((int)this.ParamStorageType == 1 && (int)oParam.get_Definition().get_ParameterType() == 10) { if (oFamType.AsInteger(oParam) == 1) { this.Value = "Yes"; } else { this.Value = "No"; } } else if ((int)this.ParamStorageType == 1) { this.Value = oFamType.AsInteger(oParam).ToString(); } else if ((int)this.ParamStorageType == 2) { this.Value = Math.Round(oFamType.AsDouble(oParam).Value, 2).ToString(); } else if ((int)this.ParamStorageType == 3) { this.Value = oFamType.AsString(oParam); } } }
public DataTable gettingFamilyParamenters(Document rfadoc) { DataTable openFamilyParaDataTable = new DataTable("familyParameterTable"); //创建带列名的列 openFamilyParaDataTable.Columns.Add("paraname", typeof(String)); openFamilyParaDataTable.Columns.Add("paravalue", typeof(String)); openFamilyParaDataTable.Columns.Add("paratag", typeof(String)); if (rfadoc.IsFamilyDocument) { FamilyManager familyMgr = rfadoc.FamilyManager; FamilyType currentType = familyMgr.CurrentType; //Element elerfadoc = rfadoc as Element; //ParameterSet de = familyMgr.Parameters; //获取参数集 FamilyParameterSet rfadocParas = rfadoc.FamilyManager.Parameters; List <FamilyParameter> rfadocParasList = new List <FamilyParameter>(); // 接下来将获取的值放入DATASET int countNum = 0; foreach (FamilyParameter rfadocPara in rfadocParas) { rfadocParasList.Add(rfadocPara); } for (int ii = 0; ii < rfadocParasList.Count(); ii++) { if (currentType == null) { MessageBox.Show("NO LI"); break; } string rfadocParaName = rfadocParasList[ii].Definition.Name; if (rfadocParaName != null) { string rfadocParaValue = currentType.AsString(rfadocParasList[ii]); bool rfadocParaTag = rfadocParasList[ii].IsInstance; openFamilyParaDataTable.Rows.Add(); openFamilyParaDataTable.Rows[countNum]["paraname"] = rfadocParaName; openFamilyParaDataTable.Rows[countNum]["paravalue"] = rfadocParaValue; if (rfadocParaTag == true) { openFamilyParaDataTable.Rows[countNum]["paratag"] = "是"; } else { openFamilyParaDataTable.Rows[countNum]["paratag"] = "否"; } } else { continue; } countNum++; } } return(openFamilyParaDataTable); }