Beispiel #1
0
        public static Autodesk.DesignScript.Geometry.Mesh ToProtoType(this Autodesk.Revit.DB.Mesh mesh)
        {
            var pts  = mesh.Vertices.Select(x => x.ToPoint()).ToArray();
            var tris = Enumerable.Range(0, mesh.NumTriangles)
                       .Select(mesh.get_Triangle)
                       .Select(tri => IndexGroup.ByIndices(tri.get_Index(0), tri.get_Index(1), tri.get_Index(2)))
                       .ToArray();

            return(Autodesk.DesignScript.Geometry.Mesh.ByPointsFaceIndices(pts, tris));
        }
Beispiel #2
0
        public static void PushMesh(Autodesk.Revit.DB.Mesh mesh, IRenderPackage package)
        {
            for (var i = 0; i < mesh.NumTriangles; i++)
            {
                var triangle = mesh.get_Triangle(i);
                for (var j = 0; j < 3; j++)
                {
                    var xyz = triangle.get_Vertex(j);
                    package.PushTriangleVertex(xyz.X, xyz.Y, xyz.Z);
                }

                var a    = mesh.get_Triangle(i).get_Vertex(1).Subtract(mesh.get_Triangle(i).get_Vertex(0)).Normalize();
                var b    = mesh.get_Triangle(i).get_Vertex(2).Subtract(mesh.get_Triangle(i).get_Vertex(0)).Normalize();
                var norm = a.CrossProduct(b);
                package.PushTriangleVertexNormal(norm.X, norm.Y, norm.Z);
                package.PushTriangleVertexNormal(norm.X, norm.Y, norm.Z);
                package.PushTriangleVertexNormal(norm.X, norm.Y, norm.Z);
            }
        }