public static QtoSetDef ExportQto(DocQuantitySet docPset) { string[] apptypes = new string[0]; if (docPset.ApplicableType != null) { apptypes = docPset.ApplicableType.Split(','); } // convert to psd schema QtoSetDef psd = new QtoSetDef(); psd.Name = docPset.Name; psd.Definition = docPset.Documentation; psd.Versions = new List<IfcVersion>(); psd.Versions.Add(new IfcVersion()); psd.Versions[0].version = "IFC4"; psd.ApplicableTypeValue = docPset.ApplicableType; psd.ApplicableClasses = new List<ClassName>(); foreach (string app in apptypes) { ClassName cln = new ClassName(); cln.Value = app; psd.ApplicableClasses.Add(cln); } psd.QtoDefinitionAliases = new List<QtoDefinitionAlias>(); foreach (DocLocalization docLocal in docPset.Localization) { QtoDefinitionAlias alias = new QtoDefinitionAlias(); psd.QtoDefinitionAliases.Add(alias); alias.lang = docLocal.Locale; alias.Value = docLocal.Documentation; } psd.QtoDefs = new List<QtoDef>(); foreach (DocQuantity docProp in docPset.Quantities) { QtoDef prop = new QtoDef(); psd.QtoDefs.Add(prop); prop.Name = docProp.Name; prop.Definition = docProp.Documentation; prop.NameAliases = new List<NameAlias>(); prop.DefinitionAliases = new List<DefinitionAlias>(); foreach (DocLocalization docLocal in docProp.Localization) { NameAlias na = new NameAlias(); prop.NameAliases.Add(na); na.lang = docLocal.Locale; na.Value = docLocal.Name; DefinitionAlias da = new DefinitionAlias(); prop.DefinitionAliases.Add(da); da.lang = docLocal.Locale; da.Value = docLocal.Documentation; } prop.QtoType = docProp.QuantityType.ToString(); } return psd; }
private static void ExportPsdProperty(DocProperty docProp, PropertyDef prop, Dictionary<string, DocPropertyEnumeration> mapPropEnum) { prop.IfdGuid = docProp.Uuid.ToString("N"); prop.Name = docProp.Name; prop.Definition = docProp.Documentation; prop.NameAliases = new List<NameAlias>(); prop.DefinitionAliases = new List<DefinitionAlias>(); foreach (DocLocalization docLocal in docProp.Localization) { NameAlias na = new NameAlias(); prop.NameAliases.Add(na); na.lang = docLocal.Locale; na.Value = docLocal.Name; DefinitionAlias da = new DefinitionAlias(); prop.DefinitionAliases.Add(da); da.lang = docLocal.Locale; da.Value = docLocal.Documentation; } prop.PropertyType = new PropertyType(); switch (docProp.PropertyType) { case DocPropertyTemplateTypeEnum.P_SINGLEVALUE: prop.PropertyType.TypePropertySingleValue = new TypePropertySingleValue(); prop.PropertyType.TypePropertySingleValue.DataType = new DataType(); prop.PropertyType.TypePropertySingleValue.DataType.type = docProp.PrimaryDataType; break; case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE: prop.PropertyType.TypePropertyBoundedValue = new TypePropertyBoundedValue(); prop.PropertyType.TypePropertyBoundedValue.DataType = new DataType(); prop.PropertyType.TypePropertyBoundedValue.DataType.type = docProp.PrimaryDataType; break; case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE: prop.PropertyType.TypePropertyEnumeratedValue = new TypePropertyEnumeratedValue(); prop.PropertyType.TypePropertyEnumeratedValue.EnumList = new EnumList(); { if (docProp.SecondaryDataType != null) { string[] parts = docProp.SecondaryDataType.Split(':'); if (parts.Length == 2) { string[] enums = parts[1].Split(','); prop.PropertyType.TypePropertyEnumeratedValue.EnumList.name = parts[0]; prop.PropertyType.TypePropertyEnumeratedValue.EnumList.Items = new List<EnumItem>(); foreach (string eachenum in enums) { EnumItem eni = new EnumItem(); prop.PropertyType.TypePropertyEnumeratedValue.EnumList.Items.Add(eni); eni.Value = eachenum.Trim(); } } string propenum = docProp.SecondaryDataType; if (propenum != null) { int colon = propenum.IndexOf(':'); if (colon > 0) { propenum = propenum.Substring(0, colon); } } DocPropertyEnumeration docPropEnum = null; if (mapPropEnum.TryGetValue(propenum, out docPropEnum)) { prop.PropertyType.TypePropertyEnumeratedValue.ConstantList = new ConstantList(); prop.PropertyType.TypePropertyEnumeratedValue.ConstantList.Items = new List<ConstantDef>(); foreach (DocPropertyConstant docPropConst in docPropEnum.Constants) { ConstantDef con = new ConstantDef(); prop.PropertyType.TypePropertyEnumeratedValue.ConstantList.Items.Add(con); con.Name = docPropConst.Name.Trim(); con.Definition = docPropConst.Documentation; con.NameAliases = new List<NameAlias>(); con.DefinitionAliases = new List<DefinitionAlias>(); foreach (DocLocalization docLocal in docPropConst.Localization) { NameAlias na = new NameAlias(); con.NameAliases.Add(na); na.lang = docLocal.Locale; na.Value = docLocal.Name.Trim(); DefinitionAlias da = new DefinitionAlias(); con.DefinitionAliases.Add(da); da.lang = docLocal.Locale; da.Value = docLocal.Documentation; } } } } } break; case DocPropertyTemplateTypeEnum.P_LISTVALUE: prop.PropertyType.TypePropertyListValue = new TypePropertyListValue(); prop.PropertyType.TypePropertyListValue.ListValue = new ListValue(); prop.PropertyType.TypePropertyListValue.ListValue.DataType = new DataType(); prop.PropertyType.TypePropertyListValue.ListValue.DataType.type = docProp.PrimaryDataType; break; case DocPropertyTemplateTypeEnum.P_TABLEVALUE: prop.PropertyType.TypePropertyTableValue = new TypePropertyTableValue(); prop.PropertyType.TypePropertyTableValue.Expression = String.Empty; prop.PropertyType.TypePropertyTableValue.DefiningValue = new DefiningValue(); prop.PropertyType.TypePropertyTableValue.DefiningValue.DataType = new DataType(); prop.PropertyType.TypePropertyTableValue.DefiningValue.DataType.type = docProp.PrimaryDataType; prop.PropertyType.TypePropertyTableValue.DefinedValue = new DefinedValue(); prop.PropertyType.TypePropertyTableValue.DefinedValue.DataType = new DataType(); prop.PropertyType.TypePropertyTableValue.DefinedValue.DataType.type = docProp.SecondaryDataType; break; case DocPropertyTemplateTypeEnum.P_REFERENCEVALUE: prop.PropertyType.TypePropertyReferenceValue = new TypePropertyReferenceValue(); prop.PropertyType.TypePropertyReferenceValue.reftype = docProp.PrimaryDataType; break; case DocPropertyTemplateTypeEnum.COMPLEX: prop.PropertyType.TypeComplexProperty = new TypeComplexProperty(); prop.PropertyType.TypeComplexProperty.name = docProp.PrimaryDataType; prop.PropertyType.TypeComplexProperty.PropertyDefs = new List<PropertyDef>(); foreach(DocProperty docSub in docProp.Elements) { PropertyDef sub = new PropertyDef(); prop.PropertyType.TypeComplexProperty.PropertyDefs.Add(sub); ExportPsdProperty(docSub, sub, mapPropEnum); } break; } }