30 lines
788 B
Python
30 lines
788 B
Python
import FreeCAD as App
|
|
import Part
|
|
|
|
|
|
class SimpleCopyPartModel:
|
|
id = None
|
|
copyLink = None
|
|
label = None
|
|
part = None
|
|
|
|
def getPart(self):
|
|
return self.part
|
|
|
|
def __init__(self, part) -> None:
|
|
try:
|
|
from random import randrange
|
|
self.id = str(randrange(1000000))
|
|
childObj = part
|
|
__shape = Part.getShape(
|
|
childObj, '', needSubElement=False, refine=False)
|
|
obj = App.ActiveDocument.addObject('Part::Feature', self.id)
|
|
obj.Shape = __shape
|
|
self.part = obj
|
|
self.label = obj.Label
|
|
App.ActiveDocument.recompute()
|
|
except Exception as e:
|
|
print(e)
|
|
|
|
def remove(self):
|
|
App.ActiveDocument.removeObject(self.label)
|