Mesh to Part

Convert Part objects to meshes
Converting higher-level objects such as Part shapes to simpler objects such as meshes is a pretty simple operation where all faces of a Part object get triangulated. The result of that triangulation (tessellation) is then used to construct a mesh:

The following code assumes our document contains one Part object.

Sometimes the triangulation of certain faces offered by OpenCascade is quite ugly. If the face has a rectangular parameter space and doesn't contain any holes or other trimming curves you can also create a mesh manually:

Convert meshes to Part objects
Converting meshes to Part objects is a very common operation. Very often you will receive 3D data in a mesh format. Meshes are very practical for representing free-form geometry and big visual scenes, as they are very lightweight. But in FreeCAD we generally prefer higher-level objects, solids, that can carry much more information and allow for curved faces.

Converting meshes to those higher-level objects (handled by the Part Module in FreeCAD) is not an easy operation. Meshes can be made of thousands of triangles (for example when generated by a 3D scanner), and having solids made of the same number of faces would be extremely heavy to manipulate. So you generally want to optimize the object when converting.

FreeCAD currently offers two methods to convert meshes to Part objects. The first method is a simple, direct conversion without any optimization:

The second method offers the possibility to consider mesh facets co-planar when the angle between them is under a certain value. This allows to build much simpler shapes:

The following code assumes our document contains one Mesh object.