def draw_faces(self, faces=None, color=None): """Draw a selection of faces. Parameters ---------- faces : list A list of face keys identifying which faces to draw. The default is ``None``, in which case all faces are drawn. color : rgb-tuple or dict of rgb-tuple The color specififcation for the faces. Returns ------- list of :class:`bpy.types.Object` """ faces = faces or list(self.mesh.faces()) face_color = colordict(color, faces, default=self.color_faces) facets = [] for face in faces: facets.append({ 'points': self.mesh.face_coordinates(face), 'name': f"{self.mesh.name}.face.{face}", 'color': face_color[face] }) objects = compas_blender.draw_faces(facets, self.facecollection) self.object_face = zip(objects, faces) return objects
def draw_faces( self, faces: Optional[List[int]] = None, color: Optional[Union[str, RGBColor, List[RGBColor], Dict[int, RGBColor]]] = None ) -> List[bpy.types.Object]: """Draw a selection of faces. Parameters ---------- faces : list A list of face keys identifying which faces to draw. The default is ``None``, in which case all faces are drawn. color : rgb-tuple or dict of rgb-tuple The color specification for the faces. Returns ------- list of :class:`bpy.types.Object` """ self.face_color = color faces = faces or self.faces facets = [] for face in faces: facets.append({ 'points': [ self.vertex_xyz[vertex] for vertex in self.mesh.face_vertices(face) ], 'name': f"{self.mesh.name}.face.{face}", 'color': self.face_color.get(face, self.default_facecolor) }) return compas_blender.draw_faces(facets, self.facecollection)
def draw(self, color: Optional[RGBColor] = None, show_points: bool = False, show_edges: bool = False, show_face: bool = True) -> List[bpy.types.Object]: """Draw the polygon. Parameters ---------- color : tuple[float, float, float] or tuple[int, int, int], optional The RGB color of the polygon. The default color is :attr:`compas.artists.PrimitiveArtist.color`. show_points : bool, optional If True, draw the corner points of the polygon. show_edges : bool, optional If True, draw the edges of the polygon. show_face : bool, optional If True, draw the face of the polygon. Returns ------- list[:blender:`bpy.types.Object`] """ color = color or self.color objects = [] if show_points: points = [{ 'pos': point, 'color': color, 'name': self.primitive.name, 'radius': 0.01 } for point in self.primitive.points] objects += compas_blender.draw_points(points, collection=self.collection) if show_edges: lines = [{ 'start': a, 'end': b, 'color': color, 'name': self.primitive.name } for a, b in self.primitive.lines] objects += compas_blender.draw_lines(lines, collection=self.collection) if show_face: polygons = [{ 'points': self.primitive.points, 'color': color, 'name': self.primitive.name }] objects += compas_blender.draw_faces(polygons, collection=self.collection) return objects
def draw(self, color: Optional[RGBColor] = None, show_points: bool = False, show_edges: bool = False, show_face: bool = True) -> List[bpy.types.Object]: """Draw the polygon. Parameters ---------- color : tuple of float or tuple of int, optional The RGB color of the polygon. show_points : bool, optional Default is ``False``. show_edges : bool, optional Default is ``False``. show_face : bool, optional Default is ``True``. Returns ------- list of bpy.types.Object """ color = color or self.color objects = [] if show_points: points = [{ 'pos': point, 'color': color, 'name': self.primitive.name, 'radius': 0.01 } for point in self.primitive.points] objects += compas_blender.draw_points(points, collection=self.collection) if show_edges: lines = [{ 'start': a, 'end': b, 'color': color, 'name': self.primitive.name } for a, b in self.primitive.lines] objects += compas_blender.draw_lines(lines, collection=self.collection) if show_face: polygons = [{ 'points': self.primitive.points, 'color': color, 'name': self.primitive.name }] objects += compas_blender.draw_faces(polygons, collection=self.collection) return objects