kiconnect/freecad/kiconnect/commands/Syncable.py

43 lines
1.1 KiB
Python

import FreeCADGui as Gui
class Syncable:
SYNCABLES = [ 'KiConnect::Project', 'KiConnect::Board', 'KiConnect::Parts', 'KiConnect::BoardBody', ]
def IsActive(self):
sel = Gui.Selection.getSelection()
if len(sel) == 0: return False
for obj in sel:
if obj.Type not in self.SYNCABLES:
return False
return True
def Activated(self):
selection = [ sel for sel in Gui.Selection.getSelection() if sel.Type in self.SYNCABLES ]
syncables = []
if len(selection) == 1:
syncables = selection
else:
syncables = []
for i in selection:
for j in selection:
print(selection)
if i == j: continue
if i in j.OutList:
break
else:
syncables.append(i)
for s in syncables:
if not hasattr(s, 'Proxy'): continue
feature = s.Proxy
if hasattr(feature, self.method):
getattr(feature, self.method)()
s.recompute()