Surface Division

Hello.
I want to divide a mesh into a certain number of divisions in U and V directions, just like what the Mesh UV component in Grasshopper does. However, I can’t find any methods or properties in the rhino api (C#) that will do it for me.
Does anyone have any suggestions?

Thanks

I am not familiar with this. Can you upload a .GH file that uses this?

Thanks,

– Dale

I uploaded the file here. It is a very simple use of this component which can give points in u and v directions.
Example.gh (3.7 KB)

Hi @Sina_Khalilvandi_Beh,

OK, the “Mesh” division threw me off, as the component you’re interested in divides surfaces, not meshes.

There a simple example:

private Point3d[] DivideSurfaceBySegments(Surface surface, int uCount, int vCount)
{
  if (null == surface || uCount < 2 || vCount < 2)
    return new Point3d[0];

  var domainU = surface.Domain(0);
  var domainV = surface.Domain(1);

  var stepU = (domainU.Max - domainU.Min) / uCount;
  var stepV = (domainV.Max - domainV.Min) / vCount;

  var points = new List<Point3d>();

  for (var vi = 0; vi < vCount + 1; vi++)
  {
    for (var ui = 0; ui < uCount + 1; ui++)
    {
      var u = domainU.Min + stepU * ui;
      var v = domainV.Min + stepV * vi;
      points.Add(surface.PointAt(u, v));
    }
  }

  return points.ToArray();
}

– Dale

1 Like

If that’s the case, the title should be changed to something like “divide surface script”

Thanks @dale
It helped me a lot.

Best

1 Like