public static ExportQto ( DocQuantitySet docPset ) : IfcDoc.Schema.PSD.QtoSetDef | ||
docPset | DocQuantitySet | |
return | IfcDoc.Schema.PSD.QtoSetDef |
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;
}
public void Save() { // build map of enumerations Dictionary <string, DocPropertyEnumeration> mapPropEnum = new Dictionary <string, DocPropertyEnumeration>(); foreach (DocPropertyEnumeration docEnum in this.m_project.PropertyEnumerations) { if (!mapPropEnum.ContainsKey(docEnum.Name)) { mapPropEnum.Add(docEnum.Name, docEnum); } } using (Package zip = ZipPackage.Open(this.m_stream, FileMode.Create)) { foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { if (this.m_type == null || this.m_type == typeof(DocPropertySet)) { foreach (DocPropertySet docPset in docSchema.PropertySets) { if (m_included == null || this.m_included.ContainsKey(docPset)) { if (docPset.IsVisible()) { Uri uri = PackUriHelper.CreatePartUri(new Uri(docPset.Name + ".xml", UriKind.Relative)); PackagePart part = zip.CreatePart(uri, "", CompressionOption.Normal); using (Stream refstream = part.GetStream()) { refstream.SetLength(0); PropertySetDef psd = Program.ExportPsd(docPset, mapPropEnum, this.m_project); using (FormatXML format = new FormatXML(refstream, typeof(PropertySetDef), PropertySetDef.DefaultNamespace, null)) { format.Instance = psd; format.Save(); } } } } } } if (this.m_type == null || this.m_type == typeof(DocQuantitySet)) { foreach (DocQuantitySet docQset in docSchema.QuantitySets) { if (m_included == null || this.m_included.ContainsKey(docQset)) { Uri uri = PackUriHelper.CreatePartUri(new Uri(docQset.Name + ".xml", UriKind.Relative)); PackagePart part = zip.CreatePart(uri, "", CompressionOption.Normal); using (Stream refstream = part.GetStream()) { refstream.SetLength(0); QtoSetDef psd = Program.ExportQto(docQset, this.m_project); using (FormatXML format = new FormatXML(refstream, typeof(QtoSetDef), PropertySetDef.DefaultNamespace, null)) { format.Instance = psd; format.Save(); } } } } } } } } }