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?
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)
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.
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).
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;
}