CreateFromBrep hang

Hi,

My plugin is converting breps into meshes but sometimes it just fails. In such cases the CreateFromBrep just hangs on this line and it never goes further. I was using different meshing parameters but nothing seem to be working. Attached is also the test model which is failing.

Let me add that I’m using Rhinoceros 8 while in Rhinoceros 6 I had no such problems.


test.3dm (118.2 KB)

Hey @karol.wierzbicki,

Is there any reason you don’t use the Mesh.CreateFromBrep method in RhinoCommon?

This is exactly what I’m using

image

Hi @karol.wierzbicki,

Can you share your code so we don’t have to re-type?

Also, if you move your polysurface to the world origin, do you get results?

– Dale

So the example can be as simple as this and it will fail for the geometry I have attached in first post.
The coordinates system is always set to World. I’m not sure if you ask me to set it also programmatically?

Result Run(RhinoDoc doc)
{
    var go = new GetObject();
    go.SetCommandPrompt("Select...");

    go.GetMultiple(1, 0);
    if (go.CommandResult() != Result.Success)
        return go.CommandResult();

    DocObjects.ObjRef[] objRefs = go.Objects();
    if (objRefs == null)
        return Result.Nothing;


    while (true)
    {
        GetResult gr = gi.Get();
        if (gr == GetResult.Cancel)
            break;
    }

        var shape = objRefs[0].Geometry() as Brep;
        MeshingParameters mp = new MeshingParameters();
        mp.RelativeTolerance = 0; // Density
        mp.GridAngle = RhinoMath.ToRadians(5); // maximum angle
        mp.GridAspectRatio = 3; // Maximum aspect ratio
        mp.MinimumEdgeLength = 1; // Minimum Edge Length
        mp.MaximumEdgeLength = 5; // Maximum Edge Length
        mp.Tolerance = 0.1; // Max distance, edge to surface
        mp.GridMinCount = 50; // Minimum initial grid quads
        mp.RefineGrid = true; // Refine grid
        mp.JaggedSeams = false; // jagged seams
        mp.SimplePlanes = true; // simple planes
        var compMeshes = Mesh.CreateFromBrep(shape, mp);

    return Result.Success;
}

By the way separate issue is that when I use go.GetMultiple(1, 0); Rhino will hang when only one object is selected.

Hi @karol.wierzbicki,

Rhino’s meshes doesn’t hang. Rather, based on your meshing parameters its making a large mesh that takes time to compute.

 Rhino object: mesh
  ON_Mesh: vertex count = 4006658  facet count = 4035651

image

– Dale

1 Like

Yes, now after changing parameters I get the mesh. Thank you.