How do I get the coordinates of the split faces?

I have created a geometry created with the Box command and split one of its faces into two with the SplitFace command.
To get the coordinates of the split faces from this geometry, I do the following.


private static string ConvertGeometryToPointList(GeometryBase geo)
{
    int no = 0;
    var text = "";
    var brep = geo as Brep;
    var surfaces = brep.Surfaces;
    foreach(var surface in surfaces)
    {
        no++;
        var vartices = surface.ToNurbsSurface().Points;
        text += $"No.{no.ToString().PadLeft(3)}";
        foreach (var vartex in vartices)
        {
            text += $"{vartex.Location.ToString().PadLeft(10)} ";
        }
        text += "\n";
    }

    return text;
}

However, the coordinates of the split faces are exactly the same.
No. 4 and 7 are the coordinates of the two split faces. Both of them seem to be the coordinates of the surface before it was split.

How can I get the coordinates of each of the split faces?

See attached.

BrepFace_Split_WithPlane_EntryLevel_V0.gh (21.5 KB)

BTW: Found 3 minutes more, added a Trim option (+ flip > see R SDK).

BrepFace_TrimSplit_WithPlane_EntryLevel_V0.gh (144.4 KB)

Thanks for the reply.
I assume you are splitting the surface with the following code

pieces = b.Split(splitter, tol);

In my case, the surface is already split by Rhino commands already.
How can I get the split surfaces in this case?
split_surface.3dm (63.6 KB)

RhinoCommon Surface means untrimmed surface.

Therefore, simply importing a surface as a Surface will automatically untrim it.

If you want to treat it as trimmed, import it as a Brep.
If you want to untrim itself, you need to Shrink in this case.

Or you can use the [ShrinkTrimmedSrf] command in rhino.

shrink.gh (11.4 KB)

1 Like

Assuming that you can read code see how the Vertices are sampled in the V Tree.

i.e.

PS: ALWAYS treat your items as Breps/BrepFaces (general case). For a given BrepFace a Surface is just the underlying “template” (so to speak) meaning the obvious (no Trim data, no actual Vertices blah, blah)

1 Like

Thanks for your sample. Unfortunately, the .gh file could not be opened properly in my Windows environment.
Is this a difference between Mac and Windows environments?

Anyway, your video was very informative and I could understand the difference between Trimmed/Untrimmed surfaces.
I apparently need to learn more about Rhino,Grasshopper data structures.

Many thanks.

1 Like

Pfotiad0,
Thanks for your comment.
Your comments were very helpful in extracting the vertices from the BrepFaces.

In general I would suggest to dig in (via R SDK) on similar matters, terminology … blah, blah (plus managing DataTrees via code - IF you have plans to do business that way).

1 Like

The gh file above was a Rhino8 file.
The Rhino7 file can be found here.

shrink_V7.gh (7.9 KB)

1 Like

Pfotiad0, Masaki,

Thank you guys, both of you. Your comments were very helpful.
And finally I got the coordinates as I intended.

Many thanks!

  private void RunScript(List<GeometryBase> Geometries, ref object A)
  {
    string text = "";
    foreach (var geo_org in Geometries)
    {
      if (geo_org is Brep)
      {
        var geo = geo_org.Duplicate(); //Constructs a deep (full) copy of this object.

        int no = 0;
        Brep brep = geo as Brep;
        brep.Faces.ShrinkFaces(); //Shrinks all the underlying surfaces in this Brep.

        foreach(BrepFace face in brep.Faces)
        {
          no++;
          text += "No" + no.ToString().PadLeft(3);
          foreach (var v in face.ToBrep().Vertices)
          {
            text += v.Location.ToString().PadLeft(8);
          }
          text += "\n";
        }
      }
    }
    A = text;


  }


Get_vertices_from_geometries_2.gh (8.8 KB)
split_surface.3dm (57.8 KB)

1 Like