Grasshopper

algorithmic modeling for Rhino

I'm trying to write a C# component to combine a few steps in my workflow. One part involves using the 'mesh surface (mesh UV)' command. However I cannot seem to find a similiar command in the rhinocommon sdk. It approximates surfaces well enough for my needs and has the nice property of producing a square grid. Does anyone know what it is doing so that I can replicate it?

Views: 3229

Replies to This Discussion

I wrote that one from scratch. It just divides the surface UV domain into equal parameter spans and connects those into a grid. The optional smoothing is a different algorithm that is a lot slower.

--

David Rutten

david@mcneel.com

Hi Hugh

There is no one-line equivalent in the RhinoCommon SDK. What the component does, is running along the surface UV and evaluating points. Then, if these points are actually not trimmed away, it adds the corresponding face.

Does it help?

Thanks

Giulio

--

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Thank you for the help. I have been able to evaluate a point on the surface based on UV. However I am having a little difficulty checking whether the point is trimmed. Might you be able to point me in the right direction please?

By the way this is the code I have used to find a point with UV:

Interval U = x.Domain(0);
Interval V = x.Domain(1);
y = U.ParameterAt(y);
z = V.ParameterAt(z);
Point3d p = x.PointAt(y, z);

BrepFace.IsPointOnFace(u,v)

--

David Rutten

david@mcneel.com

Hmmm, doesn't seem to be omitting any points. Am I doing something stupid here?

  private void RunScript(Surface x, int y, ref object A)
  {
    double tol = 0.0001;
    bool planarTest = x.IsPlanar(tol);
    if(planarTest == false)
      return;

    Brep b = x.ToBrep();
    BrepFace bf = b.Faces[0];

    Interval U = bf.Domain(0);
    Interval V = bf.Domain(1);

    List<Point3d> plist = new List<Point3d>();

    for(int i = 0; i <= y; i++)
    {
      double u = Convert.ToDouble(i) / Convert.ToDouble(y);
      
      for(int j = 0; j <= y; j++)
      {
        double v = Convert.ToDouble(j) / Convert.ToDouble(y);

        double uu = U.ParameterAt(u);
        double vv = V.ParameterAt(v);

        PointFaceRelation onFace = bf.IsPointOnFace(uu, vv);
        if(onFace == PointFaceRelation.Interior)
        {
          Point3d p = bf.PointAt(uu, vv);
          plist.Add(p);
        }
      }
    }
    A = plist;
  }

Surfaces in RhinoCommon do not support trims, so if you set the type hint to Surface you'll get an untrimmed surface. Instead, set the type hint to Brep and access the first face directly.

--

David Rutten

david@mcneel.com

Ah of course :S Thanks for the help, seems to be working just fine now!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service