def draw(self, show_point=False, show_normal=False): """Draw the circle. Parameters ---------- show_point : bool, optional Default is ``False``. show_normal : bool, optional Default is ``False``. Returns ------- list The GUIDs of the created Rhino objects. """ point = list(self.primitive.plane.point) normal = list(self.primitive.plane.normal) plane = point, normal radius = self.primitive.radius guids = [] if show_point: points = [{'pos': point, 'color': self.color, 'name': self.primitive.name}] guids += compas_rhino.draw_points(points, layer=self.layer, clear=False, redraw=False) if show_normal: lines = [{'start': point, 'end': add_vectors(point, normal), 'arrow': 'end', 'color': self.color, 'name': self.primitive.name}] guids += compas_rhino.draw_lines(lines, layer=self.layer, clear=False, redraw=False) circles = [{'plane': plane, 'radius': radius, 'color': self.color, 'name': self.primitive.name}] guids += compas_rhino.draw_circles(circles, layer=self.layer, clear=False, redraw=False) return guids
def draw_circles(self, circles, layer=None, clear_layer=False, redraw=False): """Draw a collection of circles. Parameters ---------- circles : list of dict The circles to draw. layer : str, optional The layer to draw the points in. Default is ``None``. clear_layer : bool, optional Clear the specified layer. Default is ``False``. redraw : bool, optional Redraw the Rhino view. Default is ``False``. Returns ------- list of guid The GUIDs of the polygon objects. """ layer = layer or self.layer return compas_rhino.draw_circles(circles, layer=layer, clear=clear_layer, redraw=redraw)
def draw_collection(collection, names=None, colors=None, layer=None, clear=False, add_to_group=False, group_name=None): """Draw a collection of circles. Parameters ---------- collection : list of :class:`compas.geometry.Circle` A collection of circles. names : list of str, optional Individual names for the circles. colors : color or list of color, optional A color specification for the circles as a single color or a list of individual colors. layer : str, optional A layer path. clear : bool, optional Clear the layer before drawing. add_to_group : bool, optional Add the circles to a group. group_name : str, optional Name of the group. Returns ------- list The GUIDs of the created Rhino objects. """ circles = [] for circle in collection: circles.append({ 'plane': [list(circle[0][0]), list(circle[0][1])], 'radius': circle[1] }) if colors: if isinstance(colors[0], (int, float)): colors = iterable_like(collection, [colors], colors) else: colors = iterable_like(collection, colors, colors[0]) for point, rgb in zip(circles, colors): circle['color'] = rgb if names: if isinstance(names, basestring): names = iterable_like(collection, [names], names) else: names = iterable_like(collection, names, names[0]) for circle, name in zip(circles, names): circle['name'] = name guids = compas_rhino.draw_circles(circles, layer=layer, clear=clear) if not add_to_group: return guids group = compas_rhino.rs.AddGroup(group_name) if group: compas_rhino.rs.AddObjectsToGroup(guids, group) return group
def draw(self): """Draw the circle. Returns ------- list The GUIDs of the created Rhino objects. """ point = list(self.primitive.plane.point) normal = list(self.primitive.plane.normal) radius = self.primitive.radius circles = [{'plane': [point, normal], 'radius': radius, 'color': self.color, 'name': self.name}] guids = compas_rhino.draw_circles(circles, layer=self.layer, clear=False, redraw=False) self._guids = guids return guids
def draw_circles(self, circles, layer=None, clear_layer=False, redraw=False): """Draw a collection of circles. Parameters ---------- circles : list of dict The circles to draw. layer : str, optional The layer to draw the points in. Default is ``None``, in which case the current layer is used. clear_layer : bool, optional Clear the specified layer. Default is ``False``. redraw : bool, optional Redraw the Rhino view. Default is ``False``. Returns ------- list of guid The GUIDs of the circle objects. Notes ----- The attributes required for drawing a circle are stored in a dictionary per circle. The dictionary has the following structure: .. code-block:: none { 'plane' : (point, normal), 'radius' : float 'name' : str, # optional 'color' : rgb or hex, # optional 'layer' : str # optional, defaults to the value of the parameter ``layer``. } """ layer = layer or self.layer return compas_rhino.draw_circles(circles, layer=layer, clear=clear_layer, redraw=redraw)
from random import random from compas.geometry import pointcloud_xy from compas.utilities import i_to_green from compas.utilities import i_to_red import compas_rhino cloud = pointcloud_xy(200, (0, 10), (0, 5)) points = [] circles = [] for xyz in cloud: n = random() points.append({'pos': xyz, 'color': i_to_red(n)}) circles.append({ 'plane': [xyz, [0, 0, 1]], 'color': i_to_red(n), 'radius': n }) layerp = "points" layerc = "circles" compas_rhino.draw_points(points, layer=layerp, clear=True) compas_rhino.draw_circles(circles, layer=layerp, clear=False)