Example #1
0
    public static Rhino.Commands.Result AddLine(Rhino.RhinoDoc doc)
    {
        Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint();
        gp.SetCommandPrompt("Start of line");
        gp.Get();
        if (gp.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(gp.CommandResult());
        }

        Rhino.Geometry.Point3d pt_start = gp.Point();

        gp.SetCommandPrompt("End of line");
        gp.SetBasePoint(pt_start, false);
        gp.DrawLineFromPoint(pt_start, true);
        gp.Get();
        if (gp.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(gp.CommandResult());
        }

        Rhino.Geometry.Point3d  pt_end = gp.Point();
        Rhino.Geometry.Vector3d v      = pt_end - pt_start;
        if (v.IsTiny(Rhino.RhinoMath.ZeroTolerance))
        {
            return(Rhino.Commands.Result.Nothing);
        }

        if (doc.Objects.AddLine(pt_start, pt_end) != Guid.Empty)
        {
            doc.Views.Redraw();
            return(Rhino.Commands.Result.Success);
        }
        return(Rhino.Commands.Result.Failure);
    }
Example #2
0
    public static Rhino.Commands.Result ConstrainedCopy(Rhino.RhinoDoc doc)
    {
        // Get a single planar closed curve
        var go = new Rhino.Input.Custom.GetObject();

        go.SetCommandPrompt("Select curve");
        go.GeometryFilter          = Rhino.DocObjects.ObjectType.Curve;
        go.GeometryAttributeFilter = Rhino.Input.Custom.GeometryAttributeFilter.ClosedCurve;
        go.Get();
        if (go.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(go.CommandResult());
        }
        var objref      = go.Object(0);
        var base_curve  = objref.Curve();
        var first_point = objref.SelectionPoint();

        if (base_curve == null || !first_point.IsValid)
        {
            return(Rhino.Commands.Result.Cancel);
        }

        Rhino.Geometry.Plane plane;
        if (!base_curve.TryGetPlane(out plane))
        {
            return(Rhino.Commands.Result.Cancel);
        }

        // Get a point constrained to a line passing through the initial selection
        // point and parallel to the plane's normal
        var gp = new Rhino.Input.Custom.GetPoint();

        gp.SetCommandPrompt("Offset point");
        gp.DrawLineFromPoint(first_point, true);
        var line = new Rhino.Geometry.Line(first_point, first_point + plane.Normal);

        gp.Constrain(line);
        gp.Get();
        if (gp.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(gp.CommandResult());
        }
        var second_point = gp.Point();

        Rhino.Geometry.Vector3d vec = second_point - first_point;
        if (vec.Length > 0.001)
        {
            var  xf = Rhino.Geometry.Transform.Translation(vec);
            Guid id = doc.Objects.Transform(objref, xf, false);
            if (id != Guid.Empty)
            {
                doc.Views.Redraw();
                return(Rhino.Commands.Result.Success);
            }
        }
        return(Rhino.Commands.Result.Cancel);
    }
    public static Rhino.Commands.Result AddNamedView(Rhino.RhinoDoc doc)
    {
        Rhino.Display.RhinoView view;
        Rhino.Commands.Result   rc = Rhino.Input.RhinoGet.GetView("Select view to adjust", out view);
        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }

        Rhino.Geometry.Point3d location;
        rc = Rhino.Input.RhinoGet.GetPoint("Camera Location", false, out location);
        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }

        Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint();
        gp.SetCommandPrompt("Look At Location");
        gp.DrawLineFromPoint(location, false);
        gp.Get();
        if (gp.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(gp.CommandResult());
        }
        Rhino.Geometry.Point3d lookat = gp.Point();

        string name = view.ActiveViewport.Name;

        rc = Rhino.Input.RhinoGet.GetString("Name", true, ref name);
        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }

        Rhino.Display.RhinoViewport vp = view.ActiveViewport;
        // save the current viewport projection
        vp.PushViewProjection();
        vp.CameraUp = Rhino.Geometry.Vector3d.ZAxis;
        vp.SetCameraLocation(location, false);
        vp.SetCameraDirection(lookat - location, true);
        vp.Name = name;

        doc.NamedViews.Add(name, vp.Id);
        view.Redraw();
        return(Rhino.Commands.Result.Success);
    }
