Click or drag to resize

MeshCreateContourCurves Method (Mesh, Point3d, Point3d, Double, Double)

Constructs contour curves for a mesh, sectioned along a linear axis.

Namespace:  Rhino.Geometry
Assembly:  RhinoCommon (in RhinoCommon.dll)
Since: 7.13
public static Curve[] CreateContourCurves(
	Mesh meshToContour,
	Point3d contourStart,
	Point3d contourEnd,
	double interval,
	double tolerance


Type: Rhino.GeometryMesh
A mesh to contour.
Type: Rhino.GeometryPoint3d
A start point of the contouring axis.
Type: Rhino.GeometryPoint3d
An end point of the contouring axis.
Type: SystemDouble
An interval distance.
Type: SystemDouble
A tolerance value. If negative, the positive value will be used. WARNING! Good tolerance values are in the magnitude of 10^-7, or RhinoMath.SqrtEpsilon*10. See comments at MeshIntersectionsTolerancesCoefficient

Return Value

Type: Curve
An array of curves. This array can be empty.
using System;
using Rhino;
using Rhino.DocObjects;
using Rhino.Geometry;
using Rhino.Input;
using Rhino.Input.Custom;
using Rhino.Commands;

namespace examples_cs
  public class ContourCommand : Command
    public override string EnglishName { get { return "csContour"; } }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
      var filter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Mesh;
      ObjRef[] obj_refs;
      var rc = RhinoGet.GetMultipleObjects("Select objects to contour", false, filter, out obj_refs);
      if (rc != Result.Success)
        return rc;

      var gp = new GetPoint();
      gp.SetCommandPrompt("Contour plane base point");
      if (gp.CommandResult() != Result.Success)
        return gp.CommandResult();
      var base_point = gp.Point();

      gp.DrawLineFromPoint(base_point, true);
      gp.SetCommandPrompt("Direction perpendicular to contour planes");
      if (gp.CommandResult() != Result.Success)
        return gp.CommandResult();
      var end_point = gp.Point();

      if (base_point.DistanceTo(end_point) < RhinoMath.ZeroTolerance)
        return Result.Nothing;

      double distance = 1.0;
      rc = RhinoGet.GetNumber("Distance between contours", false, ref distance);
      if (rc != Result.Success)
        return rc;

      var interval = Math.Abs(distance);

      Curve[] curves = null;
      foreach (var obj_ref in obj_refs)
        var geometry = obj_ref.Geometry();
        if (geometry == null)
          return Result.Failure;

        if (geometry is Brep)
          curves = Brep.CreateContourCurves(geometry as Brep, base_point, end_point, interval);
          curves = Mesh.CreateContourCurves(geometry as Mesh, base_point, end_point, interval);

        foreach (var curve in curves)
          var curve_object_id = doc.Objects.AddCurve(curve);

      if (curves != null)
      return Result.Success;
from System import *
from Rhino import *
from Rhino.DocObjects import *
from Rhino.Geometry import *
from Rhino.Input import *
from Rhino.Input.Custom import *
from Rhino.Commands import *
from scriptcontext import doc

def RunCommand():
  filter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Mesh
  rc, obj_refs = RhinoGet.GetMultipleObjects("Select objects to contour", False, filter)
  if rc <> Result.Success:
    return rc

  gp = GetPoint()
  gp.SetCommandPrompt("Contour plane base point")
  if gp.CommandResult() <> Result.Success:
    return gp.CommandResult()
  base_point = gp.Point()

  gp.DrawLineFromPoint(base_point, True)
  gp.SetCommandPrompt("Direction perpendicular to contour planes")
  if gp.CommandResult() <> Result.Success:
    return gp.CommandResult()
  end_point = gp.Point()

  if base_point.DistanceTo(end_point) < RhinoMath.ZeroTolerance:
    return Result.Nothing

  distance = 1.0
  rc, distance = RhinoGet.GetNumber("Distance between contours", False, distance)
  if rc <> Result.Success:
    return rc

  interval = Math.Abs(distance)

  for obj_ref in obj_refs:
    geometry = obj_ref.Geometry()
    if geometry == None:
      return Result.Failure

    if type(geometry) == Brep:
      curves = Brep.CreateContourCurves(geometry, base_point, end_point, interval)
      curves = Mesh.CreateContourCurves(geometry, base_point, end_point, interval)

    for curve in curves:
      curve_object_id = doc.Objects.AddCurve(curve)

  if curves <> None:
  return Result.Success

if __name__ == "__main__":
See Also