xBimTeam / XbimWebUI

Web components for xBIM Toolkit

Home Page:http://xbimteam.github.io/XbimWebUI/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can anyone please verify my code to load Ifc Structure

umarone opened this issue · comments

public static void Show()
        {
            const string file = "IfcImages/ModernDiningRoom.ifc";

            using (var model = IfcStore.Open(file))
            {
                  var project = model.Instances.ToList();
                LoadIfcStructure(project);        
            }
        }

private static void structuraldataPartOneLoadRelaggregates(List<IPersistEntity> listInstances)
        {
            if (listInstances != null && listInstances.Count > 0)
            {
                           foreach (var item in listInstances)
                {

                    var spatialElement = item as IIfcObjectDefinition;
                    if (spatialElement != null)
                    {
                        if (spatialElement.IsDecomposedBy.SelectMany(r => r.RelatedObjects).Count() > 0)
                        {
                           spatialElement.GetType().Name          
                        }
                        foreach (var ele in spatialElement.IsDecomposedBy.SelectMany(r => r.RelatedObjects))
                        {
                          
                            var oElement = ele as IIfcSpatialStructureElement;
                            if (oElement != null)
                            {
                               
                                
                                   oElement.GetType().Name ;
                               
                                Console.WriteLine(string.Format("{0}    -> {1}", oElement.Name, oElement.GetType().Name));
                                //using IfcRelContainedInSpatialElement to get contained elements
                                var containedElements = oElement.ContainsElements.SelectMany(rel => rel.RelatedElements);
                                if (containedElements != null)
                                {
                                     foreach (var element in containedElements)
                                    {
                                        Console.WriteLine(string.Format("{0}    -> {1}", element.Name, element.GetType().Name));
                                     
                                    }
                                
                                }
                            }
                            else
                            {

                            console.writeline (ele.Name);


                            }
                        }


                    }
                }
            }
        }

Dear Sir.
I have uploaded my code, please see if my code is fine. My code is giving me result but not in a good tree structure as OPEN IFC Viewer is giving

I found an example of loading spatial structure and i changed it according to my need. if you can correct the code please do help me

Please if anyone can see my code or if anyone can give his spatial structure reading code.