简体   繁体   中英

create custom polygon wall using xbim library

I try to make ifc wall using some polygon points and save to ifc file.

I found some approach and try that, but it does not work.

here is my code:

private static void CreateCustomPolygonWall(IfcStore model)
{
    using (var txn = model.BeginTransaction("Create Custom Polygon"))
    {
        List<double[]> points = new List<double[]>();
        points.Add(new double[] { 0, 0, 0 });
        points.Add(new double[] { 100, 0, 0 });
        points.Add(new double[] { 100, 100, 0 });

        var list = new List<IfcCartesianPoint>();
        foreach (var coordinates in points.Select(p => p.Select(x => new IfcLengthMeasure(x))))
        {
            var point = model.Instances.New<IfcCartesianPoint>();
            point.Coordinates.AddRange(coordinates);
            list.Add(point);
        }

        var faceSet = model.Instances.New<Xbim.Ifc4.TopologyResource.IfcConnectedFaceSet>();
        List<int[]> indexes = new List<int[]>();
        indexes.Add(new int[] { 0, 1, 2 });
        foreach (var t in indexes)
        {
            var polyLoop = model.Instances.New<Xbim.Ifc4.TopologyResource.IfcPolyLoop>();
            polyLoop.Polygon.AddRange(t.Select(k => list[k]));

            var bound = model.Instances.New<Xbim.Ifc4.TopologyResource.IfcFaceBound>();
            bound.Bound = polyLoop;

            var face = model.Instances.New<Xbim.Ifc4.TopologyResource.IfcFace>();
            face.Bounds.Add(bound);
            faceSet.CfsFaces.Add(face);
        }

        var surface = model.Instances.New<IfcFaceBasedSurfaceModel>();
        surface.FbsmFaces.Add(faceSet);

        txn.Commit();
    }
}

and if I save to ifc file following the code, the file has polygon points that I describe. but it is not showing any ifc viewer.

#23=IFCCARTESIANPOINT((0.,0.,0.));
#24=IFCCARTESIANPOINT((100.,0.,0.));
#25=IFCCARTESIANPOINT((100.,100.,0.));

so how can I create a polygon wall and save it to ifc file using xbim library?

any hint?

best regards.

You need to create more than just the geometry to create an IFC file which other viewers would process and display. Here is a working example of 3D wall creation. If you want to define the wall as any arbitrary profile, you would replace IfcRectangleProfileDef in the example with other profile definition , likely IfcArbitraryClosedProfileDef with OuterCurve being IfcPolyline .

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