import BOPTools.JoinFeatures
import FreeCAD as App
import uuid


class ConnectedPartModel:
    name = None
    id = None
    solid = None

    def __init__(self, part) -> None:
        try:
            self.id ='part' + str(uuid.uuid4())
            j = BOPTools.JoinFeatures.makeConnect(name=self.id)
            if (type(part) is list):
                j.Objects = part
            else:
                j.Objects = [part]
            j.Proxy.execute(j)
            j.purgeTouched()
            self.solid = j
            App.ActiveDocument.recompute()
        except Exception as e:
            print(e)
        pass

    def remove(self):
        try:
            App.ActiveDocument.removeObject(self.solid.Label)
        except Exception as e:
            print(e)


 