`MeshParameter` or `MeshFaceParameter` classes?

Hi there!

I noticed the “Mesh Closets Point (MeshCP)” component outputs a “MeshParameter” type object:


Is this type publicly exposed in RhinoCommon? I noticed there are MeshParameter and MeshFaceParameter registrations for components in the GH SDK, but cannot find a mirroring type in RC (or the GH SDK for the same matter)…



It’s a type defined inside the SurfaceComponents.gha standard plug-in.

So, it is not accessible via a standard C# Script component, right?

You can access it, that Parameter object must be a Grasshopper Type that is a wrapper for the RhinoCommon MeshPoint class, as David specified above. Also, that Parameter object is just represented as a .NET string class. If you have a look at the RhinoCommon documentation you can find the answer for yourself:

MeshPoint class:

Mesh class / ClosestMeshPoint() method


So here I recreated a sample code to illustrate you what is happening behind the scenes on the fly

 private void RunScript(Mesh x, Point3d y, object z, ref object A, ref object B)

    // Here we verify that the Parameter type is actually just a string representation
    var p = (string) z;

    // Here we get the MeshPoint object
    MeshPoint cMp = x.ClosestMeshPoint(y, double.MaxValue);

    // Here is my sample wrapper that will output the same representation as the
    // Grasshopper type does
    MeshPointWrapper mPW = new MeshPointWrapper(cMp);

    A = mPW;
    B = cMp.Point;

  // <Custom additional code> 
  public class MeshPointWrapper
    private readonly MeshPoint m_meshPoint;

    public MeshPointWrapper(MeshPoint meshPoint)
      m_meshPoint = meshPoint;

    private string BarycentricQuadCoordinates()
      double [] t = m_meshPoint.T;

      string stringRep = "";

      for (int i = 0; i < t.Length; i++)
        stringRep += t[i].ToString() + ";";

      return stringRep;

    public override string ToString()
      return m_meshPoint.FaceIndex.ToString() + "[" + BarycentricQuadCoordinates() + "]" ;


  // </Custom additional code> 

Hi @rawitscher-torres,

Thanks for the sample. Indeed, stringifying a representation of the MeshPoint class is a problem, like you did or trying to get the rounding even closer to the native implementation:

string meshParamString = mp.FaceIndex + "["
      + String.Format("{0:0.000###}", v[0]) + ";"
      + String.Format("{0:0.000###}", v[1]) + ";"
      + String.Format("{0:0.000###}", v[2]) + ";"
      + String.Format("{0:0.000###}", v[3]) + "]";

The problem is however, that we need a native .NET MeshParameter object if the type David specifies, since we need to interface with the native “Evaluate Mesh” for example, which only takes this class (and will not accept the object serialized into a string…)

Yeah, I also agree that a string serialization does not make much sense to have. Maybe David has a reason on why he left it as such in the Grasshopper world. But why don’t you just bypass the gh components and just do want you want to do through C# You can freely access everything you need through RhinoCommon. In the Mesh class you have everything you need to quickly recreate the same behavior that you have exposed in the Mesh components in Grasshopper

I know, I wish I could, but it is just how the workflow is setup… :frowning:

And which workflow might that be? But anyways now you know that the MeshPoint class contains all the info that the parameter object has and other properties as well.