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 straightforward 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 an active Part object.

Alternative example:

The following code assumes our document contains an active Part object.

Convert meshes to Part objects
Converting meshes to Part objects is a common operation. Very often you will receive 3D data in a mesh format. Meshes are quite 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 contain thousands of triangles (for example when generated by a 3D scanner), and solids made of the same number of faces would be extremely difficult 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, reducing the number of faces in the final result:

The following code assumes our document contains an active Mesh object.