Example #4
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var view = doc.Views.ActiveView;
            var vp   = view.ActiveViewport;

            var target = vp.CameraTarget;
            var camera = vp.CameraLocation;

            var gp = new Rhino.Input.Custom.GetPoint();

            gp.SetCommandPrompt("New target location");
            gp.SetDefaultPoint(target);
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            target = gp.Point();

            gp.ClearDefault();
            gp.SetCommandPrompt("New camera location");
            gp.SetDefaultPoint(camera);
            gp.SetBasePoint(target, true);
            gp.DrawLineFromPoint(target, true);
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            camera = gp.Point();

            var camdir = target - camera;

            camdir.Unitize();
            if (camdir.IsTiny())
            {
                return(Result.Cancel);
            }

            vp.SetCameraLocations(target, camera);
            view.Redraw();

            return(Result.Success);
        }
  public static Rhino.Commands.Result AddNamedView(Rhino.RhinoDoc doc)
  {
    Rhino.Display.RhinoView view;
    Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetView("Select view to adjust", out view);
    if (rc != Rhino.Commands.Result.Success)
      return rc;

    Rhino.Geometry.Point3d location;
    rc = Rhino.Input.RhinoGet.GetPoint("Camera Location", false, out location);
    if (rc != Rhino.Commands.Result.Success)
      return rc;

    Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint();
    gp.SetCommandPrompt("Look At Location");
    gp.DrawLineFromPoint(location, false);
    gp.Get();
    if (gp.CommandResult() != Rhino.Commands.Result.Success)
      return gp.CommandResult();
    Rhino.Geometry.Point3d lookat = gp.Point();
    
    string name = view.ActiveViewport.Name;
    rc = Rhino.Input.RhinoGet.GetString("Name", true, ref name);
    if (rc != Rhino.Commands.Result.Success)
      return rc;

    Rhino.Display.RhinoViewport vp = view.ActiveViewport;
    // save the current viewport projection
    vp.PushViewProjection();
    vp.CameraUp = Rhino.Geometry.Vector3d.ZAxis;
    vp.SetCameraLocation(location, false);
    vp.SetCameraDirection(lookat - location, true);
    vp.Name = name;

    doc.NamedViews.Add(name, vp.Id);
    view.Redraw();
    return Rhino.Commands.Result.Success;
  }
