Click or drag to resize

SurfaceIsoCurve Method

Gets isoparametric curve.

Namespace:  Rhino.Geometry
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 5.0
Syntax
public Curve IsoCurve(
	int direction,
	double constantParameter
)

Parameters

direction
Type: SystemInt32
0 first parameter varies and second parameter is constant e.g., point on IsoCurve(0,c) at t is srf(t,c) This is a horizontal line from left to right 1 first parameter is constant and second parameter varies e.g., point on IsoCurve(1,c) at t is srf(c,t This is a vertical line from bottom to top.
constantParameter
Type: SystemDouble
The parameter that was constant on the original surface.

Return Value

Type: Curve
An isoparametric curve or null on error.
Remarks
In this function "direction" indicates which direction the resulting curve runs. 0: horizontal, 1: vertical In the other Surface functions that take a "direction" argument, "direction" indicates if "constantParameter" is a "u" or "v" parameter.
Examples
using Rhino;
using Rhino.DocObjects;
using Rhino.Commands;
using Rhino.Input;
using Rhino.Input.Custom;
using Rhino.Geometry;

namespace examples_cs
{
  public class ExtractIsocurveCommand : Rhino.Commands.Command
  {
    public override string EnglishName
    {
      get { return "csExtractIsocurve"; }
    }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      ObjRef obj_ref;
      var rc = RhinoGet.GetOneObject("Select surface", false, ObjectType.Surface, out obj_ref);
      if (rc != Result.Success || obj_ref == null)
        return rc;
      var surface = obj_ref.Surface();

      var gp = new GetPoint();
      gp.SetCommandPrompt("Point on surface");
      gp.Constrain(surface, false);
      var option_toggle = new OptionToggle(false, "U", "V");
      gp.AddOptionToggle("Direction", ref option_toggle);
      Point3d point = Point3d.Unset;
      while (true)
      {
        var grc = gp.Get();
        if (grc == GetResult.Option)
          continue;
        else if (grc == GetResult.Point)
        {
          point = gp.Point();
          break;
        }
        else
          return Result.Nothing;
      }
      if (point == Point3d.Unset)
        return Result.Nothing;

      int direction = option_toggle.CurrentValue ? 1 : 0; // V : U
      double u_parameter, v_parameter;
      if (!surface.ClosestPoint(point, out u_parameter, out v_parameter)) return Result.Failure;

      var iso_curve = surface.IsoCurve(direction, direction == 1 ? u_parameter : v_parameter);
      if (iso_curve == null) return Result.Failure;

      doc.Objects.AddCurve(iso_curve);
      doc.Views.Redraw();
      return Result.Success;
    }
  }
}
Python
from Rhino import *
from Rhino.DocObjects import *
from Rhino.Commands import *
from Rhino.Input import *
from Rhino.Input.Custom import *
from Rhino.Geometry import *
from scriptcontext import doc

def RunCommand():
  rc, obj_ref = RhinoGet.GetOneObject("Select surface", False, ObjectType.Surface)
  if rc <> Result.Success or obj_ref == None:
    return rc
  surface = obj_ref.Surface()

  gp = GetPoint()
  gp.SetCommandPrompt("Point on surface")
  gp.Constrain(surface, False)
  option_toggle = OptionToggle(False, "U", "V")
  gp.AddOptionToggle("Direction", option_toggle)
  point = Point3d.Unset

  while True:
    grc = gp.Get()
    if grc == GetResult.Option:
      continue
    elif grc == GetResult.Point:
      point = gp.Point()
      break
    else:
      return Result.Nothing

  if point == Point3d.Unset:
    return Result.Nothing

  direction = 1 if option_toggle.CurrentValue else 0
  b, u_parameter, v_parameter = surface.ClosestPoint(point)
  if not b: return Result.Failure

  iso_curve = surface.IsoCurve(direction, u_parameter if direction == 1 else v_parameter)
  if iso_curve == None: 
    return Result.Failure

  doc.Objects.AddCurve(iso_curve)
  doc.Views.Redraw()
  return Result.Success

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