def mesh_draw(mesh, color=None): """ Draw a mesh object in Rhino. Parameters ---------- mesh : compas.datastructures.Mesh The mesh object. color : str, tuple, list, dict (None) The vertex color specification. Defaults to None. Notes ----- Colors can be specifiedin different ways: * str: A hexadecimal color that will be applied to all elements subject to the specification. * tuple, list: RGB color that will be applied to all elements subject to the specification. * dict: RGB or hex color dict with a specification for some or all of the related elements. Notes ----- RGB colors specified as values between 0 and 255, should be integers. RGB colors specified as values between 0.0 and 1.0, should be floats. """ artist = MeshArtist(mesh) return artist.draw_mesh(color)
def to_rgmesh(self): """Convert to :class:`Rhino.Geometry.Mesh` Returns ------- :class:`Rhino.Geometry.Mesh` """ artist = MeshArtist(self) return artist.draw_mesh()
def grasshopper_draw(self): visualisations = [] for woodLayer in self.timberboards: for board in woodLayer: my_box = board.box mesh_box = Mesh.from_shape(my_box) artist = MeshArtist(mesh_box) box_visualisation = artist.draw_mesh() visualisations.append(box_visualisation) return visualisations
def grasshopper_draw(): visualisations = [] for brd in self.elements(): board = brd[1] # visualise all the boards my_box = box_update(board)[1] mesh_box = Mesh.from_shape(my_box) artist = MeshArtist(mesh_box) box_visualisation = artist.draw_mesh() visualisations.append(box_visualisation) return visualisations
def grasshopper_draw(system): def box_update(elmnt): elmnt.board_frame = Frame(elmnt.centre_point, elmnt.length_vector, elmnt.width_vector) elmnt.box = Box(elmnt.board_frame, elmnt.length, elmnt.width, elmnt.height) return elmnt.board_frame, elmnt.box visualisations = [] for brd in system.elements(): board = brd[1] # visualise all the boards my_box = box_update(board)[1] mesh_box = Mesh.from_shape(my_box) artist = MeshArtist(mesh_box) box_visualisation = artist.draw_mesh() visualisations.append(box_visualisation) return visualisations
from compas.datastructures import Mesh from compas.datastructures import mesh_subdivide from compas_ghpython.artists import MeshArtist # make a control mesh mesh = Mesh.from_polyhedron(6) # set default vertex attributes mesh.update_default_vertex_attributes({'is_fixed': False}) # make an artist for drawing artist = MeshArtist(mesh) # draw the control mesh into outputs P, L P = artist.draw_vertices() L = artist.draw_edges() # keep some of the vertices fixed and make a subd mesh (using catmullclark) for key, value in zip(range(len(is_fixed)), is_fixed): mesh.set_vertex_attribute(key, 'is_fixed', value) fixed = mesh.vertices_where({'is_fixed': True}) subd = mesh_subdivide(mesh, scheme='catmullclark', k=k, fixed=fixed) # pass the new mesh to the artist artist.mesh = subd # draw the result into output M M = artist.draw_mesh()
def draw(self): from compas_ghpython.artists import MeshArtist for vkey, element in self.assembly.elements(): artist = MeshArtist(element.mesh) yield artist.draw_mesh()
def cgmesh_to_rgmesh(mesh): artist = MeshArtist(mesh) return artist.draw_mesh()