美文网首页狮猿社_Rhino
RhinoCommon 创建Contour Curves

RhinoCommon 创建Contour Curves

作者: 锦囊喵 | 来源:发表于2020-03-30 09:47 被阅读0次

    以下代码展示,如何对所选物体创建Contour Curves:

    partial class Examples
    {
      public static Result ContourCurves(RhinoDoc doc)
      {
        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");
        gp.Get();
        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");
        gp.Get();
        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);
          }
          else
          {
            curves = Mesh.CreateContourCurves(geometry as Mesh, base_point, end_point, interval);
          }
    
          foreach (var curve in curves)
          {
            var curve_object_id = doc.Objects.AddCurve(curve);
            doc.Objects.Select(curve_object_id);
          }
        }
    
        if (curves != null)
          doc.Views.Redraw();
        return Result.Success;
      }
    }
    

    https://developer.rhino3d.com/samples/rhinocommon/create-contour-curves/

    相关文章

      网友评论

        本文标题:RhinoCommon 创建Contour Curves

        本文链接:https://www.haomeiwen.com/subject/oyemuhtx.html