Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
    def __init__(self, vobj, deleteOnReject):
        FreeCAD.ActiveDocument.openTransaction(
            translate("Path_Job", "Edit Job"))
        self.vobj = vobj
        self.vproxy = vobj.Proxy
        self.obj = vobj.Object
        self.deleteOnReject = deleteOnReject
        self.form = FreeCADGui.PySideUic.loadUi(":/panels/PathEdit.ui")
        self.template = PathJobCmd.DlgJobTemplateExport(
            self.obj, self.form.jobBox.widget(1))

        vUnit = FreeCAD.Units.Quantity(
            1, FreeCAD.Units.Velocity).getUserPreferred()[2]
        self.form.toolControllerList.horizontalHeaderItem(1).setText('#')
        self.form.toolControllerList.horizontalHeaderItem(2).setText(vUnit)
        self.form.toolControllerList.horizontalHeaderItem(3).setText(vUnit)
        self.form.toolControllerList.horizontalHeader().setResizeMode(
            0, QtGui.QHeaderView.Stretch)
        self.form.toolControllerList.resizeColumnsToContents()

        currentPostProcessor = self.obj.PostProcessor
        postProcessors = PathPreferences.allEnabledPostProcessors(
            ['', currentPostProcessor])
        for post in postProcessors:
            self.form.postProcessor.addItem(post)
        # update the enumeration values, just to make sure all selections are valid
        self.obj.PostProcessor = postProcessors
        self.obj.PostProcessor = currentPostProcessor

        base = self.obj.Base if PathJob.isResourceClone(self.obj,
                                                        'Base') else None
        stock = self.obj.Stock
        for o in PathJob.ObjectJob.baseCandidates():
            if o != base and o != stock:
                self.form.jobModel.addItem(o.Label, o)
        self.selectComboBoxText(self.form.jobModel,
                                self.obj.Proxy.baseObject(self.obj).Label)

        self.postProcessorDefaultTooltip = self.form.postProcessor.toolTip()
        self.postProcessorArgsDefaultTooltip = self.form.postProcessorArguments.toolTip(
        )

        self.vproxy.setupEditVisibility(self.obj)

        self.stockFromBase = None
        self.stockFromExisting = None
        self.stockCreateBox = None
        self.stockCreateCylinder = None
        self.stockEdit = None

        self.setupGlobal = PathSetupSheetGui.GlobalEditor(
            self.obj.SetupSheet, self.form)
        self.setupOps = PathSetupSheetGui.OpsDefaultEditor(
            self.obj.SetupSheet, self.form)
Esempio n. 4
0
 def createJob(self):
     return PathJobCmd.CommandJobCreate().Activated()