def slotDeletedObject(self, obj): if Script.getObjectType(obj) == "App::PySerial": if obj.Proxy.hasParent(obj): obj = obj.Proxy.getParent(obj) if Script.getObjectType(obj) == "App::UsbPool" and\ obj.Proxy.Machine.isRunning(): obj.Proxy.Machine.halt() obj.Proxy.Machine.pool.waitForDone()
def Activated(self): obj = FreeCADGui.Selection.getSelection(FreeCAD.ActiveDocument.Name)[0] code = '''obj = FreeCADGui.Selection.getSelection(FreeCAD.ActiveDocument.Name)[0]\n''' if Script.getObjectType(obj) == "App::UsbPool": code += '''obj.Pause = not obj.Pause''' if Script.getObjectType(obj) == "App::PySerial": code += '''obj.InList[0].Pause = not obj.InList[0].Pause''' FreeCADGui.doCommand(code) FreeCAD.ActiveDocument.recompute()
def IsActive(self): if FreeCAD.ActiveDocument is not None: s = FreeCADGui.Selection.getSelection(FreeCAD.ActiveDocument.Name) if len(s): obj = s[0] if Script.getObjectType(obj) == "App::UsbPool" or\ Script.getObjectType(obj) == "App::PySerial": return True return False
def IsActive(self): if FreeCAD.ActiveDocument is not None: s = FreeCADGui.Selection.getSelection(FreeCAD.ActiveDocument.Name) if len(s): obj = s[0] if Script.getObjectType(obj) == "App::PySerial": obj = obj.Proxy.getParent(obj) if Script.getObjectType(obj) == "App::UsbPool" and\ obj.Proxy.Machine.run: return True return False
def Activated(self): obj = FreeCADGui.Selection.getSelection(FreeCAD.ActiveDocument.Name)[0] code = '''obj = FreeCADGui.Selection.getSelection(FreeCAD.ActiveDocument.Name)[0]\n''' if Script.getObjectType(obj) == "App::UsbPool": code += '''for o in obj.Serials: o.Proxy.Update = ["Port", "Baudrate"] o.touch()''' if Script.getObjectType(obj) == "App::PySerial": code += '''obj.Proxy.Update = ["Port", "Baudrate"] obj.touch()''' FreeCADGui.doCommand(code) FreeCAD.ActiveDocument.recompute()
def shouldShow(self): for obj in FreeCADGui.Selection.getSelection(): if AppScript.getObjectType(obj) == "App::UsbPool" and\ GuiScript.getObjectViewType(obj.ViewObject) == "Gui::UsbTinyG2": self.view.setModel(obj.ViewObject.Proxy.Model) return True self.view.setModel(self.model) return False
def Activated(self): obj = FreeCADGui.Selection.getSelection(FreeCAD.ActiveDocument.Name)[0] code = '''obj = Gui.Selection.getSelection(App.ActiveDocument.Name)[0]\n''' if Script.getObjectType(obj) == "App::PySerial": obj = obj.Proxy.getParent(obj) code += '''obj = obj.Proxy.getParent(obj)\n''' if obj.Proxy.Machine.isRunning(): code += '''obj.Proxy.Machine.stop()''' else: code += '''obj.Proxy.Machine.start(obj)''' FreeCADGui.doCommand(code) FreeCAD.ActiveDocument.recompute()