Hello everyone,
I’m working with a Trimmed Surface and need help with the following tasks using C#:
- Extract the Surface and OuterLoop from the Trimmed Surface (this part is already implemented in my code).
- Split the Surface in half along the U direction.
- Apply the same OuterLoop to the resulting two surfaces.
Here is the code I have so far:
public static Brep[] Subdivide(Brep brep)
{
BrepFace brepFace = brep.Faces[0];
Surface surface = brepFace.UnderlyingSurface() ?? throw new Exception("Surface extraction failed");
BrepLoop outerLoop = brepFace.OuterLoop;
var domainU = surface.Domain(0);
var domainV = surface.Domain(1);
Interval domainU1 = new Interval(domainU.Min, domainU.Mid);
Interval domainU2 = new Interval(domainU.Mid, domainU.Max);
Surface surface1 = surface.Trim(domainU1, domainV);
Surface surface2 = surface.Trim(domainU2, domainV);
Brep brep1 = Brep.CreateFromSurface(surface1);
Brep brep2 = Brep.CreateFromSurface(surface2);
// Here you need to apply the outerLoop to the new Breps
return new Brep[] { brep1, brep2 };
}
Could someone please provide guidance or a code snippet on how to apply the extracted OuterLoop to the two new surfaces after splitting them?
Thank you in advance for your help!
Below are images showing how this should look in Rhino:
Additionally, here is how this can be achieved using Grasshopper components:
Definition.gh (41.5 KB)
Best regards,
Klimenko Petr