Example #1
0
    def draw_polygons(self,
                      polygons,
                      layer=None,
                      clear_layer=False,
                      redraw=False):
        """Draw a collection of polygons.

        Parameters
        ----------
        polylines : list of dict
            The polygons 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_polylines(polygons,
                                           layer=layer,
                                           clear=clear_layer,
                                           redraw=redraw)
Example #2
0
    def draw(self, show_points=False):
        """Draw the polyline.

        Parameters
        ----------
        show_points : bool, optional
            Default is ``False``.

        Returns
        -------
        list
            The GUIDs of the created Rhino objects.
        """
        _points = map(list, self.primitive.points)
        guids = []
        if show_points:
            points = [{
                'pos': point,
                'color': self.color,
                'name': self.primitive.name
            } for point in _points]
            guids += compas_rhino.draw_points(points,
                                              layer=self.layer,
                                              clear=False,
                                              redraw=False)
        polylines = [{
            'points': _points,
            'color': self.color,
            'name': self.primitive.name
        }]
        guids = compas_rhino.draw_polylines(polylines,
                                            layer=self.layer,
                                            clear=False,
                                            redraw=False)
        return guids
Example #3
0
    def draw_polygons(self,
                      polygons,
                      layer=None,
                      clear_layer=False,
                      redraw=False):
        """Draw a collection of polygons.

        Parameters
        ----------
        polylines : list of dict
            The polygons 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 polygon objects.

        Notes
        -----
        The attributes required for drawing a polygon are stored in a dictionary per polygon.
        The dictionary has the following structure:

        .. code-block:: none

            {
                'points' : list of point,
                'name'   : str,                      # optional
                'color'  : rgb or hex,               # optional
                'layer'  : str,                      # optional, defaults to the value of the parameter ``layer``.
                'width'  : float,                    # optional, modifies the plot weight if not None.
                'arrow'  : {'start', 'end', 'both'}  # optional
            }

        Note that the draing of polygons currently falls back on the drawing of polylines.
        The polygon should therefore be closed expicitly, but this is done for you,
        on te fly...

        """
        layer = layer or self.layer
        for polygon in polygons:
            if polygon['points'][0] != polygon['points'][-1]:
                polygon[
                    'points'] = polygon['points'][:] + polygon['points'][:1]
        return compas_rhino.draw_polylines(polygons,
                                           layer=layer,
                                           clear=clear_layer,
                                           redraw=redraw)
Example #4
0
    def draw(self):
        """Draw the polyline.

        Returns
        -------
        list
            The GUIDs of the created Rhino objects.
        """
        polylines = [{'points': map(list, self.primitive.points), 'color': self.color, 'name': self.name}]
        guids = compas_rhino.draw_polylines(polylines, layer=self.layer, clear=False, redraw=False)
        self._guids = guids
        return guids
Example #5
0
    def draw(self):
        """Draw the polyline.

        """
        polylines = [{
            'points': self.primitive.points,
            'color': self.color,
            'name': self.name
        }]
        self.guids = compas_rhino.draw_polylines(polylines,
                                                 layer=self.layer,
                                                 clear=False,
                                                 redraw=False)
Example #6
0
    def draw_polylines(self,
                       polylines,
                       layer=None,
                       clear_layer=False,
                       redraw=False):
        """Draw a collection of polygons.

        Parameters
        ----------
        polylines : list of dict
            The polylines 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 polyline objects.

        Notes
        -----
        The attributes required for drawing a polyline are stored in a dictionary per polyline.
        The dictionary has the following structure:

        .. code-block:: none

            {
                'points' : list of point,
                'name'   : str,                      # optional
                'color'  : rgb or hex,               # optional
                'layer'  : str,                      # optional, defaults to the value of the parameter ``layer``.
                'width'  : float,                    # optional, modifies the plot weight if not None.
                'arrow'  : {'start', 'end', 'both'}  # optional
            }

        """
        layer = layer or self.layer
        return compas_rhino.draw_polylines(polylines,
                                           layer=layer,
                                           clear=clear_layer,
                                           redraw=redraw)