/// <summary> /// Exports file according to format. /// </summary> /// <param name="filepath">File path to export.</param> /// <param name="templates">Optional filter of templates to export.</param> /// <param name="views">Optional filter of views to export.</param> /// <param name="schemas">Optional filter of schemas to export.</param> /// <param name="locales">Optional filter of locales to export.</param> public static void DoExport(DocProject docProject, string filepath, DocModelView[] views, string[] locales, Dictionary<long, SEntity> instances) { string ext = System.IO.Path.GetExtension(filepath).ToLower(); Dictionary<DocObject, bool> included = null; if (views != null) { included = new Dictionary<DocObject, bool>(); foreach (DocModelView docView in views) { docProject.RegisterObjectsInScope(docView, included); } } switch (ext) { case ".ifc": using (FormatSPF format = new FormatSPF(filepath, Schema.IFC.SchemaIfc.Types, instances)) { format.InitHeaders(docProject.Annotations[0].Code, "IFC4"); Schema.IFC.IfcProject ifcProject = new IfcDoc.Schema.IFC.IfcProject(); Program.ExportIfc(ifcProject, docProject, included); format.Save(); } break; case ".ifcxml": using (FormatXML format = new FormatXML(filepath, typeof(Schema.IFC.IfcProject), "http://www.buildingsmart-tech.org/ifcXML/IFC4")) { Schema.IFC.IfcProject ifcProject = new IfcDoc.Schema.IFC.IfcProject(); Program.ExportIfc(ifcProject, docProject, included); format.Instance = ifcProject; format.Save(); } break; case ".mvdxml": using (FormatXML format = new FormatXML(filepath, typeof(mvdXML), mvdXML.DefaultNamespace)) { mvdXML mvd = new mvdXML(); Program.ExportMvd(mvd, docProject, included); format.Instance = mvd; format.Save(); } break; case ".cs": using (FormatCSC format = new FormatCSC(filepath)) { format.Instance = docProject; format.Save(); } break; case ".exp": // use currently visible model view(s) using (FormatEXP format = new FormatEXP(filepath)) { format.Instance = docProject; format.ModelViews = views; format.Save(); } break; case ".xsd": // use currently visible model view(s) using (FormatXSD format = new FormatXSD(filepath)) { format.Instance = docProject; format.ModelViews = views; format.Save(); } break; case ".xml": // Express XSD Configuration using (FormatXML format = new FormatXML(filepath, typeof(Schema.CNF.configuration), null, Schema.CNF.SchemaCNF.Prefixes)) { Schema.CNF.configuration config = new Schema.CNF.configuration(); Program.ExportCnf(config, docProject, views, included); format.Instance = config; format.Save(); } break; case ".txt": // pick locale using (FormatCSV format = new FormatCSV(filepath)) { format.Instance = docProject; format.Locales = locales; format.Save(); } break; case ".sch": using (FormatXML format = new FormatXML(filepath, typeof(Schema.SCH.schema), "http://purl.oclc.org/dsdl/schematron")) { Schema.SCH.schema sch = new Schema.SCH.schema(); Program.ExportSch(sch, docProject, included); format.Instance = sch; format.Save(); } break; } }
/// <summary> /// Exports file according to format. /// </summary> /// <param name="filepath">File path to export.</param> /// <param name="templates">Optional filter of templates to export.</param> /// <param name="views">Optional filter of views to export.</param> /// <param name="schemas">Optional filter of schemas to export.</param> /// <param name="locales">Optional filter of locales to export.</param> public static void DoExport(DocProject docProject, string filepath, DocModelView[] views, string[] locales, Dictionary<long, SEntity> instances) { string ext = System.IO.Path.GetExtension(filepath).ToLower(); Dictionary<DocObject, bool> included = null; if (views != null) { included = new Dictionary<DocObject, bool>(); foreach (DocModelView docView in views) { docProject.RegisterObjectsInScope(docView, included); } } // special case for zip files -- determine based on special naming; make configurable in future Type typeExport = null; if (filepath.EndsWith("-psd.zip")) { typeExport = typeof(DocPropertySet); } else if(filepath.EndsWith("-qto.zip")) { typeExport = typeof(DocQuantitySet); } switch (ext) { case ".ifc": using (FormatSPF format = new FormatSPF(filepath, Schema.IFC.SchemaIfc.Types, instances)) { string filename = System.IO.Path.GetFileName(filepath); format.InitHeaders(filename, "IFC4"); // we always use IFC4 (not later schema) for exporting templates, as that is the earliest version required. Schema.IFC.IfcProject ifcProject = new IfcDoc.Schema.IFC.IfcProject(); Program.ExportIfc(ifcProject, docProject, included); format.Save(); } break; case ".ifcxml": using (FormatXML format = new FormatXML(filepath, typeof(Schema.IFC.IfcProject), "http://www.buildingsmart-tech.org/ifcXML/IFC4")) { Schema.IFC.IfcProject ifcProject = new IfcDoc.Schema.IFC.IfcProject(); Program.ExportIfc(ifcProject, docProject, included); format.Instance = ifcProject; format.Save(); } break; case ".mvdxml": using (FormatXML format = new FormatXML(filepath, typeof(mvdXML), mvdXML.DefaultNamespace)) { mvdXML mvd = new mvdXML(); Program.ExportMvd(mvd, docProject, included); format.Instance = mvd; format.Save(); } break; case ".cs": using (FormatCSC format = new FormatCSC(filepath)) { format.Instance = docProject; format.Save(); } break; case ".exp": // use currently visible model view(s) using (FormatEXP format = new FormatEXP(filepath)) { format.Instance = docProject; format.ModelViews = views; format.Save(); } break; case ".xsd": // use currently visible model view(s) using (FormatXSD format = new FormatXSD(filepath)) { format.Instance = docProject; format.ModelViews = views; format.Save(); } break; case ".xml": // Express XSD Configuration using (FormatXML format = new FormatXML(filepath, typeof(Schema.CNF.configuration), null, Schema.CNF.SchemaCNF.Prefixes)) { Schema.CNF.configuration config = new Schema.CNF.configuration(); Program.ExportCnf(config, docProject, views, included); format.Instance = config; format.Save(); } break; case ".txt": // pick locale using (FormatCSV format = new FormatCSV(filepath)) { format.Instance = docProject; format.Locales = locales; format.Save(); } break; case ".sch": using (FormatXML format = new FormatXML(filepath, typeof(Schema.SCH.schema), "http://purl.oclc.org/dsdl/schematron")) { Schema.SCH.schema sch = new Schema.SCH.schema(); Program.ExportSch(sch, docProject, included); format.Instance = sch; format.Save(); } break; case ".zip": using (FormatZIP format = new FormatZIP(new System.IO.FileStream(filepath, System.IO.FileMode.Create), docProject, included, typeExport)) { format.Save(); } break; } }