Geometry Gym C# - 如何使用新组件修改现有IFC文件?

时间:2017-11-02 09:31:53

标签: c# ifc

我的要求是使用 GeometryGym 读取现有的IFC文件,并向其添加新对象。所以我写了一个C#代码如下,

public void CreateDocuemntRefIcon(string filePath)
{
       DatabaseIfc db = new DatabaseIfc(filePath);
       IfcProject project = db.Project;
       List<IfcBuilding> buildings = project.Extract<IfcBuilding>();
       IfcBuilding thisBuilding = buildings.FirstOrDefault();

       //Creating cube object 
       List<Coord3d> points = new List<Coord3d>() {
             new Coord3d(0, 0, 0), new Coord3d(10, 0, 0),
             new Coord3d(10, 10, 0), new Coord3d(0, 10, 0),
             new Coord3d(0, 0, 10), new Coord3d(10, 0, 10),
             new Coord3d(10, 10, 10), new Coord3d(0, 10, 10) };


       IfcCartesianPointList3D cartesianPointList3D = new IfcCartesianPointList3D(db, points);

        List<CoordIndex> coordIndex = new List<CoordIndex>() {
                new CoordIndex(1, 6, 5), new CoordIndex(1, 2, 6), new CoordIndex(6, 2, 7),
                new CoordIndex(7, 2, 3), new CoordIndex(7, 8, 6), new CoordIndex(6, 8, 5),
                new CoordIndex(5, 8, 1), new CoordIndex(1, 8, 4), new CoordIndex(4, 2, 1),
                new CoordIndex(2, 4, 3), new CoordIndex(4, 8, 7), new CoordIndex(7, 3, 4)
         };

         IfcTriangulatedFaceSet triangulatedFaceSet = new IfcTriangulatedFaceSet(cartesianPointList3D, true, coordIndex);
         IfcColourRgbList colourRgbList = new IfcColourRgbList(db, new List<Color>() { Color.Red, Color.Green, Color.Yellow });
         IfcIndexedColourMap indexedColourMap = new IfcIndexedColourMap(triangulatedFaceSet, colourRgbList, new List<int>() { 1, 1, 2, 2, 3, 3, 1, 1, 1, 1, 1, 1 });

         IfcBuildingElementProxy buildingElementProxy =
                    new IfcBuildingElementProxy(thisBuilding, null, new IfcProductDefinitionShape(new IfcShapeRepresentation(triangulatedFaceSet)));

         //Writed the file
         db.WriteFile(string.Format("{0}.ifc", "EditedIFC"));
}

这适用于 IFC4发布。但不适用于 IFC2x3发布。可能是什么问题 ?

1 个答案:

答案 0 :(得分:0)

IFC2X3没有IfcTriangulatedFaceSet。这已经添加了IFC4。

您可以使用IFC2X3下的IfcShellBasedSurfaceModel模拟三角形曲面。