简体   繁体   中英

How to retrieve geometry from IFC file using Xbim ? Or is there anyother alternative to this task?

I want to retrieve data from raw IFC file. I am trying this with Xbim. I am able to retrieve the elements but not able to get geometry specific data.I need location, boundingbox .

Is is possible to do this with xbim ? Is there any alternative to xbim ?

In my case, IFC includes walls, openings, plates, beams and studs. I need their relevant geometries and location. Beams and studs are having drilled holes. But these drilled holes do not belong to any ifc entity such as IfcOpeningElement or Ifc Void.

Is there a way i can get these holes geometry in a tessellate form ?

All i need is access to geometric data of IFC entities.

I also tried using Revit to get data.But there were issues with conversion, like it is heavily dependent on how mapping of Ifc entities with revit category is present.For every other new model ifc elements mapped to different category.

In revit, i imported ifc file and created addin for revit. These addin can read all elements and can get their geometry data. Is there any other such application but less heavier than revit where i can try building such addin also application must correctly categorize elements?

Revit is a heavy program, use xbim instead, try this code to get the geometric information:

        using (var model = IfcStore.Open("ifc_file.ifc"))
        {
            Xbim3DModelContext context = new Xbim3DModelContext(model);
            context.CreateContext();

            List<XbimShapeGeometry> geometrys = context.ShapeGeometries().ToList();
            List<XbimShapeInstance> instances = context.ShapeInstances().ToList();

            //Check all the instances
            foreach (var instance in instances)
            {
                var transfor = instance.Transformation; //Transformation matrix (location point inside)

                XbimShapeGeometry geometry = context.ShapeGeometry(instance);   //Instance's geometry
                XbimRect3D box = geometry.BoundingBox; //bounding box you need

                byte[] data = ((IXbimShapeGeometryData)geometry).ShapeData;

                //If you want to get all the faces and trinagulation use this
                using (var stream = new MemoryStream(data))
                {
                    using (var reader = new BinaryReader(stream))
                    {
                        var mesh = reader.ReadShapeTriangulation();

                        List<XbimFaceTriangulation> faces = mesh.Faces as List<XbimFaceTriangulation>;
                        List<XbimPoint3D> vertices = mesh.Vertices as List<XbimPoint3D>;
                    }
                }
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM