The second method offers the possibility to consider mesh facets coplanar when the angle between them is under a certain value. This allows to build much simpler shapes: (let's assume our document contains one Mesh object)

{{Code|code=

{{Code|code=

# let's assume our document contains one Mesh object

# let's assume our document contains one Mesh object

−

import Mesh,Part,MeshPart

+

import Mesh

+

import Part

+

import MeshPart

+

faces = []

faces = []

mesh = App.ActiveDocument.ActiveObject.Mesh

mesh = App.ActiveDocument.ActiveObject.Mesh

Line 68:

Line 107:

# we assume that the exterior boundary is that one with the biggest bounding box

# we assume that the exterior boundary is that one with the biggest bounding box

# let's assume our document contains one Part objectimportMeshfaces=[]shape=FreeCAD.ActiveDocument.ActiveObject.Shapetriangles=shape.tessellate(1)# the number represents the precision of the tessellationfortriintriangles[1]:face=[]foriintri:face.append(triangles[0][i])faces.append(face)m=Mesh.Mesh(faces)Mesh.show(m)

# let's assume our document contains one Mesh objectimportMeshimportPartimportMeshPartfaces=[]mesh=App.ActiveDocument.ActiveObject.Meshsegments=mesh.getPlanes(0.00001)# use rather strict tolerance hereforiinsegments:iflen(i)>0:# a segment can have inner holeswires=MeshPart.wireFromSegment(mesh,i)# we assume that the exterior boundary is that one with the biggest bounding boxiflen(wires)>0:ext=Nonemax_length=0foriinwires:ifi.BoundBox.DiagonalLength>max_length:max_length=i.BoundBox.DiagonalLengthext=iwires.remove(ext)# all interior wires mark a hole and must reverse their orientation, otherwise Part.Face failsforiinwires:i.reverse()# make sure that the exterior wires comes as first in the listwires.insert(0,ext)faces.append(Part.Face(wires))shell=Part.Compound(faces)Part.show(shell)# solid = Part.Solid(Part.Shell(faces))# Part.show(solid)