Getting Null Mesh

Mesh mesh = face.GetMesh(MeshType.Default);

I taking face from a face list but this mesh is null.

Hey @Rushank you’ll need to provide a lot more info to get an answer to your question.

  • Do you have a file associated with this issue that you can include?
  • Do you have some more of the code you’re writing?
  • What are you trying to achieve?

– cs

Hi @Rushank,

If the Brep has never been tesselated, then this is a valid return value.

– Dale

@csykes here is a piece of code I am using, this is part one of the functions in workflows.

Brep brepbody = new Brep();
            List<BrepEdge> points = new List<BrepEdge>();
            foreach (BrepFace face in brepfacelist)
            {
                //      BrepFace face = body.Faces.ElementAt(faceindex);



                Mesh mesh = face.GetMesh(MeshType.Default);
                QuadRemeshParameters quadparam = new QuadRemeshParameters();
                quadparam.PreserveMeshArrayEdgesMode = 2;
                quadparam.TargetEdgeLength = 0.5;



                Mesh quadmesh = mesh.QuadRemesh(quadparam);

I have a list of BrepFaces “brepfacelist” and I want to get mesh for the face.
@dale, Can some changes in code guarentee it will work , when this snippet is run in script editor from grasshopper, it works. I have made a workflow, how can I make it work now?
I also read your post test_getmeshes but I need the mesh for my code to work.

Hi @Rushank,

Like I said, Brepface.GetMesh can return null. This usually happens when you create a Brep from scratch and do not add it to the document, where Rhino will create a render mesh and cache it on the faces of the Brep.

If you have a Brep and you need a mesh, use Mesh.CreateFromBrep.

If you add the Brep to the document and there isn’t a shaded viewport, which forces meshing, you can use BrepObject.CreateMeshes.

– Dale

Hi @dale Mesh.CreateFromBrep worked.