internal static IfcBuildingStorey CreateStorey(IfcStore model, IfcBuilding building, string BlkName, int storeyNumber, FloorBase cadFloor) { IfcBuildingStorey storey; using (var trans = model.BeginTransaction("Add Storey")) { storey = model.Instances.New <IfcBuildingStorey>(); storey.Name = BlkName + $"F{storeyNumber}"; IfcRelAggregates rel = model.Instances.New <IfcRelAggregates>(); rel.RelatingObject = building; rel.RelatedObjects.Add(storey); XbimCreateBuilding.AddStoreyProperties(model, storey, cadFloor.Height, cadFloor.Level); trans.Commit(); } return(storey); }
public ActionResult SubmitBlahBlah(List <int> axesIds, SubmissionStages subItem) { List <string> files = Directory.GetFiles(FileStruc.CurrentVersion).ToList(); List <IIfcProduct> Axes; List <IIfcProduct> lstProductSubmission; List <Line> lstAxesLines = new List <Line>(); string ifcFile = files.Where(a => Path.GetExtension(a) == ".ifc").FirstOrDefault(); using (var model = IfcStore.Open(ifcFile)) { Axes = model.Instances.OfType <IIfcProduct>().Where(b => axesIds.Contains(b.EntityLabel)).ToList(); List <IIfcProduct> lstProduct = model.Instances.OfType <IIfcProduct>().Where(p => lstProductId.Contains(p.EntityLabel)).ToList(); List <Line> lstLines = IFCHelper.AxesLinesGet(Axes); //Axes Boundaries LinearPath linPathSubmittal = MathHelper.LinPathAxesIntersection(lstLines); Dictionary <int, LinearPath> dicElement = IFCHelper.DicLinPathOfProductsGet(lstProduct); //get products within the axes boundary Dictionary <int, LinearPath> elementsWithinAxesBoundary = CadHelper.SubmittedElementsGet(linPathSubmittal, dicElement); //reinforcement IFC file using (IfcStore subModelRFT = IFCHelper.CreateandInitModel("Reinforcement File", model.Instances.OfType <IfcProject>().FirstOrDefault().UnitsInContext)) { IfcBuilding bldng = IFCHelper.CreateBuilding(subModelRFT, "bldngRFT", new Point3D(0, 0, 0)); using (var txn = subModelRFT.BeginTransaction("I")) { IfcBuildingStorey storey = subModelRFT.Instances.New <IfcBuildingStorey>(); bldng.AddToSpatialDecomposition(storey); switch (subItem) { case SubmissionStages.FormWork: for (int i = 0; i < elementsWithinAxesBoundary.Values.ToList().Count; i++) { IIfcProduct product = lstProduct.FirstOrDefault(p => p.EntityLabel == elementsWithinAxesBoundary.Keys.ToList()[i]); IIfcRepresentationItem repItem = product.Representation.Representations.First.Items.First; double height = (repItem as IIfcExtrudedAreaSolid).Depth; IfcOpeningElement open; XbimCreateBuilding.CreateFormWork(subModelRFT, elementsWithinAxesBoundary.Values.ToList()[i], DefaultValues.FormWorkThickness, height, out open, "", false, false, false); } //switch (elemTypeFormwork) //{ // case ElementType.PCF: // break; // case ElementType.RCF: // break; // case ElementType.SEM: // break; // case ElementType.SHW: // break; // case ElementType.RTW: // break; // case ElementType.COL: // for (int i = 0; i < elementsWithinAxesBoundary.Values.ToList().Count; i++) // { // Column col = new Column(elementsWithinAxesBoundary.Values.ToList()[i]); // ReinforcedCadColumn rftCol = new ReinforcedCadColumn(col, 0); // IIfcProduct product = lstProduct.FirstOrDefault(p => p.EntityLabel == elementsWithinAxesBoundary.Keys.ToList()[i]); // IIfcRepresentationItem repItem = product.Representation.Representations.First.Items.First; // double height = (repItem as IIfcExtrudedAreaSolid).Depth; // IfcOpeningElement open; // XbimCreateBuilding.CreateFormWork(subModelRFT, rftCol.CadColumn.ColPath, DefaultValues.FormWorkThickness, // height, out open, false, false, false); // } // break; // case ElementType.SLB: // break; // default: // break; //} break; case SubmissionStages.Concrete: lstProductSubmission = lstProduct.Where(p => elementsWithinAxesBoundary.ContainsKey(p.EntityLabel)).ToList(); var map = new XbimInstanceHandleMap(model, subModelRFT); for (int i = 0; i < lstProductSubmission.Count; i++) { IIfcProduct product = subModelRFT.InsertCopy(lstProductSubmission[i], map, null, false, false); storey.AddElement(product as IfcProduct); } break; case SubmissionStages.Reinforcement: Enum.TryParse(ElementTypeSubmitted, out ElementType elemType); switch (elemType) { case ElementType.PCF: break; case ElementType.RCF: break; case ElementType.SEM: break; case ElementType.SHW: break; case ElementType.RTW: break; case ElementType.COL: for (int i = 0; i < elementsWithinAxesBoundary.Values.ToList().Count; i++) { Column col = new Column(elementsWithinAxesBoundary.Values.ToList()[i]); ReinforcedCadColumn rftCol = new ReinforcedCadColumn(col, 0); IIfcProduct product = lstProduct.FirstOrDefault(p => p.EntityLabel == elementsWithinAxesBoundary.Keys.ToList()[i]); IIfcRepresentationItem repItem = product.Representation.Representations.First.Items.First; double height = (repItem as IIfcExtrudedAreaSolid).Depth; XbimCreateBuilding.CreateColumnRft(rftCol, storey, subModelRFT, height, ""); } break; case ElementType.SLB: break; default: break; } break; default: break; } txn.Commit(); subModelRFT.SaveAs(@"E:\01. Work\demo.ifc"); var context = new Xbim3DModelContext(subModelRFT); context.CreateContext(); //var wexBimFilename = Path.ChangeExtension(, "wexBIM"); using (var wexBiMfile = System.IO.File.Create((@"E:\01. Work\demo.wexBIM"))) { using (var wexBimBinaryWriter = new BinaryWriter(wexBiMfile)) { subModelRFT.SaveAsWexBim(wexBimBinaryWriter); wexBimBinaryWriter.Close(); } wexBiMfile.Close(); } } } } return(new EmptyResult()); }
public ActionResult PreviewModel(string versionPath) { var CADFileDirectoryBuildingA = $"{Server.MapPath("~")}\\CAD Files\\BuildingA"; //var CADFileDirectoryBuildingB = $"{Server.MapPath("~")}\\CAD Files\\BuildingB"; List <string> cadfilesBuildingA = Directory.GetFiles(CADFileDirectoryBuildingA).ToList(); //var cadfilesBuildingB = Directory.GetFiles(CADFileDirectoryBuildingB).ToList(); //Building buildingA = new Building("Building A", new Point3D(0, 0, 0)); Building buildingA2 = new Building("Building A", new Point3D(0, 0, 0), 0); //Building buildingB = new Building("Building B", new Point3D(500, 0, 0)); //building.AddNewFloor(cadfiles.Where(e=>e.Contains("Ground")).FirstOrDefault(), 3); //buildingA.AddNewFloor(cadfilesBuildingA.Where(e => e.Contains("Ground")).FirstOrDefault(), 3); // buildingA.AddNewFloor(cadfilesBuildingA.Where(e => e.Contains("Basement")).FirstOrDefault(), 0); {//new buildingA2.AddBuildingFoundation(cadfilesBuildingA.Where(b => b.Contains("Foundation")).FirstOrDefault(), 0, 0); buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("Basement")).FirstOrDefault(), 4.95, 4.95); buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("Ground")).FirstOrDefault(), 8.75, 3.8); buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("1st")).FirstOrDefault(), 11.75, 3); buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("2nd")).FirstOrDefault(), 14.75, 3); buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("3rd")).FirstOrDefault(), 17.75, 3); buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("4th")).FirstOrDefault(), 20.75, 3); buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("5th")).FirstOrDefault(), 23.75, 3); buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("6th")).FirstOrDefault(), 26.75, 3); buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("Roof Floor")).FirstOrDefault(), 29.75, 3); buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("UpRoof")).FirstOrDefault(), 32.75, 3); //buildingA2.AddNewFloor(cadfilesBuildingA.Where(b => b.Contains("Ground")).FirstOrDefault(), 3, 3); //top level = lvl + height } //buildingA.AddBuildingFoundation(cadfilesBuildingA.Where(e => e.Contains("Foundation")).FirstOrDefault(),4.50, 0.2); //buildingB.AddNewFloor(cadfilesBuildingB.Where(e => e.sContains("Basement")).FirstOrDefault(), 0); //buildingB.AddBuildingFoundation(cadfilesBuildingB.Where(e => e.Contains("Foundation")).FirstOrDefault(), -4); newBuilding = new XbimCreateBuilding(buildingA2, versionPath); List <string> files = Directory.GetFiles(versionPath).ToList(); // string wexFile = files.Where(a => Path.GetExtension(a) == ".wexBIM").FirstOrDefault(); List <string> lstIfcFile = files.Where(a => Path.GetExtension(a) == ".ifc").ToList(); //string wexFile = files.Where(a => Path.GetExtension(a) == ".wexBIM").FirstOrDefault(); string wexFile = files.Where(a => Path.GetExtension(a) == ".wexBIM").FirstOrDefault(); var verName = Path.GetFileName(versionPath); var proName = Path.GetFileName(Path.GetDirectoryName(versionPath)); FileStruc.CurrentVersion = versionPath; TempData["VersionName"] = proName + "/" + verName; if (wexFile != null) { TempData["wexbimFilePath"] = wexFile; IFCConverter.CreateTree(lstIfcFile[0]); } else { string newPath = null; for (int i = 0; i < lstIfcFile.Count; i++) { string ifcFile = files.Where(a => Path.GetExtension(a) == ".ifc").ToList()[i]; newPath = IFCConverter.ToWexBIM(ifcFile); } TempData["wexbimFilePath"] = newPath; TempData["IFCFilePath"] = lstIfcFile[0]; } //RedirectToAction("Viewer"); return(RedirectToAction("Viewer")); }