42 lines
1 KiB
Python
42 lines
1 KiB
Python
import FreeCAD as App
|
|
from helper.is_solid import is_object_solid
|
|
|
|
|
|
class AssemblyParseUseCase:
|
|
_parts = []
|
|
_asm = []
|
|
|
|
def __init__(self) -> None:
|
|
self.initParse()
|
|
pass
|
|
|
|
|
|
|
|
def initParse(self):
|
|
for el in App.ActiveDocument.Objects:
|
|
if(is_object_solid(el)):
|
|
self._asm.append(el.Label)
|
|
|
|
def toJson(self):
|
|
return str(self._asm).replace('\'', "\"")
|
|
|
|
def getSubPartsLink(self, group):
|
|
groupLink = {}
|
|
for el in group:
|
|
if (is_object_solid(el)):
|
|
if str(el.Shape).find('Solid') != -1:
|
|
if groupLink.get(el.Label) == None:
|
|
groupLink[el.Label] = []
|
|
for i in el.Group:
|
|
|
|
if str(i).find('Pad') != -1:
|
|
groupLink[el.Label].append(i)
|
|
if groupLink.__len__() == 0:
|
|
return None
|
|
return groupLink
|
|
|
|
def getLinkedProperty(self):
|
|
return self._asm
|
|
|
|
|
|
|