ObjectTable.AddLeader Method (Plane, IEnumerable(Point2d))

ObjectTableAddLeader Method (Plane, IEnumerablePoint2d)

[Missing <summary> documentation for "M:Rhino.DocObjects.Tables.ObjectTable.AddLeader(Rhino.Geometry.Plane,System.Collections.Generic.IEnumerable{Rhino.Geometry.Point2d})"]

Namespace:  Rhino.DocObjects.Tables
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 5.0
Syntax
public Guid AddLeader(
	Plane plane,
	IEnumerable<Point2d> points
)
Public Function AddLeader ( 
	plane As Plane,
	points As IEnumerable(Of Point2d)
) As Guid

Parameters

plane
Type: Rhino.GeometryPlane

[Missing <param name="plane"/> documentation for "M:Rhino.DocObjects.Tables.ObjectTable.AddLeader(Rhino.Geometry.Plane,System.Collections.Generic.IEnumerable{Rhino.Geometry.Point2d})"]

points
Type: System.Collections.GenericIEnumerablePoint2d

[Missing <param name="points"/> documentation for "M:Rhino.DocObjects.Tables.ObjectTable.AddLeader(Rhino.Geometry.Plane,System.Collections.Generic.IEnumerable{Rhino.Geometry.Point2d})"]

Return Value

Type: Guid

[Missing <returns> documentation for "M:Rhino.DocObjects.Tables.ObjectTable.AddLeader(Rhino.Geometry.Plane,System.Collections.Generic.IEnumerable{Rhino.Geometry.Point2d})"]

Examples
using Rhino;
using Rhino.Geometry;
using Rhino.Commands;
using System.Collections.Generic;
using System.Linq;

namespace examples_cs
{
  public class LeaderCommand : Command
  {
    public override string EnglishName { get { return "csLeader"; } }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      var points = new Point3d[]
      {
        new Point3d(1, 1, 0),
        new Point3d(5, 1, 0),
        new Point3d(5, 5, 0),
        new Point3d(9, 5, 0)
      };

      var xy_plane = Plane.WorldXY;

      var points2d = new List<Point2d>();
      foreach (var point3d in points)
      {
        double x, y;
        if (xy_plane.ClosestParameter(point3d, out x, out y))
        {
          var point2d = new Point2d(x, y);
          if (points2d.Count < 1 || point2d.DistanceTo(points2d.Last<Point2d>()) > RhinoMath.SqrtEpsilon)
            points2d.Add(point2d);
        }
      }

      doc.Objects.AddLeader(xy_plane, points2d);
      doc.Views.Redraw();
      return Result.Success;
    }
  }
}
Imports Rhino
Imports Rhino.Geometry
Imports Rhino.Commands
Imports System.Collections.Generic
Imports System.Linq

Namespace examples_vb
  Public Class LeaderCommand
    Inherits Command
    Public Overrides ReadOnly Property EnglishName() As String
      Get
        Return "vbLeader"
      End Get
    End Property

    Protected Overrides Function RunCommand(doc As RhinoDoc, mode As RunMode) As Result
      Dim points = New List(Of Point3d)() From { _
        New Point3d(1, 1, 0), _
        New Point3d(5, 1, 0), _
        New Point3d(5, 5, 0), _
        New Point3d(9, 5, 0) _
      }

      Dim xyPlane = Plane.WorldXY

      Dim points2d = New List(Of Point2d)()
      For Each point3d As Point3d In points
        Dim x As Double, y As Double
        If xyPlane.ClosestParameter(point3d, x, y) Then
          Dim point2d = New Point2d(x, y)
          If points2d.Count < 1 OrElse point2d.DistanceTo(points2d.Last()) > RhinoMath.SqrtEpsilon Then
            points2d.Add(point2d)
          End If
        End If
      Next

      doc.Objects.AddLeader(xyPlane, points2d)
      doc.Views.Redraw()
      Return Result.Success
    End Function
  End Class
End Namespace
Python
import rhinoscriptsyntax as rs

def RunCommand():
  points = [(1,1,0), (5,1,0), (5,5,0), (9,5,0)]
  rs.AddLeader(points)

if __name__ == "__main__":
    RunCommand()
See Also