Example #1
0
    def draw_mesh(self, compas_mesh, color=None):
        mesh = Rhino.Geometry.Mesh()

        # TODO: check mesh_draw from rhino
        vertices = compas_mesh.get_vertices_attributes('xyz')
        faces = [
            compas_mesh.face_vertices(fkey) for fkey in compas_mesh.faces()
        ]

        for v in vertices:
            mesh.Vertices.Add(*v)
        for f in faces:
            mesh.Faces.AddFace(*f)

        mesh.Normals.ComputeNormals()
        mesh.Compact()

        if color:
            color = rgb_to_rgb(color[0], color[1], color[2])
            count = len(vertices)
            colors = CreateInstance(Color, count)
            for i in range(count):
                colors[i] = rs.coercecolor(color)
            mesh.VertexColors.SetColors(colors)
        return mesh
Example #2
0
 def create_geometry(self, geometry, name=None, color=None):
     if color:
         color = rgb_to_rgb(color[0], color[1], color[2])
     vertices, faces = geometry.to_vertices_and_faces()
     mesh = compas_ghpython.draw_mesh(vertices, faces, color=color)
     # Try to fix invalid meshes
     if not mesh.IsValid:
         mesh.FillHoles()
     return mesh
Example #3
0
    def draw_geometry(self, geometry, name=None, color=None):
        if color:
            color = rgb_to_rgb(color[0], color[1], color[2])

        mesh = mesh_draw(geometry, color=color)

        # Try to fix invalid meshes
        if not mesh.IsValid:
            mesh.FillHoles()

        return mesh
Example #4
0
 def draw_mesh(self, compas_mesh, color=None):
     if color:
         color = rgb_to_rgb(color[0], color[1], color[2])
     return mesh_draw(compas_mesh, color=color)
Example #5
0
 def draw_geometry(self, geometry, color=None):
     if color:
         color = rgb_to_rgb(color[0], color[1], color[2])
     return mesh_draw(geometry, color=color)