def addToJob(obj, jobname=None): '''adds a path object to a job obj = obj jobname = None''' PathLog.track(jobname) if jobname is not None: jobs = GetJobs(jobname) if len(jobs) == 1: job = jobs[0] else: PathLog.error(translate("Path", "Didn't find job %s") % jobname) return None else: jobs = GetJobs() if len(jobs) == 0: job = PathJobCmd.CommandJobCreate().Activated() elif len(jobs) == 1: job = jobs[0] else: selected = FreeCADGui.Selection.getSelection() if 1 == len(selected) and selected[0] in jobs: job = selected[0] else: modelSelected = [] for job in jobs: if all([o in job.Model.Group for o in selected]): modelSelected.append(job) if 1 == len(modelSelected): job = modelSelected[0] else: modelObjectSelected = [] for job in jobs: if all([ o in job.Proxy.baseObjects(job) for o in selected ]): modelObjectSelected.append(job) if 1 == len(modelObjectSelected): job = modelObjectSelected[0] else: # form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/DlgJobChooser.ui") form = FreeCADGui.PySideUic.loadUi( ":/panels/DlgJobChooser.ui") if modelObjectSelected: mylist = [j.Label for j in modelObjectSelected] else: mylist = [j.Label for j in jobs] form.cboProject.addItems(mylist) r = form.exec_() if r is False or r == 0: return None else: job = [ j for j in jobs if j.Label == form.cboProject.currentText() ][0] if obj and job: job.Proxy.addOperation(obj) return job
def addToJob(obj, jobname=None): '''adds a path object to a job obj = obj jobname = None''' PathLog.track() if jobname is not None: jobs = GetJobs(jobname) if len(jobs) == 1: job = jobs[0] else: PathLog.error(translate("Path", "Didn't find job %s") % jobname) return None else: jobs = GetJobs() if len(jobs) == 0: job = PathJobCmd.CommandJobCreate().Activated() elif len(jobs) == 1: job = jobs[0] else: # form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Path/DlgJobChooser.ui") form = FreeCADGui.PySideUic.loadUi(":/panels/DlgJobChooser.ui") mylist = [i.Label for i in jobs] form.cboProject.addItems(mylist) r = form.exec_() if r is False: return None else: print(form.cboProject.currentText()) job = [i for i in jobs if i.Label == form.cboProject.currentText()][0] if obj: job.Proxy.addOperation(obj) return job
def createJob(self): return PathJobCmd.CommandJobCreate().Activated()