Brep.CreatePlanarBreps weirdness - bug?

I’ve been running into this issue in C# but I’ve been testing it now in python and seem to run into the same problem there.

I tried to filter out the problem which I’m running into but basically what I’m trying to do is the following. I want to take a mesh as an input, then create a meshoutline from topview, then use those curves to create a planar surface.

Unfortunately something goes wrong in the last process when I use the Brep.CreatePlanarBreps Method on the generated curves and I’m getting the following instead (on the left):

I don’t get what the problem is here as it only used one of the curves to generate the planar surface even though the method gets both curves as input. What’s even weirder is that when I add the curves to the Rhino document and afterwards use a testscript to take the curves and use the same method, I do end up with the correct result. But due to potentiel performance issues, I’d like to not use this workaround as a solution. Anybody that could give some insights into what’s going on here?

240707 CreateOulinesProblem.py (827 Bytes)
240707 CreateOutlines.3dm (3.0 MB)

@dale could you have a look at this, or do you know who else I could ask?

In your method, you’re using b to create the surface, instead of the list of curves

1 Like

Hi @siemen,

Maybe this?

import Rhino
import scriptcontext as sc

def get_mesh_object():
    filter = Rhino.DocObjects.ObjectType.Mesh
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select a mesh", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success:
        return None
    return objref.Mesh()

mesh = get_mesh_object()
if mesh:
    curves = []
    polylines = mesh.GetOutlines(Rhino.Geometry.Plane.WorldXY)
    for p in polylines:
        curves.append(p.ToPolylineCurve())
    
    breps = Rhino.Geometry.Brep.CreatePlanarBreps(curves, sc.doc.ModelAbsoluteTolerance)
    if breps:
        for b in breps:
            id = sc.doc.Objects.AddBrep(b)
            obj = sc.doc.Objects.FindId(id)
            if obj:
                obj.Select(True)
        sc.doc.Views.Redraw()

– Dale

1 Like

Ok so apparently I cannot recreate the issue in Python. In C# I’m not getting the correct surface and I checked that I’m giving the two curves into the method. I guess I’ll need to dig a bit more and try to filter out this specific part of the code. Possibly I’ll find what I’m doing wrong in the process but I hope it actually is something outside of my code being wrong since I’ve been looking at this for quite some time now :smiling_face_with_tear:

It is something in my code which I need to solve. Sorry for bothering you guys and thanks for the help again. @Gijs @dale