import FreeCAD as App import uuid import Mesh import Part # import PartGui import MeshPart class MeshPartModel: id = None mesh = None def __init__(self, part) -> None: try: from random import randrange self.id = 'mesh' + str(randrange(1000000)) document = App.ActiveDocument mesh = document.addObject("Mesh::Feature", self.id) shape = Part.getShape(part, "") mesh.Mesh = MeshPart.meshFromShape( Shape=shape, LinearDeflection=20, AngularDeflection=0.1, Relative=False) mesh.Label = self.id self.mesh = mesh except Exception as e: print(e) pass def remove(self): try: App.ActiveDocument.removeObject(self.mesh.Label) except Exception as e: print(e)