public static void Create(string path, XbimSchemaVersion schema, Action <IModel> creation) { var f = MemoryModel.GetFactory(schema); using (var model = new MemoryModel(f)) { using (var txn = model.BeginTransaction("Creation")) { creation(model); txn.Commit(); } using (var file = File.Create(path)) { if (path.ToLowerInvariant().EndsWith(".ifc")) { model.SaveAsStep21(file); } else if (path.ToLowerInvariant().EndsWith(".ifcxml")) { model.SaveAsXml(file, new System.Xml.XmlWriterSettings { Indent = true, IndentChars = " " }); } else { throw new Exception("Unexpected extension"); } file.Close(); } } }
public static IModel Create(XbimSchemaVersion schema, Action <IModel> creation) { var f = MemoryModel.GetFactory(schema); var model = new MemoryModel(f); using (var txn = model.BeginTransaction("Creation")) { creation(model); txn.Commit(); } return(model); }