/// <summary> /// Saves a model as a Zipped IFC file /// </summary> /// <param name="model">The model to export</param> /// <param name="stream">The stream will be closed and flushed on return</param> /// <param name="zipEntryName">The name of the file zipped inside the file</param> /// <param name="storageType">Specify IfcZip and then either IfcXml or Ifc</param> /// <param name="progDelegate"></param> public static void SaveAsIfcZip(this IModel model, Stream stream, string zipEntryName, StorageType storageType, ReportProgressDelegate progDelegate = null) { Debug.Assert(storageType.HasFlag(StorageType.IfcZip)); var fileBody = Path.ChangeExtension(zipEntryName, storageType.HasFlag(StorageType.IfcXml) ? "ifcXml" : "ifc" ); using (var zipStream = new ZipArchive(stream, ZipArchiveMode.Create)) { var newEntry = zipStream.CreateEntry(fileBody); using (var writer = newEntry.Open()) { if (storageType.HasFlag(StorageType.IfcXml)) { model.SaveAsIfcXml(writer, progDelegate); } else //assume it is Ifc { model.SaveAsIfc(writer, progDelegate); } } } }
public virtual bool CreateFrom(Stream inputStream, long streamSize, StorageType streamType, string xbimDbName, ReportProgressDelegate progDelegate = null, bool keepOpen = false, bool cacheEntities = false) { Close(); if (streamType.HasFlag(StorageType.IfcZip) || streamType.HasFlag(StorageType.StpZip) || streamType.HasFlag(StorageType.Zip)) { Cache.ImportZip(xbimDbName, inputStream, progDelegate, keepOpen, cacheEntities, _codePageOverrideForStepFiles); } else if (streamType.HasFlag(StorageType.Ifc) || streamType.HasFlag(StorageType.Stp)) { Cache.ImportStep(xbimDbName, inputStream, streamSize, progDelegate, keepOpen, cacheEntities, _codePageOverrideForStepFiles); } else if (streamType.HasFlag(StorageType.IfcXml)) { Cache.ImportIfcXml(xbimDbName, inputStream, progDelegate, keepOpen, cacheEntities); } return(true); }