static void ImportProject(DatabaseIfc db) { #if IFCTest if (SQ.sql != null) { if (db.Project.GlobalId == ProjectModel.Set.Projectmodel.Code) { //the current model is the same as the IFC //TODO: ASk User if he want to replace the currently stored Data with the IFC One } var projectmodel = ProjectModel.Set.Projectmodel; #else var projectmodel = new ProjectModel(); #endif projectmodel.Code = db.Project.GlobalId; projectmodel.Name = db.Project.Name; IfcBuilding.ExtractBuilding(db); var walls = db.Where(o => o is IfcWall).Cast<IfcWall>(); foreach (var w in walls) { var finishmodel = new FinishModel(); IfcObjectType.ExtractTypicalProperties(w, finishmodel); finishmodel.FinishLib = IfcObjectType.ExtractType(w) as FinishLib; finishmodel.FinishLib.InsertOrReplace(); IfcData.InsertOrReplaceAll(finishmodel.FinishLib.Additional_Info); IfcData.InsertOrReplaceAll(finishmodel.Additional_Info); IfcMaterial.ExtractMaterial(w).ForEach(m=> { m.SetFkeyParent(finishmodel.FinishLib); m.InsertOrReplace(); }); finishmodel.InsertOrReplace(); } #if IFCTest } else { Utility.Constants.MainWindow.ShowModalMessageExternal("Please create a project first", ""); } #endif }
public static List <MaterialLib> ExtractMaterialData(IfcMaterialLayerSetUsage matusage) { List <MaterialLib> mats = new List <MaterialLib>(); var layers = matusage.ForLayerSet.MaterialLayers; for (int i = 0; i < layers.Count; i++) { var layer = layers[i]; var fmat = new MaterialLib(); fmat.Name = layer.Material.Name; fmat.Additional_Info.Add(new Data() { Name = "Thickness", Value = layer.LayerThickness.ToString() }); List <Data> datas = new List <Data>(); layer.Material.HasProperties.ForEach(p => { var dic = IfcConvert.ToIfcPropertyDic(p.Properties); datas.AddRange(IfcData.ExtractProps(dic, fmat)); }); } return(mats); }
static List <Data> ExtractData(IfcElement ifcele, Core model) { var props = ((IfcPropertySet)ifcele.IsDefinedBy.First().RelatingPropertyDefinition).HasProperties; return(IfcData.ExtractProps(props, model)); }