Example #6
0
        protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
        {
            // Select objects to scale
            var list = new Rhino.Collections.TransformObjectList();
            var rc   = SelectObjects("Select objects to scale", list);

            if (rc != Rhino.Commands.Result.Success)
            {
                return(rc);
            }

            Point3d anchor;
            Point3d _ref;
            Plane   plane;

            // Origin point
            var gp = new Rhino.Input.Custom.GetPoint();

            gp.SetCommandPrompt("Origin point");
            var copy = new Rhino.Input.Custom.OptionToggle(m_copy, "No", "Yes");

            gp.AddOptionToggle("Copy", ref copy);
            for (; ;)
            {
                var res = gp.Get();
                if (res == Rhino.Input.GetResult.Point)
                {
                    var view = gp.View();
                    if (view == null)
                    {
                        return(Rhino.Commands.Result.Failure);
                    }
                    plane  = view.ActiveViewport.ConstructionPlane();
                    anchor = gp.Point();
                    break;
                }
                if (res == Rhino.Input.GetResult.Option)
                {
                    continue;
                }

                return(Rhino.Commands.Result.Cancel);
            }

            bool bAcceptDefault = true;

            // Scale factor or first reference point
            gp.SetCommandPrompt("Scale factor or first reference point");
            gp.SetBasePoint(anchor, true);
            gp.DrawLineFromPoint(anchor, true);
            gp.ConstrainToConstructionPlane(true);
            for (; ;)
            {
                if (bAcceptDefault)
                {
                    gp.AcceptNumber(true, false);
                    gp.SetDefaultNumber(m_scale);
                }
                else
                {
                    gp.AcceptNothing(true);
                    gp.ClearDefault();
                }

                var res = gp.Get();
                if (res == Rhino.Input.GetResult.Point)
                {
                    _ref = gp.Point();
                    break;
                }
                if (res == Rhino.Input.GetResult.Number)
                {
                    double       scale      = Math.Abs(gp.Number());
                    const double EPS_DIVIDE = 0.000001;
                    if (scale < EPS_DIVIDE)
                    {
                        continue;
                    }
                    m_scale      = scale;
                    plane.Origin = anchor;

                    var xform = Transform.Scale(plane, m_scale, m_scale, m_scale);
                    TransformObjects(list, xform, copy.CurrentValue, copy.CurrentValue);
                    m_copy = copy.CurrentValue;
                    if (m_copy)
                    {
                        bAcceptDefault = false;
                        continue;
                    }
                    doc.Views.Redraw();
                    return(Rhino.Commands.Result.Success);
                }

                if (res == Rhino.Input.GetResult.Nothing)
                {
                    if (bAcceptDefault == false)
                    {
                        return(Rhino.Commands.Result.Success);
                    }

                    plane.Origin = anchor;
                    var xform = Transform.Scale(plane, m_scale, m_scale, m_scale);
                    TransformObjects(list, xform, copy.CurrentValue, copy.CurrentValue);

                    m_copy = copy.CurrentValue;
                    if (m_copy)
                    {
                        bAcceptDefault = false;
                        continue;
                    }
                    doc.Views.Redraw();
                    return(Rhino.Commands.Result.Success);
                }
                if (res == Rhino.Input.GetResult.Option)
                {
                    continue;
                }
                return(Rhino.Commands.Result.Cancel);
            }

            // Second reference point
            var gx = new GetScaleXform();

            gx.SetCommandPrompt("Second reference point");
            gx.AddOptionToggle("copy", ref copy);
            gx.AddTransformObjects(list);
            gx.SetBasePoint(anchor, true);
            gx.DrawLineFromPoint(anchor, true);
            gx.ConstrainToConstructionPlane(true);
            gx.Plane    = plane;
            gx.RefPoint = _ref;
            gx.AcceptNothing(true);
            gx.AcceptNumber(true, false);

            rc = Rhino.Commands.Result.Cancel;
            for (; ;)
            {
                var res = gx.GetXform();
                if (res == Rhino.Input.GetResult.Point)
                {
                    var view = gx.View();
                    if (view == null)
                    {
                        rc = Rhino.Commands.Result.Failure;
                        break;
                    }
                    var xform = gx.CalculateTransform(view.ActiveViewport, gx.Point());
                    if (xform.IsValid && xform != Transform.Identity)
                    {
                        TransformObjects(list, xform, copy.CurrentValue, copy.CurrentValue);
                        rc      = Rhino.Commands.Result.Success;
                        m_scale = gx.Scale;
                    }
                    m_copy = copy.CurrentValue;
                    if (m_copy)
                    {
                        continue;
                    }

                    break;
                }

                if (res == Rhino.Input.GetResult.Number)
                {
                    var view = gx.View();
                    if (view == null)
                    {
                        rc = Rhino.Commands.Result.Failure;
                        break;
                    }

                    var xform = gx.CalculateTransform(view.ActiveViewport, gx.Number());
                    if (xform.IsValid && xform != Transform.Identity)
                    {
                        TransformObjects(list, xform, copy.CurrentValue, copy.CurrentValue);
                        rc      = Rhino.Commands.Result.Success;
                        m_scale = gx.Scale;
                    }
                    m_copy = copy.CurrentValue;
                    if (m_copy)
                    {
                        continue;
                    }
                    break;
                }

                if (res == Rhino.Input.GetResult.Option)
                {
                    continue;
                }

                break;
            }

            doc.Views.Redraw();
            return(rc);
        }
    protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
    {
        Rhino.DocObjects.ObjRef objref;
        var rc = Rhino.Input.RhinoGet.GetOneObject("Select object", true, Rhino.DocObjects.ObjectType.AnyObject, out objref);

        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }

        rc = Rhino.Input.RhinoGet.GetPoint("Start point", false, out m_point_start);
        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }

        var obj = objref.Object();

        if (obj == null)
        {
            return(Rhino.Commands.Result.Failure);
        }

        // create an instance of a GetPoint class and add a delegate
        // for the DynamicDraw event
        var gp = new Rhino.Input.Custom.GetPoint();

        gp.DrawLineFromPoint(m_point_start, true);
        var  optdouble    = new Rhino.Input.Custom.OptionDouble(m_distance);
        bool constrain    = false;
        var  optconstrain = new Rhino.Input.Custom.OptionToggle(constrain, "Off", "On");

        gp.AddOptionDouble("Distance", ref optdouble);
        gp.AddOptionToggle("Constrain", ref optconstrain);
        gp.DynamicDraw += ArrayByDistanceDraw;
        gp.Tag          = obj;
        while (gp.Get() == Rhino.Input.GetResult.Option)
        {
            m_distance = optdouble.CurrentValue;
            if (constrain != optconstrain.CurrentValue)
            {
                constrain = optconstrain.CurrentValue;
                if (constrain)
                {
                    var gp2 = new Rhino.Input.Custom.GetPoint();
                    gp2.DrawLineFromPoint(m_point_start, true);
                    gp2.SetCommandPrompt("Second point on constraint line");
                    if (gp2.Get() == Rhino.Input.GetResult.Point)
                    {
                        gp.Constrain(m_point_start, gp2.Point());
                    }
                    else
                    {
                        gp.ClearCommandOptions();
                        optconstrain.CurrentValue = false;
                        constrain = false;
                        gp.AddOptionDouble("Distance", ref optdouble);
                        gp.AddOptionToggle("Constrain", ref optconstrain);
                    }
                }
                else
                {
                    gp.ClearConstraints();
                }
            }
        }

        if (gp.CommandResult() == Rhino.Commands.Result.Success)
        {
            m_distance = optdouble.CurrentValue;
            var    pt     = gp.Point();
            var    vec    = pt - m_point_start;
            double length = vec.Length;
            vec.Unitize();
            int count = (int)(length / m_distance);
            for (int i = 1; i < count; i++)
            {
                var translate = vec * (i * m_distance);
                var xf        = Rhino.Geometry.Transform.Translation(translate);
                doc.Objects.Transform(obj, xf, false);
            }
            doc.Views.Redraw();
        }

        return(gp.CommandResult());
    }
    protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
    {
      // Select objects to scale
      var list = new Rhino.Collections.TransformObjectList();
      var rc = SelectObjects("Select objects to scale", list);
      if (rc != Rhino.Commands.Result.Success)
        return rc;

      var anchor = new Point3d();
      var _ref = new Point3d();
      Plane plane = new Plane();

      // Origin point
      var gp = new Rhino.Input.Custom.GetPoint();
      gp.SetCommandPrompt("Origin point");
      var copy = new Rhino.Input.Custom.OptionToggle(m_copy,"No", "Yes");
      gp.AddOptionToggle("Copy", ref copy);
      for (; ; )
      {
        var res = gp.Get();
        if (res == Rhino.Input.GetResult.Point)
        {
          var view = gp.View();
          if (view == null)
            return Rhino.Commands.Result.Failure;
          plane = view.ActiveViewport.ConstructionPlane();
          anchor = gp.Point();
          break;
        }
        if (res == Rhino.Input.GetResult.Option)
          continue;

        return Rhino.Commands.Result.Cancel;
      }

      bool bAcceptDefault = true;

      // Scale factor or first reference point
      gp.SetCommandPrompt("Scale factor or first reference point");
      gp.SetBasePoint(anchor, true);
      gp.DrawLineFromPoint(anchor, true);
      gp.ConstrainToConstructionPlane(true);
      for (; ; )
      {
        if (bAcceptDefault)
        {
          gp.AcceptNumber(true, false);
          gp.SetDefaultNumber(m_scale);
        }
        else
        {
          gp.AcceptNothing(true);
          gp.ClearDefault();
        }

        var res = gp.Get();
        if (res == Rhino.Input.GetResult.Point)
        {
          _ref = gp.Point();
          break;
        }
        if (res == Rhino.Input.GetResult.Number)
        {
          double scale = Math.Abs(gp.Number());
          const double EPS_DIVIDE = 0.000001;
          if (scale < EPS_DIVIDE)
            continue;
          m_scale = scale;
          plane.Origin = anchor;

          var xform = Transform.Scale(plane, m_scale, m_scale, m_scale);
          TransformObjects(list, xform, copy.CurrentValue, copy.CurrentValue);
          m_copy = copy.CurrentValue;
          if (m_copy)
          {
            bAcceptDefault = false;
            continue;
          }
          doc.Views.Redraw();
          return Rhino.Commands.Result.Success;
        }

        if (res == Rhino.Input.GetResult.Nothing)
        {
          if (bAcceptDefault == false)
            return Rhino.Commands.Result.Success;

          plane.Origin = anchor;
          var xform = Transform.Scale(plane, m_scale, m_scale, m_scale);
          TransformObjects(list, xform, copy.CurrentValue, copy.CurrentValue);

          m_copy = copy.CurrentValue;
          if (m_copy)
          {
            bAcceptDefault = false;
            continue;
          }
          doc.Views.Redraw();
          return Rhino.Commands.Result.Success;
        }
        if (res == Rhino.Input.GetResult.Option)
          continue;
        return Rhino.Commands.Result.Cancel;
      }

      // Second reference point
      var gx = new GetScaleXform();
      gx.SetCommandPrompt("Second reference point");
      gx.AddOptionToggle("copy", ref copy);
      gx.AddTransformObjects(list);
      gx.SetBasePoint(anchor, true);
      gx.DrawLineFromPoint(anchor, true);
      gx.ConstrainToConstructionPlane(true);
      gx.Plane = plane;
      gx.RefPoint = _ref;
      gx.AcceptNothing(true);
      gx.AcceptNumber(true, false);

      rc = Rhino.Commands.Result.Cancel;
      for (; ; )
      {
        var res = gx.GetXform();
        if (res == Rhino.Input.GetResult.Point)
        {
          var view = gx.View();
          if (view == null)
          {
            rc = Rhino.Commands.Result.Failure;
            break;
          }
          var xform = gx.CalculateTransform(view.ActiveViewport, gx.Point());
          if (xform.IsValid && xform != Transform.Identity)
          {
            TransformObjects(list, xform, copy.CurrentValue, copy.CurrentValue);
            rc = Rhino.Commands.Result.Success;
            m_scale = gx.Scale;
          }
          m_copy = copy.CurrentValue;
          if (m_copy)
            continue;

          break;
        }

        if (res == Rhino.Input.GetResult.Number)
        {
          var view = gx.View();
          if (view == null)
          {
            rc = Rhino.Commands.Result.Failure;
            break;
          }

          var xform = gx.CalculateTransform(view.ActiveViewport, gx.Number());
          if (xform.IsValid && xform != Transform.Identity)
          {
            TransformObjects(list, xform, copy.CurrentValue, copy.CurrentValue);
            rc = Rhino.Commands.Result.Success;
            m_scale = gx.Scale;
          }
          m_copy = copy.CurrentValue;
          if (m_copy)
            continue;
          break;
        }

        if (res == Rhino.Input.GetResult.Option)
          continue;

        if (res == Rhino.Input.GetResult.Nothing)
          break;

        break;
      }

      doc.Views.Redraw();
      return rc;
    }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // mimic the functionality of the contour command using a background threads
            // The tricky parts to the contour command are that it dynamically adds
            // sections as they are found
            const ObjectType filter = ObjectType.Brep | ObjectType.Extrusion | ObjectType.Mesh;

            ObjRef[] objrefs;
            var      rc = RhinoGet.GetMultipleObjects("Select objects for contours", false, filter, out objrefs);

            if (rc != Result.Success)
            {
                return(rc);
            }
            if (objrefs == null || objrefs.Length < 1)
            {
                return(Result.Failure);
            }

            Point3d base_point;

            rc = RhinoGet.GetPoint("Contour plane base point", false, out base_point);
            if (rc != Result.Success)
            {
                return(rc);
            }
            var gp = new Rhino.Input.Custom.GetPoint();

            gp.SetCommandPrompt("Direction perpendicular to contour planes");
            gp.DrawLineFromPoint(base_point, false);
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }
            Point3d end_point = gp.Point();

            double interval = 1;

            rc = RhinoGet.GetNumber("Distance between contours", true, ref interval, 0.001, 10000);
            if (rc != Result.Success)
            {
                return(rc);
            }

            // figure out the combined bounding box of all the selected geometry
            BoundingBox bounds     = BoundingBox.Unset;
            var         geometries = new List <GeometryBase>();

            foreach (var objref in objrefs)
            {
                var geometry  = objref.Geometry();
                var extrusion = geometry as Extrusion;
                if (extrusion != null)
                {
                    geometry = objref.Brep();
                }
                geometries.Add(geometry);
                var bbox = geometry.GetBoundingBox(false);
                bounds.Union(bbox);
            }

            Vector3d normal = end_point - base_point;

            normal.Unitize();
            var    curplane = new Plane(base_point, normal);
            double min_t, max_t;

            if (!curplane.DistanceTo(bounds, out min_t, out max_t))
            {
                return(Result.Failure);
            }

            min_t -= interval;
            max_t += interval;
            min_t  = Math.Floor(min_t / interval);
            max_t  = Math.Ceiling(max_t / interval);
            double tolerance = doc.ModelAbsoluteTolerance;

            var tasks = new List <Task <Curve[]> >();
            var gc    = new Rhino.Input.Custom.GetCancel();

            for (double t = min_t; t <= max_t; t += 1.0)
            {
                double offset = t * interval;
                var    point  = base_point + normal * offset;
                var    plane  = new Plane(point, normal);
                foreach (var geom in geometries)
                {
                    var geom1 = geom;
                    var task  = Task.Run(() => Section(plane, geom1, tolerance), gc.Token);
                    tasks.Add(task);
                }
            }
            gc.TaskCompleted += OnTaskCompleted;
            rc = gc.WaitAll(tasks, doc);
            return(rc);
        }
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            const ObjectType filter = ObjectType.Brep | ObjectType.Extrusion | ObjectType.Mesh;
            var rc = RhinoGet.GetMultipleObjects("Select objects to contour", false, filter, out var objrefs);

            if (rc != Result.Success)
            {
                return(rc);
            }

            if (objrefs == null || objrefs.Length < 1)
            {
                return(Result.Failure);
            }

            rc = RhinoGet.GetPoint("Contour plane base point", false, out var base_point);
            if (rc != Result.Success)
            {
                return(rc);
            }

            var gp = new Rhino.Input.Custom.GetPoint();

            gp.SetCommandPrompt("Direction perpendicular to contour planes");
            gp.DrawLineFromPoint(base_point, false);
            gp.Get();
            if (gp.CommandResult() != Result.Success)
            {
                return(gp.CommandResult());
            }

            var end_point = gp.Point();

            var interval = 1.0;

            rc = RhinoGet.GetNumber("Distance between contours", true, ref interval, 0.001, 10000);
            if (rc != Result.Success)
            {
                return(rc);
            }

            var bounds     = BoundingBox.Unset;
            var geometries = new List <GeometryBase>();

            foreach (var objref in objrefs)
            {
                var geometry = objref.Geometry();
                if (geometry is Extrusion)
                {
                    geometry = objref.Brep();
                }
                geometries.Add(geometry);
                var bbox = geometry.GetBoundingBox(false);
                bounds.Union(bbox);
            }

            var normal = end_point - base_point;

            normal.Unitize();
            var curplane = new Plane(base_point, normal);

            if (!curplane.DistanceTo(bounds, out var min_t, out var max_t))
            {
                return(Result.Failure);
            }

            min_t -= interval;
            max_t += interval;
            min_t  = Math.Floor(min_t / interval);
            max_t  = Math.Ceiling(max_t / interval);
            var tolerance = doc.ModelAbsoluteTolerance;

            var tasks = new List <Task <Curve[]> >();
            var gc    = new Rhino.Input.Custom.GetCancel();

            for (var t = min_t; t <= max_t; t += 1.0)
            {
                var offset = t * interval;
                var point  = base_point + normal * offset;
                var plane  = new Plane(point, normal);
                foreach (var geom in geometries)
                {
                    var geom1 = geom;
                    var task  = Task.Run(() => Section(plane, geom1, tolerance), gc.Token);
                    tasks.Add(task);
                }
            }
            gc.TaskCompleted += OnTaskCompleted;
            rc = gc.WaitAll(tasks, doc);
            return(rc);
        }