Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }