internal static void ExportIfc(IfcProject ifcProject, DocProject docProject, Dictionary<DocObject, bool> included)
{
ifcProject.Name = "IFC4 Property Set Templates";
// cache enumerators
Dictionary<string, DocPropertyEnumeration> mapEnums = new Dictionary<string,DocPropertyEnumeration>();
foreach (DocSection docSect in docProject.Sections)
{
foreach (DocSchema docSchema in docSect.Schemas)
{
foreach (DocPropertyEnumeration docEnum in docSchema.PropertyEnums)
{
try
{
mapEnums.Add(docEnum.Name, docEnum);
}
catch
{
}
}
}
}
IfcLibraryInformation ifcLibInfo = null;
#if false // optimization: don't include library info
IfcLibraryInformation ifcLibInfo = new IfcLibraryInformation();
ifcLibInfo.Publisher = null; // BuildingSmart...
ifcLibInfo.Version = "IFC4";
ifcLibInfo.VersionDate = DateTime.UtcNow;
ifcLibInfo.Location = "";
ifcLibInfo.Name = ifcProject.Name;
IfcRelAssociatesLibrary ifcRelLibProject = new IfcRelAssociatesLibrary();
ifcRelLibProject.RelatingLibrary = ifcLibInfo;
ifcRelLibProject.RelatedObjects.Add(ifcProject);
#endif
IfcRelDeclares rel = new IfcRelDeclares();
rel.RelatingContext = ifcProject;
ifcProject.Declares.Add(rel);
foreach (DocSection docSection in docProject.Sections)
{
foreach (DocSchema docSchema in docSection.Schemas)
{
foreach (DocPropertySet docPset in docSchema.PropertySets)
{
if (included == null || included.ContainsKey(docPset))
{
IfcPropertySetTemplate ifcPset = new IfcPropertySetTemplate();
rel.RelatedDefinitions.Add(ifcPset);
ifcPset.GlobalId = SGuid.Format(docPset.Uuid);
ifcPset.Name = docPset.Name;
ifcPset.Description = docPset.Documentation;
switch (docPset.PropertySetType)
{
case "PSET_TYPEDRIVENOVERRIDE":
ifcPset.PredefinedType = IfcPropertySetTemplateTypeEnum.PSET_TYPEDRIVENOVERRIDE;
break;
case "PSET_OCCURRENCEDRIVEN":
ifcPset.PredefinedType = IfcPropertySetTemplateTypeEnum.PSET_OCCURRENCEDRIVEN;
break;
case "PSET_PERFORMANCEDRIVEN":
ifcPset.PredefinedType = IfcPropertySetTemplateTypeEnum.PSET_PERFORMANCEDRIVEN;
break;
}
ifcPset.ApplicableEntity = docPset.ApplicableType;
foreach (DocLocalization docLoc in docPset.Localization)
{
IfcLibraryReference ifcLib = new IfcLibraryReference();
ifcLib.Language = docLoc.Locale;
ifcLib.Name = docLoc.Name;
ifcLib.Description = docLoc.Documentation;
ifcLib.ReferencedLibrary = ifcLibInfo;
IfcRelAssociatesLibrary ifcRal = new IfcRelAssociatesLibrary();
ifcRal.RelatingLibrary = ifcLib;
ifcRal.RelatedObjects.Add(ifcPset);
ifcPset.HasAssociations.Add(ifcRal);
}
foreach (DocProperty docProp in docPset.Properties)
{
IfcPropertyTemplate ifcProp = ExportIfcPropertyTemplate(docProp, ifcLibInfo, mapEnums);
ifcPset.HasPropertyTemplates.Add(ifcProp);
}
}
}
foreach (DocQuantitySet docQuantitySet in docSchema.QuantitySets)
{
if (included == null || included.ContainsKey(docQuantitySet))
{
IfcPropertySetTemplate ifcPset = new IfcPropertySetTemplate();
rel.RelatedDefinitions.Add(ifcPset);
ifcPset.Name = docQuantitySet.Name;
ifcPset.Description = docQuantitySet.Documentation;
ifcPset.PredefinedType = IfcPropertySetTemplateTypeEnum.QTO_OCCURRENCEDRIVEN;
ifcPset.ApplicableEntity = docQuantitySet.ApplicableType;
foreach (DocLocalization docLoc in docQuantitySet.Localization)
{
IfcLibraryReference ifcLib = new IfcLibraryReference();
ifcLib.Language = docLoc.Locale;
ifcLib.Name = docLoc.Name;
ifcLib.Description = docLoc.Documentation;
ifcLib.ReferencedLibrary = ifcLibInfo;
IfcRelAssociatesLibrary ifcRal = new IfcRelAssociatesLibrary();
ifcRal.RelatingLibrary = ifcLib;
ifcRal.RelatedObjects.Add(ifcPset);
}
foreach (DocQuantity docProp in docQuantitySet.Quantities)
{
IfcSimplePropertyTemplate ifcProp = new IfcSimplePropertyTemplate();
ifcPset.HasPropertyTemplates.Add(ifcProp);
ifcProp.Name = docProp.Name;
ifcProp.Description = docProp.Documentation;
ifcProp.TemplateType = (IfcSimplePropertyTemplateTypeEnum)Enum.Parse(typeof(IfcSimplePropertyTemplateTypeEnum), docProp.QuantityType.ToString());
foreach (DocLocalization docLoc in docProp.Localization)
{
IfcLibraryReference ifcLib = new IfcLibraryReference();
ifcLib.Language = docLoc.Locale;
ifcLib.Name = docLoc.Name;
ifcLib.Description = docLoc.Documentation;
ifcLib.ReferencedLibrary = ifcLibInfo;
IfcRelAssociatesLibrary ifcRal = new IfcRelAssociatesLibrary();
ifcRal.RelatingLibrary = ifcLib;
ifcRal.RelatedObjects.Add(ifcProp);
}
}
}
}
}
}
}