/// <summary> /// Creates the building and buildinh stories /// </summary> private void CreateBuildingStructure() { // Create the building building = new XPreviewBuilding() { Name = parameters.BuildingName, Location = new XbimPoint3D(parameters.ReferenceLine.sp.X, parameters.ReferenceLine.sp.Y, parameters.ReferenceLine.sp.Z), ReferenceDirection = parameters.ReferenceLine.NormalizedVector, Axis = new XbimVector3D(0, 0, 1) }; // Building stories for (int i = 0; i < parameters.NumberOfFloors; i++) { XPreviewBuildingStory story = new XPreviewBuildingStory { Name = "Floor " + (i + 1).ToString(), Location = new XbimPoint3D(0, 0, i * parameters.FloorToFloor), ReferenceDirection = new XbimVector3D(1, 0, 0), Axis = new XbimVector3D(0, 0, 1), Container = building, StoryNumber = (i + 1), }; } }
private XPreviewBuilding CreateGarageStructure(XParameters parameters) { XbimPoint3D location = parameters.Perimeter.First(); XPolygon perimeter = parameters.Perimeter.Normalized(location); // Create the building XPreviewBuilding garage = new XPreviewBuilding() { Name = parameters.BuildingName, Location = location, ReferenceDirection = new XbimVector3D(1, 0, 0), Axis = new XbimVector3D(0, 0, 1) }; // Building stories for (int i = 0; i < parameters.NumberOfFloors; i++) { XPreviewBuildingStory story = new XPreviewBuildingStory { Name = "Floor " + (i + 1).ToString(), Location = new XbimPoint3D(0, 0, i * parameters.FloorToFloor), ReferenceDirection = new XbimVector3D(1, 0, 0), Axis = new XbimVector3D(0, 0, 1), Container = garage, StoryNumber = (i + 1), }; } return(garage); }
public List <XTreeNode> CreateProjectTree(string projectId) { List <XTreeNode> projectStructure = new List <XTreeNode>(); try { string modelPath = GetFolderPath(projectId) + projectId + ".ifc"; model = IfcStore.Open(modelPath); IfcBuilding ifcBuilding = model.Instances.OfType <IfcBuilding>().FirstOrDefault(); if (ifcBuilding != null) { building = new XPreviewBuilding(ifcBuilding); IfcProject project = model.Instances.OfType <IfcProject>().FirstOrDefault(); if (project != null) { IfcUtils utils = new IfcUtils(); XTreeNode projectNode = utils.CreateProjectHierarchy(project); if (projectNode != null) { projectStructure.Add(projectNode); } } model.Close(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } return(projectStructure); }
public XTreeNode GetModelTree(string projectId, bool serialize = false) { string modelPath = GetFolderPath(projectId) + projectId + ".ifc"; model = IfcStore.Open(modelPath); XTreeNode rootNode = new XTreeNode("Project"); XTreeNode buildingsNode = new XTreeNode("Buildings"); rootNode.ChildNodes.Add(buildingsNode); foreach (IfcBuilding ifcBuilding in model.Instances.OfType <IfcBuilding>()) { building = new XPreviewBuilding(ifcBuilding); buildingsNode.ChildNodes.Add(building.GetModelTree()); } model.Close(); if (serialize) { string json = JsonConvert.SerializeObject(rootNode, Formatting.Indented); string treePath = GetFolderPath(projectId) + "pegasustree.json"; System.IO.File.WriteAllText(treePath, json); } return(rootNode); }
public string CreateOBJFile(IfcStore model, string projectId) { this.model = model; IfcBuilding ifcBuilding = model.Instances.OfType <IfcBuilding>().FirstOrDefault(); if (ifcBuilding != null) { building = new XPreviewBuilding(ifcBuilding); XPreviewElement.vertexCount = 1; var context = new Xbim3DModelContext(model); context.CreateContext(); string objfile = building.GetPreviewObjGroup(context); string path = GetFolderPath(projectId) + "pegasus.obj"; System.IO.File.WriteAllText(path, objfile); // Create the material template library by scanning for unit colors string mtlfile = string.Empty; foreach (UnitParameters unit in parameters.UnitDefinitions) { string unitType = unit.UnitType.Replace(' ', '_'); mtlfile += "newmtl " + unit.UnitType.Replace(' ', '_') + Environment.NewLine; System.Drawing.Color color1 = System.Drawing.ColorTranslator.FromHtml(unit.Color); mtlfile += "kd " + color1.R / 255.0 + ", " + color1.G / 255.0 + ", " + color1.B / 255.0 + Environment.NewLine; } mtlfile += "newmtl corridor" + Environment.NewLine; System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml("#afafaf"); mtlfile += "kd " + color.R / 255.0 + ", " + color.G / 255.0 + ", " + color.B / 255.0 + Environment.NewLine; System.IO.File.WriteAllText(GetFolderPath(projectId) + "pegasus.mtl", mtlfile); model.Close(); return(path); } else { return(string.Empty); } }
public string CreateSVGFile(string projectId) { string modelPath = GetFolderPath(projectId) + projectId + ".ifc"; model = IfcStore.Open(modelPath); IfcBuilding ifcBuilding = model.Instances.OfType <IfcBuilding>().FirstOrDefault(); if (ifcBuilding != null) { building = new XPreviewBuilding(ifcBuilding); string svg = building.GetSVGstring(); string path = GetFolderPath(projectId) + "pegasus.svg"; System.IO.File.WriteAllText(path, svg); model.Close(); return(path); } else { return(string.Empty); } }
private void CreateGarageP(XParameters parameters) { XPreviewBuilding garage = CreateGarageStructure(parameters); garage.CommitAll(model); }