def setFields(self): self.form.finalDepth.setText( FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.startDepth.setText( FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText( FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText( FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is None: self.obj.ToolController = PathUtils.findToolController(self.obj) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False) else: self.obj.ToolController = PathUtils.findToolController(self.obj)
def setFields(self): PathLog.track() self.form.startDepth.setText( FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText( FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.stepDown.setText( FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText( FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText( FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) self.form.extraOffset.setText( FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) self.form.useCompensation.setChecked(self.obj.UseComp) # self.form.useStartPoint.setChecked(self.obj.UseStartPoint) index = self.form.direction.findText(self.obj.Direction, QtCore.Qt.MatchFixedString) if index >= 0: self.form.direction.blockSignals(True) self.form.direction.setCurrentIndex(index) self.form.direction.blockSignals(False) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is None: self.obj.ToolController = PathUtils.findToolController(self.obj) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False) else: self.obj.ToolController = PathUtils.findToolController(self.obj)
def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "StepDown"): self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "MaterialAllowance"): self.obj.MaterialAllowance = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value if hasattr(self.obj, "UseStartPoint"): self.obj.UseStartPoint = self.form.useStartPoint.isChecked() if hasattr(self.obj, "Algorithm"): self.obj.Algorithm = str(self.form.algorithmSelect.currentText()) if hasattr(self.obj, "CutMode"): self.obj.CutMode = str(self.form.cutMode.currentText()) if hasattr(self.obj, "UseZigZag"): self.obj.UseZigZag = self.form.useZigZag.isChecked() if hasattr(self.obj, "ZigUnidirectional"): self.obj.ZigUnidirectional = self.form.zigZagUnidirectional.isChecked() if hasattr(self.obj, "ZigZagAngle"): self.obj.ZigZagAngle = FreeCAD.Units.Quantity(self.form.zigZagAngle.text()).Value if hasattr(self.obj, "StepOver"): self.obj.StepOver = self.form.stepOverPercent.value() if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.obj.Proxy.execute(self.obj)
def setDefaultValues(self, obj): '''setDefaultValues(obj) ... base implementation. Do not overwrite, overwrite opSetDefaultValues() instead.''' PathUtils.addToJob(obj) obj.Active = True features = self.opFeatures(obj) if FeatureTool & features: obj.ToolController = PathUtils.findToolController(obj) if FeatureDepths & features: obj.StartDepth = 1.0 obj.FinalDepth = 0.0 if FeatureStepDown & features: obj.StepDown = 1.0 if FeatureHeights & features: obj.ClearanceHeight = 10.0 obj.SafeHeight = 8.0 if FeatureStartPoint & features: obj.UseStartPoint = False self.opSetDefaultValues(obj)
def getFields(self): PathLog.track() if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "StepDown"): self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "OffsetExtra"): self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value if hasattr(self.obj, "RollRadius"): self.obj.RollRadius = FreeCAD.Units.Quantity(self.form.rollRadius.text()).Value if hasattr(self.obj, "UseComp"): self.obj.UseComp = self.form.useCompensation.isChecked() if hasattr(self.obj, "UseStartPoint"): self.obj.UseStartPoint = self.form.useStartPoint.isChecked() if hasattr(self.obj, "UseEndPoint"): self.obj.UseEndPoint = self.form.useEndPoint.isChecked() if hasattr(self.obj, "Direction"): self.obj.Direction = str(self.form.direction.currentText()) if hasattr(self.obj, "ToolController"): tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.obj.Proxy.execute(self.obj)
def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "FinishDepth"): self.obj.FinishDepth = FreeCAD.Units.Quantity(self.form.finishDepth.text()).Value if hasattr(self.obj, "StepDown"): self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "MaterialAllowance"): self.obj.MaterialAllowance = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value if hasattr(self.obj, "UseStartPoint"): self.obj.UseStartPoint = self.form.useStartPoint.isChecked() if hasattr(self.obj, "CutMode"): self.obj.CutMode = str(self.form.cutMode.currentText()) if hasattr(self.obj, "OffsetPattern"): self.obj.OffsetPattern = str(self.form.offsetpattern.currentText()) if hasattr(self.obj, "ZigZagAngle"): self.obj.ZigZagAngle = FreeCAD.Units.Quantity(self.form.zigZagAngle.text()).Value if hasattr(self.obj, "StepOver"): self.obj.StepOver = self.form.stepOverPercent.value() if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.isDirty = True
def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity( self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity( self.form.finalDepth.text()).Value if hasattr(self.obj, "FinishDepth"): self.obj.FinishDepth = FreeCAD.Units.Quantity( self.form.finishDepth.text()).Value if hasattr(self.obj, "StepDown"): self.obj.StepDown = FreeCAD.Units.Quantity( self.form.stepDown.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity( self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity( self.form.clearanceHeight.text()).Value if hasattr(self.obj, "Algorithm"): self.obj.Algorithm = str( self.form.algorithmSelect.currentText()) if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format( self.form.uiToolController.currentText())) tc = PathUtils.findToolController( self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.obj.Proxy.execute(self.obj)
def setDefaultValues(self, obj): '''setDefaultValues(obj) ... base implementation. Do not overwrite, overwrite opSetDefaultValues() instead.''' job = PathUtils.addToJob(obj) obj.Active = True features = self.opFeatures(obj) if FeatureTool & features: obj.ToolController = PathUtils.findToolController(obj) obj.OpToolDiameter = 1.0 if FeatureDepths & features: obj.setExpression('StartDepth', job.SetupSheet.StartDepthExpression) obj.setExpression('FinalDepth', job.SetupSheet.FinalDepthExpression) obj.OpStartDepth = 1.0 obj.OpFinalDepth = 0.0 if FeatureStepDown & features: obj.setExpression('StepDown', job.SetupSheet.StepDownExpression) if FeatureHeights & features: if job.SetupSheet.SafeHeightExpression: obj.setExpression('SafeHeight', job.SetupSheet.SafeHeightExpression) if job.SetupSheet.ClearanceHeightExpression: obj.setExpression('ClearanceHeight', job.SetupSheet.ClearanceHeightExpression) if FeatureStartPoint & features: obj.UseStartPoint = False self.opSetDefaultValues(obj) obj.recompute()
def getFields(self): PathLog.track() if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity( self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity( self.form.finalDepth.text()).Value if hasattr(self.obj, "PeckDepth"): self.obj.PeckDepth = FreeCAD.Units.Quantity( self.form.peckDepth.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity( self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity( self.form.clearanceHeight.text()).Value if hasattr(self.obj, "RetractHeight"): self.obj.RetractHeight = FreeCAD.Units.Quantity( self.form.retractHeight.text()).Value if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format( self.form.uiToolController.currentText())) tc = PathUtils.findToolController( self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.obj.Proxy.execute(self.obj)
def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "FinishDepth"): self.obj.FinishDepth = FreeCAD.Units.Quantity(self.form.finishDepth.text()).Value if hasattr(self.obj, "StepDown"): self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "PassExtension"): self.obj.PassExtension = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value if hasattr(self.obj, "CutMode"): self.obj.CutMode = str(self.form.cutMode.currentText()) if hasattr(self.obj, "ZigZagAngle"): self.obj.ZigZagAngle = FreeCAD.Units.Quantity(self.form.zigZagAngle.text()).Value if hasattr(self.obj, "StepOver"): self.obj.StepOver = self.form.stepOverPercent.value() if hasattr(self.obj, "BoundaryShape"): self.obj.BoundaryShape = str(self.form.boundaryShape.currentText()) if hasattr(self.obj, "OffsetPattern"): self.obj.OffsetPattern = str(self.form.offsetpattern.currentText()) if hasattr(self.obj, "ToolController"): tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.isDirty = True
def getFields(self): PathLog.track() if self.obj: try: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "PeckDepth"): if FreeCAD.Units.Quantity(self.form.peckDepth.text()).Value >= 0: self.obj.PeckDepth = FreeCAD.Units.Quantity(self.form.peckDepth.text()).Value else: self.form.peckDepth.setText("0.00") if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "RetractHeight"): self.obj.RetractHeight = FreeCAD.Units.Quantity(self.form.retractHeight.text()).Value if hasattr(self.obj, "DwellTime"): if FreeCAD.Units.Quantity(self.form.dwellTime.text()).Value >= 0: self.obj.DwellTime = FreeCAD.Units.Quantity(self.form.dwellTime.text()).Value else: self.form.dwellTime.setText("0.00") if hasattr(self.obj, "DwellEnabled"): self.obj.DwellEnabled = self.form.dwellEnabled.isChecked() if hasattr(self.obj, "PeckEnabled"): self.obj.PeckEnabled = self.form.peckEnabled.isChecked() if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc except ValueError: self.setFields() self.isDirty = True
def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "StepDown"): self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "OffsetExtra"): self.obj.OffsetExtra = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value if hasattr(self.obj, "UseComp"): self.obj.UseComp = self.form.useCompensation.isChecked() if hasattr(self.obj, "UseStartPoint"): self.obj.UseStartPoint = self.form.useStartPoint.isChecked() if hasattr(self.obj, "Side"): self.obj.Side = str(self.form.cutSide.currentText()) if hasattr(self.obj, "Direction"): self.obj.Direction = str(self.form.direction.currentText()) if hasattr(self.obj, "processHoles"): self.obj.processHoles = self.form.processHoles.isChecked() if hasattr(self.obj, "processPerimeter"): self.obj.processPerimeter = self.form.processPerimeter.isChecked() if hasattr(self.obj, "processCircles"): self.obj.processCircles = self.form.processCircles.isChecked() if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.isDirty = True
def getFields(self): PathLog.track() if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity( self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity( self.form.finalDepth.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity( self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity( self.form.clearanceHeight.text()).Value if hasattr(self.obj, "StepDown"): self.obj.StepDown = FreeCAD.Units.Quantity( self.form.stepDown.text()).Value if hasattr(self.obj, "OffsetExtra"): self.obj.OffsetExtra = FreeCAD.Units.Quantity( self.form.extraOffset.text()).Value if hasattr(self.obj, "UseComp"): self.obj.UseComp = self.form.useCompensation.isChecked() # if hasattr(self.obj, "UseStartPoint"): # self.obj.UseStartPoint = self.form.useStartPoint.isChecked() if hasattr(self.obj, "Direction"): self.obj.Direction = str(self.form.direction.currentText()) if hasattr(self.obj, "ToolController"): tc = PathUtils.findToolController( self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.isDirty = True
def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "FinishDepth"): self.obj.FinishDepth = FreeCAD.Units.Quantity(self.form.finishDepth.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "StepDown"): self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "PassExtension"): self.obj.PassExtension = FreeCAD.Units.Quantity(self.form.extraOffset.text()).Value if hasattr(self.obj, "CutMode"): self.obj.CutMode = str(self.form.cutMode.currentText()) if hasattr(self.obj, "UseZigZag"): self.obj.UseZigZag = self.form.useZigZag.isChecked() if hasattr(self.obj, "ZigUnidirectional"): self.obj.ZigUnidirectional = self.form.zigZagUnidirectional.isChecked() if hasattr(self.obj, "ZigZagAngle"): self.obj.ZigZagAngle = FreeCAD.Units.Quantity(self.form.zigZagAngle.text()).Value if hasattr(self.obj, "StepOver"): self.obj.StepOver = self.form.stepOverPercent.value() if hasattr(self.obj, "BoundaryShape"): self.obj.BoundaryShape = str(self.form.boundaryShape.currentText()) if hasattr(self.obj, "ToolController"): tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.obj.Proxy.execute(self.obj)
def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.finishDepth.setText(FreeCAD.Units.Quantity(self.obj.FinishDepth.Value, FreeCAD.Units.Length).UserString) self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) PathLog.debug("searching for TC label {}. Found Index: {}".format(self.obj.ToolController.Label, index)) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False) else: self.obj.ToolController = PathUtils.findToolController(self.obj) for i in self.obj.Base: self.form.baseList.addItem(i[0].Name) index = self.form.algorithmSelect.findText( self.obj.Algorithm, QtCore.Qt.MatchFixedString) if index >= 0: self.form.algorithmSelect.blockSignals(True) self.form.algorithmSelect.setCurrentIndex(index) self.form.algorithmSelect.blockSignals(False)
def setFields(self): self.form.startDepth.setText( FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText( FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText( FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText( FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) self.form.stepDown.setText( FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.extraOffset.setText( FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) self.form.rollRadius.setText( FreeCAD.Units.Quantity(self.obj.RollRadius.Value, FreeCAD.Units.Length).UserString) self.form.useCompensation.setChecked(self.obj.UseComp) self.form.useStartPoint.setChecked(self.obj.UseStartPoint) self.form.useEndPoint.setChecked(self.obj.UseEndPoint) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) PathLog.debug("searching for TC label {}. Found Index: {}".format( self.obj.ToolController.Label, index)) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False) else: self.obj.ToolController = PathUtils.findToolController(self.obj) index = self.form.cutSide.findText(self.obj.Side, QtCore.Qt.MatchFixedString) if index >= 0: self.form.cutSide.blockSignals(True) self.form.cutSide.setCurrentIndex(index) self.form.cutSide.blockSignals(False) index = self.form.direction.findText(self.obj.Direction, QtCore.Qt.MatchFixedString) if index >= 0: self.form.direction.setCurrentIndex(index) self.form.baseList.blockSignals(True) for i in self.obj.Base: for sub in i[1]: self.form.baseList.addItem(i[0].Name + "." + sub) self.form.baseList.blockSignals(False)
def setDefaultValues(self, obj): '''setDefaultValues(obj) ... base implementation. Do not overwrite, overwrite opSetDefaultValues() instead.''' job = PathUtils.addToJob(obj) obj.Active = True features = self.opFeatures(obj) if FeatureTool & features: if 1 < len(job.Operations.Group): obj.ToolController = PathUtil.toolControllerForOp( job.Operations.Group[-2]) else: obj.ToolController = PathUtils.findToolController(obj) if not obj.ToolController: return None obj.OpToolDiameter = obj.ToolController.Tool.Diameter if FeatureCoolant & features: obj.CoolantMode = job.SetupSheet.CoolantMode if FeatureDepths & features: if self.applyExpression(obj, 'StartDepth', job.SetupSheet.StartDepthExpression): obj.OpStartDepth = 1.0 else: obj.StartDepth = 1.0 if self.applyExpression(obj, 'FinalDepth', job.SetupSheet.FinalDepthExpression): obj.OpFinalDepth = 0.0 else: obj.FinalDepth = 0.0 else: obj.StartDepth = 1.0 if FeatureStepDown & features: if not self.applyExpression(obj, 'StepDown', job.SetupSheet.StepDownExpression): obj.StepDown = '1 mm' if FeatureHeights & features: if job.SetupSheet.SafeHeightExpression: if not self.applyExpression( obj, 'SafeHeight', job.SetupSheet.SafeHeightExpression): obj.SafeHeight = '3 mm' if job.SetupSheet.ClearanceHeightExpression: if not self.applyExpression( obj, 'ClearanceHeight', job.SetupSheet.ClearanceHeightExpression): obj.ClearanceHeight = '5 mm' if FeatureStartPoint & features: obj.UseStartPoint = False self.opSetDefaultValues(obj, job) return job
def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.finishDepth.setText(FreeCAD.Units.Quantity(self.obj.FinishDepth.Value, FreeCAD.Units.Length).UserString) self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) self.form.stepOverPercent.setValue(self.obj.StepOver) self.form.zigZagAngle.setText(FreeCAD.Units.Quantity(self.obj.ZigZagAngle, FreeCAD.Units.Angle).UserString) self.form.extraOffset.setValue(self.obj.PassExtension.Value) index = self.form.cutMode.findText( self.obj.CutMode, QtCore.Qt.MatchFixedString) if index >= 0: self.form.cutMode.blockSignals(True) self.form.cutMode.setCurrentIndex(index) self.form.cutMode.blockSignals(False) index = self.form.boundaryShape.findText( self.obj.BoundaryShape, QtCore.Qt.MatchFixedString) if index >= 0: self.form.boundaryShape.blockSignals(True) self.form.boundaryShape.setCurrentIndex(index) self.form.boundaryShape.blockSignals(False) index = self.form.offsetpattern.findText( self.obj.OffsetPattern, QtCore.Qt.MatchFixedString) if index >= 0: self.form.offsetpattern.blockSignals(True) self.form.offsetpattern.setCurrentIndex(index) self.form.offsetpattern.blockSignals(False) for i in self.obj.Base: for sub in i[1]: self.form.baseList.addItem(i[0].Name + "." + sub) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is None: self.obj.ToolController = PathUtils.findToolController(self.obj) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False)
def setupToolController(self, obj, combo): '''setupToolController(obj, combo) ... helper function to setup obj's ToolController in the given combo box.''' controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] combo.blockSignals(True) combo.addItems(labels) combo.blockSignals(False) if obj.ToolController is None: obj.ToolController = PathUtils.findToolController(obj) if obj.ToolController is not None: self.selectInComboBox(obj.ToolController.Label, combo)
def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) self.form.rollRadius.setText(FreeCAD.Units.Quantity(self.obj.RollRadius.Value, FreeCAD.Units.Length).UserString) self.form.useCompensation.setChecked(self.obj.UseComp) self.form.useStartPoint.setChecked(self.obj.UseStartPoint) self.form.useEndPoint.setChecked(self.obj.UseEndPoint) self.form.processHoles.setChecked(self.obj.processHoles) self.form.processPerimeter.setChecked(self.obj.processPerimeter) self.form.processCircles.setChecked(self.obj.processCircles) index = self.form.cutSide.findText( self.obj.Side, QtCore.Qt.MatchFixedString) if index >= 0: self.form.cutSide.blockSignals(True) self.form.cutSide.setCurrentIndex(index) self.form.cutSide.blockSignals(False) index = self.form.direction.findText( self.obj.Direction, QtCore.Qt.MatchFixedString) if index >= 0: self.form.direction.blockSignals(True) self.form.direction.setCurrentIndex(index) self.form.direction.blockSignals(False) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) PathLog.debug("searching for TC label {}. Found Index: {}".format(self.obj.ToolController.Label, index)) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False) else: self.obj.ToolController = PathUtils.findToolController(self.obj) self.form.baseList.blockSignals(True) for i in self.obj.Base: for sub in i[1]: self.form.baseList.addItem(i[0].Name + "." + sub) self.form.baseList.blockSignals(False) self.form.update()
def getFields(self): if self.obj: if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "ToolController"): tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.obj.Proxy.execute(self.obj)
def setFields(self): PathLog.track() self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.OffsetExtra.Value, FreeCAD.Units.Length).UserString) self.form.rollRadius.setText(FreeCAD.Units.Quantity(self.obj.RollRadius.Value, FreeCAD.Units.Length).UserString) self.form.useCompensation.setChecked(self.obj.UseComp) self.form.useStartPoint.setChecked(self.obj.UseStartPoint) self.form.useEndPoint.setChecked(self.obj.UseEndPoint) index = self.form.direction.findText( self.obj.Direction, QtCore.Qt.MatchFixedString) if index >= 0: self.form.direction.blockSignals(True) self.form.direction.setCurrentIndex(index) self.form.direction.blockSignals(False) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is None: self.obj.ToolController = PathUtils.findToolController(self.obj) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False) else: self.obj.ToolController = PathUtils.findToolController(self.obj)
def setFields(self): self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is None: self.obj.ToolController = PathUtils.findToolController(self.obj) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False) else: self.obj.ToolController = PathUtils.findToolController(self.obj)
def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "ToolController"): tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.isDirty = True
def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.MaterialAllowance, FreeCAD.Units.Length).UserString) self.form.useStartPoint.setChecked(self.obj.UseStartPoint) self.form.useZigZag.setChecked(self.obj.UseZigZag) self.form.zigZagUnidirectional.setChecked(self.obj.ZigUnidirectional) self.form.zigZagAngle.setText(FreeCAD.Units.Quantity(self.obj.ZigZagAngle, FreeCAD.Units.Angle).UserString) self.form.stepOverPercent.setValue(self.obj.StepOver) index = self.form.algorithmSelect.findText(self.obj.Algorithm, QtCore.Qt.MatchFixedString) if index >= 0: self.form.algorithmSelect.blockSignals(True) self.form.algorithmSelect.setCurrentIndex(index) self.form.algorithmSelect.blockSignals(False) index = self.form.cutMode.findText( self.obj.CutMode, QtCore.Qt.MatchFixedString) if index >= 0: self.form.cutMode.blockSignals(True) self.form.cutMode.setCurrentIndex(index) self.form.cutMode.blockSignals(False) # for i in self.obj.Base: # self.form.baseList.addItem(i[0].Name + "." + i[1][0]) self.form.baseList.blockSignals(True) for i in self.obj.Base: for sub in i[1]: self.form.baseList.addItem(i[0].Name + "." + sub) self.form.baseList.blockSignals(False) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) PathLog.debug("searching for TC label {}. Found Index: {}".format(self.obj.ToolController.Label, index)) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False) else: self.obj.ToolController = PathUtils.findToolController(self.obj)
def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.finishDepth.setText(FreeCAD.Units.Quantity(self.obj.FinishDepth.Value, FreeCAD.Units.Length).UserString) self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) self.form.stepOverPercent.setValue(self.obj.StepOver) self.form.useZigZag.setChecked(self.obj.UseZigZag) self.form.zigZagUnidirectional.setChecked(self.obj.ZigUnidirectional) self.form.zigZagAngle.setValue(FreeCAD.Units.Quantity(self.obj.ZigZagAngle, FreeCAD.Units.Angle)) self.form.extraOffset.setValue(self.obj.PassExtension.Value) index = self.form.cutMode.findText( self.obj.CutMode, QtCore.Qt.MatchFixedString) if index >= 0: self.form.cutMode.blockSignals(True) self.form.cutMode.setCurrentIndex(index) self.form.cutMode.blockSignals(False) index = self.form.boundaryShape.findText( self.obj.BoundaryShape, QtCore.Qt.MatchFixedString) if index >= 0: self.form.boundaryShape.blockSignals(True) self.form.boundaryShape.setCurrentIndex(index) self.form.boundaryShape.blockSignals(False) for i in self.obj.Base: for sub in i[1]: self.form.baseList.addItem(i[0].Name + "." + sub) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is None: self.obj.ToolController = PathUtils.findToolController(self.obj) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False)
def Activated(self): import FreeCADGui import Path from PathScripts import PathUtils FreeCAD.ActiveDocument.openTransaction( translate("PathHelix", "Create a helix cut")) FreeCADGui.addModule("PathScripts.PathHelix") obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "PathHelix") ObjectPathHelix(obj) ViewProviderPathHelix(obj.ViewObject) obj.Features = cylinders_in_selection() obj.DeltaR = 1.0 if not obj.ToolController: obj.ToolController = PathUtils.findToolController(obj) toolLoad = obj.ToolController if toolLoad is not None: obj.ToolNumber = toolLoad.ToolNumber tool = toolLoad.Proxy.getTool(toolLoad) if tool: # start with 25% overlap obj.DeltaR = tool.Diameter * 0.75 obj.Active = True obj.Comment = "" obj.Direction = "CW" obj.StartSide = "inside" obj.Clearance = 10.0 obj.StepDown = 1.0 obj.UseStartDepth = False obj.StartDepth = 1.0 obj.UseFinalDepth = False obj.FinalDepth = 0.0 obj.ThroughDepth = 0.0 PathUtils.addToJob(obj) obj.ViewObject.startEditing() FreeCAD.ActiveDocument.recompute()
def setFields(self): self.form.startDepth.setText(FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText(FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.finishDepth.setText(FreeCAD.Units.Quantity(self.obj.FinishDepth.Value, FreeCAD.Units.Length).UserString) self.form.stepDown.setText(FreeCAD.Units.Quantity(self.obj.StepDown.Value, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText(FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText(FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) self.form.extraOffset.setText(FreeCAD.Units.Quantity(self.obj.MaterialAllowance.Value, FreeCAD.Units.Length).UserString) self.form.useStartPoint.setChecked(self.obj.UseStartPoint) self.form.zigZagAngle.setText(FreeCAD.Units.Quantity(self.obj.ZigZagAngle, FreeCAD.Units.Angle).UserString) self.form.stepOverPercent.setValue(self.obj.StepOver) index = self.form.offsetpattern.findText( self.obj.OffsetPattern, QtCore.Qt.MatchFixedString) if index >= 0: self.form.offsetpattern.blockSignals(True) self.form.offsetpattern.setCurrentIndex(index) self.form.offsetpattern.blockSignals(False) index = self.form.cutMode.findText( self.obj.CutMode, QtCore.Qt.MatchFixedString) if index >= 0: self.form.cutMode.blockSignals(True) self.form.cutMode.setCurrentIndex(index) self.form.cutMode.blockSignals(False) self.form.baseList.blockSignals(True) for i in self.obj.Base: for sub in i[1]: self.form.baseList.addItem(i[0].Name + "." + sub) self.form.baseList.blockSignals(False) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) PathLog.debug("searching for TC label {}. Found Index: {}".format(self.obj.ToolController.Label, index)) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False) else: self.obj.ToolController = PathUtils.findToolController(self.obj)
def setDefaultValues(self, obj): '''setDefaultValues(obj) ... base implementation. Do not overwrite, overwrite opSetDefaultValues() instead.''' job = PathUtils.addToJob(obj) obj.Active = True features = self.opFeatures(obj) if FeatureTool & features: if 1 < len(job.Operations.Group): obj.ToolController = PathUtil.toolControllerForOp(job.Operations.Group[-2]) else: obj.ToolController = PathUtils.findToolController(obj) if not obj.ToolController: return None obj.OpToolDiameter = obj.ToolController.Tool.Diameter if FeatureDepths & features: if self.applyExpression(obj, 'StartDepth', job.SetupSheet.StartDepthExpression): obj.OpStartDepth = 1.0 else: obj.StartDepth = 1.0 if self.applyExpression(obj, 'FinalDepth', job.SetupSheet.FinalDepthExpression): obj.OpFinalDepth = 0.0 else: obj.FinalDepth = 0.0 else: obj.StartDepth = 1.0 if FeatureStepDown & features: if not self.applyExpression(obj, 'StepDown', job.SetupSheet.StepDownExpression): obj.StepDown = '1 mm' if FeatureHeights & features: if job.SetupSheet.SafeHeightExpression: if not self.applyExpression(obj, 'SafeHeight', job.SetupSheet.SafeHeightExpression): obj.SafeHeight = '3 mm' if job.SetupSheet.ClearanceHeightExpression: if not self.applyExpression(obj, 'ClearanceHeight', job.SetupSheet.ClearanceHeightExpression): obj.ClearanceHeight = '5 mm' if FeatureStartPoint & features: obj.UseStartPoint = False self.opSetDefaultValues(obj, job) return job
def setDefaultValues(self, obj): '''setDefaultValues(obj) ... base implementation. Do not overwrite, overwrite opSetDefaultValues() instead.''' job = PathUtils.addToJob(obj) obj.Active = True features = self.opFeatures(obj) if FeatureTool & features: obj.ToolController = PathUtils.findToolController(obj) obj.OpToolDiameter = 1.0 if FeatureDepths & features: if self.applyExpression(obj, 'StartDepth', job.SetupSheet.StartDepthExpression): obj.OpStartDepth = 1.0 else: obj.StartDepth = 1.0 if self.applyExpression(obj, 'FinalDepth', job.SetupSheet.FinalDepthExpression): obj.OpFinalDepth = 0.0 else: obj.FinalDepth = 0.0 if FeatureStepDown & features: if not self.applyExpression(obj, 'StepDown', job.SetupSheet.StepDownExpression): obj.StepDown = '1 mm' if FeatureHeights & features: if job.SetupSheet.SafeHeightExpression: if not self.applyExpression( obj, 'SafeHeight', job.SetupSheet.SafeHeightExpression): obj.SafeHeight = '3 mm' if job.SetupSheet.ClearanceHeightExpression: if not self.applyExpression( obj, 'ClearanceHeight', job.SetupSheet.ClearanceHeightExpression): obj.ClearanceHeight = '5 mm' if FeatureStartPoint & features: obj.UseStartPoint = False self.opSetDefaultValues(obj) obj.recompute()
def Activated(self): import FreeCADGui import Path from PathScripts import PathUtils FreeCAD.ActiveDocument.openTransaction(translate("PathHelix", "Create a helix cut")) FreeCADGui.addModule("PathScripts.PathHelix") obj = FreeCAD.ActiveDocument.addObject("Path::FeaturePython", "PathHelix") ObjectPathHelix(obj) ViewProviderPathHelix(obj.ViewObject) obj.Features = cylinders_in_selection() obj.DeltaR = 1.0 if not obj.ToolController: obj.ToolController = PathUtils.findToolController(obj) toolLoad = obj.ToolController if toolLoad is not None: obj.ToolNumber = toolLoad.ToolNumber tool = toolLoad.Proxy.getTool(toolLoad) if tool: # start with 25% overlap obj.DeltaR = tool.Diameter * 0.75 obj.Active = True obj.Comment = "" obj.Direction = "CW" obj.StartSide = "inside" obj.Clearance = 10.0 obj.StepDown = 1.0 obj.UseStartDepth = False obj.StartDepth = 1.0 obj.UseFinalDepth = False obj.FinalDepth = 0.0 obj.ThroughDepth = 0.0 PathUtils.addToJob(obj) obj.ViewObject.startEditing() FreeCAD.ActiveDocument.recompute()
def setFields(self): self.form.startDepth.setText( FreeCAD.Units.Quantity(self.obj.StartDepth.Value, FreeCAD.Units.Length).UserString) self.form.finalDepth.setText( FreeCAD.Units.Quantity(self.obj.FinalDepth.Value, FreeCAD.Units.Length).UserString) self.form.finishDepth.setText( FreeCAD.Units.Quantity(self.obj.FinishDepth.Value, FreeCAD.Units.Length).UserString) self.form.stepDown.setText( FreeCAD.Units.Quantity(self.obj.StepDown, FreeCAD.Units.Length).UserString) self.form.safeHeight.setText( FreeCAD.Units.Quantity(self.obj.SafeHeight.Value, FreeCAD.Units.Length).UserString) self.form.clearanceHeight.setText( FreeCAD.Units.Quantity(self.obj.ClearanceHeight.Value, FreeCAD.Units.Length).UserString) controllers = PathUtils.getToolControllers(self.obj) labels = [c.Label for c in controllers] self.form.uiToolController.blockSignals(True) self.form.uiToolController.addItems(labels) self.form.uiToolController.blockSignals(False) if self.obj.ToolController is not None: index = self.form.uiToolController.findText( self.obj.ToolController.Label, QtCore.Qt.MatchFixedString) PathLog.debug("searching for TC label {}. Found Index: {}".format( self.obj.ToolController.Label, index)) if index >= 0: self.form.uiToolController.blockSignals(True) self.form.uiToolController.setCurrentIndex(index) self.form.uiToolController.blockSignals(False) else: self.obj.ToolController = PathUtils.findToolController(self.obj) for i in self.obj.Base: self.form.baseList.addItem(i[0].Name) index = self.form.algorithmSelect.findText(self.obj.Algorithm, QtCore.Qt.MatchFixedString) if index >= 0: self.form.algorithmSelect.blockSignals(True) self.form.algorithmSelect.setCurrentIndex(index) self.form.algorithmSelect.blockSignals(False)
def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity( self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity( self.form.finalDepth.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity( self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity( self.form.clearanceHeight.text()).Value if hasattr(self.obj, "StepDown"): self.obj.StepDown = FreeCAD.Units.Quantity( self.form.stepDown.text()).Value if hasattr(self.obj, "MaterialAllowance"): self.obj.MaterialAllowance = FreeCAD.Units.Quantity( self.form.extraOffset.text()).Value if hasattr(self.obj, "UseStartPoint"): self.obj.UseStartPoint = self.form.useStartPoint.isChecked() if hasattr(self.obj, "Algorithm"): self.obj.Algorithm = str( self.form.algorithmSelect.currentText()) if hasattr(self.obj, "CutMode"): self.obj.CutMode = str(self.form.cutMode.currentText()) if hasattr(self.obj, "UseZigZag"): self.obj.UseZigZag = self.form.useZigZag.isChecked() if hasattr(self.obj, "ZigUnidirectional"): self.obj.ZigUnidirectional = self.form.zigZagUnidirectional.isChecked( ) if hasattr(self.obj, "ZigZagAngle"): self.obj.ZigZagAngle = FreeCAD.Units.Quantity( self.form.zigZagAngle.text()).Value if hasattr(self.obj, "StepOver"): self.obj.StepOver = self.form.stepOverPercent.value() if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format( self.form.uiToolController.currentText())) tc = PathUtils.findToolController( self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.obj.Proxy.execute(self.obj)
def getFields(self): if self.obj: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "FinishDepth"): self.obj.FinishDepth = FreeCAD.Units.Quantity(self.form.finishDepth.text()).Value if hasattr(self.obj, "StepDown"): self.obj.StepDown = FreeCAD.Units.Quantity(self.form.stepDown.text()).Value if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "Algorithm"): self.obj.Algorithm = str( self.form.algorithmSelect.currentText()) if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc self.isDirty = True
def getFields(self): PathLog.track() if self.obj: try: if hasattr(self.obj, "StartDepth"): self.obj.StartDepth = FreeCAD.Units.Quantity(self.form.startDepth.text()).Value if hasattr(self.obj, "FinalDepth"): self.obj.FinalDepth = FreeCAD.Units.Quantity(self.form.finalDepth.text()).Value if hasattr(self.obj, "PeckDepth"): if FreeCAD.Units.Quantity(self.form.peckDepth.text()).Value >= 0: self.obj.PeckDepth = FreeCAD.Units.Quantity(self.form.peckDepth.text()).Value else: self.form.peckDepth.setText("0.00") if hasattr(self.obj, "SafeHeight"): self.obj.SafeHeight = FreeCAD.Units.Quantity(self.form.safeHeight.text()).Value if hasattr(self.obj, "ClearanceHeight"): self.obj.ClearanceHeight = FreeCAD.Units.Quantity(self.form.clearanceHeight.text()).Value if hasattr(self.obj, "RetractHeight"): self.obj.RetractHeight = FreeCAD.Units.Quantity(self.form.retractHeight.text()).Value if hasattr(self.obj, "DwellTime"): if FreeCAD.Units.Quantity(self.form.dwellTime.text()).Value >= 0: self.obj.DwellTime = FreeCAD.Units.Quantity(self.form.dwellTime.text()).Value else: self.form.dwellTime.setText("0.00") if hasattr(self.obj, "DwellEnabled"): self.obj.DwellEnabled = self.form.dwellEnabled.isChecked() if hasattr(self.obj, "PeckEnabled"): self.obj.PeckEnabled = self.form.peckEnabled.isChecked() if hasattr(self.obj, "ToolController"): PathLog.debug("name: {}".format(self.form.uiToolController.currentText())) tc = PathUtils.findToolController(self.obj, self.form.uiToolController.currentText()) self.obj.ToolController = tc except ValueError: self.setFields() self.obj.Proxy.execute(self.obj)
def updateToolController(self, obj, combo): '''updateToolController(obj, combo) ... helper function to update obj's ToolController property if a different one has been selected in the combo box.''' tc = PathUtils.findToolController(obj, combo.currentText()) if obj.ToolController != tc: obj.ToolController = tc
def execute(self, obj): from Part import Circle, Cylinder, Plane from PathScripts import PathUtils from math import sqrt output = '(helix cut operation' if obj.Comment: output += ', ' + str(obj.Comment) + ')\n' else: output += ')\n' if obj.Features: if not obj.Active: obj.Path = Path.Path("(helix cut operation inactive)") if obj.ViewObject: obj.ViewObject.Visibility = False return if not obj.ToolController: obj.ToolController = PathUtils.findToolController(obj) toolLoad = obj.ToolController if toolLoad is None or toolLoad.ToolNumber == 0: FreeCAD.Console.PrintError("PathHelix: No tool selected for helix cut operation, insert a tool change operation first\n") obj.Path = Path.Path("(ERROR: no tool selected for helix cut operation)") return tool = toolLoad.Proxy.getTool(toolLoad) zsafe = max(baseobj.Shape.BoundBox.ZMax for baseobj, features in obj.Features) + obj.Clearance.Value output += "G0 Z" + fmt(zsafe) drill_jobs = [] for base, features in obj.Features: for center, by_radius in features_by_centers(base, features).items(): radii = sorted(by_radius.keys(), reverse=True) cylinders = map(lambda radius: getattr(base.Shape, by_radius[radius]), radii) zsafe = max(cyl.BoundBox.ZMax for cyl in cylinders) + obj.Clearance.Value cur_z = cylinders[0].BoundBox.ZMax jobs = [] for cylinder in cylinders: # Find other edge of current cylinder other_edge = None for edge in cylinder.Edges: if isinstance(edge.Curve, Circle) and edge.Curve.Center.z != cur_z: other_edge = edge break next_z = other_edge.Curve.Center.z dz = next_z - cur_z r = cylinder.Surface.Radius if dz < 0: # This is a closed hole if the face connected to # the current cylinder at next_z has the cylinder's # edge as its OuterWire closed = None for face in base.Shape.Faces: if connected(other_edge, face) and not face.isSame(cylinder.Faces[0]): wire = face.OuterWire if len(wire.Edges) == 1 and wire.Edges[0].isSame(other_edge): closed = True else: closed = False if closed is None: raise Exception("Cannot determine if this cylinder is closed on the z = {0} side".format(next_z)) xc, yc, _ = cylinder.Surface.Center jobs.append(dict(xc=xc, yc=yc, zmin=next_z, zmax=cur_z, zsafe=zsafe, r_out=r, r_in=0.0, closed=closed)) elif dz > 0: new_jobs = [] for job in jobs: if job["zmin"] < next_z < job["zmax"]: # split this job job1 = dict(job) job2 = dict(job) job1["zmin"] = next_z job2["zmax"] = next_z job2["r_in"] = r new_jobs.append(job1) new_jobs.append(job2) else: new_jobs.append(job) jobs = new_jobs else: FreeCAD.Console.PrintError("PathHelix: Encountered cylinder with zero height\n") break cur_z = next_z if obj.UseStartDepth: jobs = [job for job in jobs if job["zmin"] < obj.StartDepth.Value] if jobs: jobs[0]["zmax"] = obj.StartDepth.Value if obj.UseFinalDepth: jobs = [job for job in jobs if job["zmax"] > obj.FinalDepth.Value] if jobs: jobs[-1]["zmin"] = obj.FinalDepth.Value else: if not jobs[-1]["closed"]: jobs[-1]["zmin"] -= obj.ThroughDepth.Value drill_jobs.extend(jobs) if len(drill_jobs) > 0: drill_jobs = PathUtils.sort_jobs(drill_jobs, ['xc', 'yc'], ['xc', 'zmax']) for job in drill_jobs: output += helix_cut((job["xc"], job["yc"]), job["r_out"], job["r_in"], obj.DeltaR.Value, job["zmax"], job["zmin"], obj.StepDown.Value, job["zsafe"], tool.Diameter, toolLoad.VertFeed.Value, toolLoad.HorizFeed.Value, obj.Direction, obj.StartSide) output += '\n' obj.Path = Path.Path(output) if obj.ViewObject: obj.ViewObject.Visibility = True
def __init__(self, obj): from Units import Quantity from PathScripts import PathUtils self.obj = obj self.previous_value = {} self.form = QtGui.QToolBox() ui = FreeCADGui.UiLoader() grayed_out = "background-color: #d0d0d0;" def nextToolBoxItem(label, iconFile): widget = QtGui.QWidget() layout = QtGui.QGridLayout() widget.setLayout(layout) icon = QtGui.QIcon(iconFile) self.form.addItem(widget, icon, label) return layout def addFiller(): row = layout.rowCount() widget = QtGui.QWidget() layout.addWidget(widget, row, 0, 1, 2) layout.setRowStretch(row, 1) layout = nextToolBoxItem("Geometry", ":/icons/PartDesign_InternalExternalGear.svg") def addWidget(widget): row = layout.rowCount() layout.addWidget(widget, row, 0, 1, 2) def addWidgets(widget1, widget2): row = layout.rowCount() layout.addWidget(widget1, row, 0) layout.addWidget(widget2, row, 1) def addQuantity(property, labelstring, activator=None, max=None): self.previous_value[property] = getattr(self.obj, property) widget = ui.createWidget("Gui::InputField") if activator: self.previous_value[activator] = getattr(self.obj, activator) currently_active = getattr(self.obj, activator) label = QtGui.QCheckBox(labelstring) def change(state): setattr(self.obj, activator, label.isChecked()) if label.isChecked(): widget.setStyleSheet("") else: widget.setStyleSheet(grayed_out) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() label.stateChanged.connect(change) label.setChecked(currently_active) if not currently_active: widget.setStyleSheet(grayed_out) label.setToolTip(self.obj.getDocumentationOfProperty(activator)) else: label = QtGui.QLabel(labelstring) label.setToolTip(self.obj.getDocumentationOfProperty(property)) quantity = getattr(self.obj, property) widget.setText(quantity.UserString) widget.setToolTip(self.obj.getDocumentationOfProperty(property)) if max: # cannot use widget.setMaximum() as apparently ui.createWidget() # returns the object up-casted to QWidget. widget.setProperty("maximum", max) def change(quantity): setattr(self.obj, property, quantity) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() QtCore.QObject.connect(widget, QtCore.SIGNAL("valueChanged(const Base::Quantity &)"), change) addWidgets(label, widget) return label, widget def addCheckBox(property, label): self.previous_value[property] = getattr(self.obj, property) widget = QtGui.QCheckBox(label) widget.setToolTip(self.obj.getDocumentationOfProperty(property)) def change(state): setattr(self.obj, property, widget.isChecked()) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() widget.stateChanged.connect(change) widget.setChecked(getattr(self.obj, property)) addWidget(widget) def addEnumeration(property, label, options): self.previous_value[property] = getattr(self.obj, property) label = QtGui.QLabel(label) label.setToolTip(self.obj.getDocumentationOfProperty(property)) widget = QtGui.QComboBox() widget.setToolTip(self.obj.getDocumentationOfProperty(property)) for option_label, option_value in options: widget.addItem(option_label) def change(index): setattr(self.obj, property, options[index][1]) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() widget.currentIndexChanged.connect(change) addWidgets(label, widget) self.featureTree = QtGui.QTreeWidget() self.featureTree.setMinimumHeight(200) self.featureTree.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) # self.featureTree.setDragDropMode(QtGui.QAbstractItemView.DragDrop) # self.featureTree.setDefaultDropAction(QtCore.Qt.MoveAction) self.fillFeatureTree() sm = self.featureTree.selectionModel() sm.selectionChanged.connect(self.selectFeatures) addWidget(self.featureTree) self.featureTree.expandAll() self.addButton = QtGui.QPushButton("Add holes") self.addButton.clicked.connect(self.addCylinders) self.delButton = QtGui.QPushButton("Delete") self.delButton.clicked.connect(self.delCylinders) addWidgets(self.addButton, self.delButton) # End of "Features" section layout = nextToolBoxItem("Drill parameters", ":/icons/Path-OperationB.svg") addCheckBox("Active", "Operation is active") toolLoad = PathUtils.findToolController(obj) tool = toolLoad and toolLoad.Proxy.getTool(toolLoad) if not tool: drmax = None else: drmax = tool.Diameter addQuantity("DeltaR", "Step in Radius", max=drmax) addQuantity("StepDown", "Step in Z") addEnumeration("Direction", "Cut direction", [("Clockwise", "CW"), ("Counter-Clockwise", "CCW")]) addEnumeration("StartSide", "Start Side", [("Start from inside", "inside"), ("Start from outside", "outside")]) # End of "Drill parameters" section addFiller() layout = nextToolBoxItem("Cutting Depths", ":/icons/Path-Depths.svg") addQuantity("Clearance", "Clearance Distance") addQuantity("StartDepth", "Absolute start height", "UseStartDepth") fdcheckbox, fdinput = addQuantity("FinalDepth", "Absolute final height", "UseFinalDepth") tdlabel, tdinput = addQuantity("ThroughDepth", "Extra drill depth\nfor open holes") # End of "Cutting Depths" section addFiller() # make ThroughDepth and FinalDepth mutually exclusive def fd_change(state): if fdcheckbox.isChecked(): tdinput.setStyleSheet(grayed_out) else: tdinput.setStyleSheet("") fdcheckbox.stateChanged.connect(fd_change) def td_change(quantity): fdcheckbox.setChecked(False) QtCore.QObject.connect(tdinput, QtCore.SIGNAL("valueChanged(const Base::Quantity &)"), td_change) if obj.UseFinalDepth: tdinput.setStyleSheet(grayed_out)
def __init__(self, obj): #from Units import Quantity from PathScripts import PathUtils self.obj = obj self.previous_value = {} self.form = QtGui.QToolBox() ui = FreeCADGui.UiLoader() grayed_out = "background-color: #d0d0d0;" def nextToolBoxItem(label, iconFile): widget = QtGui.QWidget() layout = QtGui.QGridLayout() widget.setLayout(layout) icon = QtGui.QIcon(iconFile) self.form.addItem(widget, icon, label) return layout def addFiller(): row = layout.rowCount() widget = QtGui.QWidget() layout.addWidget(widget, row, 0, 1, 2) layout.setRowStretch(row, 1) layout = nextToolBoxItem("Geometry", ":/icons/PartDesign_InternalExternalGear.svg") def addWidget(widget): row = layout.rowCount() layout.addWidget(widget, row, 0, 1, 2) def addWidgets(widget1, widget2): row = layout.rowCount() layout.addWidget(widget1, row, 0) layout.addWidget(widget2, row, 1) def addQuantity(property, labelstring, activator=None, max=None): self.previous_value[property] = getattr(self.obj, property) widget = ui.createWidget("Gui::InputField") if activator: self.previous_value[activator] = getattr(self.obj, activator) currently_active = getattr(self.obj, activator) label = QtGui.QCheckBox(labelstring) def change(state): setattr(self.obj, activator, label.isChecked()) if label.isChecked(): widget.setStyleSheet("") else: widget.setStyleSheet(grayed_out) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() label.stateChanged.connect(change) label.setChecked(currently_active) if not currently_active: widget.setStyleSheet(grayed_out) label.setToolTip(self.obj.getDocumentationOfProperty(activator)) else: label = QtGui.QLabel(labelstring) label.setToolTip(self.obj.getDocumentationOfProperty(property)) quantity = getattr(self.obj, property) widget.setText(quantity.UserString) widget.setToolTip(self.obj.getDocumentationOfProperty(property)) if max: # cannot use widget.setMaximum() as apparently ui.createWidget() # returns the object up-casted to QWidget. widget.setProperty("maximum", max) def change(quantity): setattr(self.obj, property, quantity) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() QtCore.QObject.connect(widget, QtCore.SIGNAL("valueChanged(const Base::Quantity &)"), change) addWidgets(label, widget) return label, widget def addCheckBox(property, label): self.previous_value[property] = getattr(self.obj, property) widget = QtGui.QCheckBox(label) widget.setToolTip(self.obj.getDocumentationOfProperty(property)) def change(state): setattr(self.obj, property, widget.isChecked()) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() widget.stateChanged.connect(change) widget.setChecked(getattr(self.obj, property)) addWidget(widget) def addEnumeration(property, label, options): self.previous_value[property] = getattr(self.obj, property) label = QtGui.QLabel(label) label.setToolTip(self.obj.getDocumentationOfProperty(property)) widget = QtGui.QComboBox() widget.setToolTip(self.obj.getDocumentationOfProperty(property)) for option_label, option_value in options: widget.addItem(option_label) def change(index): setattr(self.obj, property, options[index][1]) self.obj.Proxy.execute(self.obj) FreeCAD.ActiveDocument.recompute() widget.currentIndexChanged.connect(change) addWidgets(label, widget) self.featureTree = QtGui.QTreeWidget() self.featureTree.setMinimumHeight(200) self.featureTree.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) # self.featureTree.setDragDropMode(QtGui.QAbstractItemView.DragDrop) # self.featureTree.setDefaultDropAction(QtCore.Qt.MoveAction) self.fillFeatureTree() sm = self.featureTree.selectionModel() sm.selectionChanged.connect(self.selectFeatures) addWidget(self.featureTree) self.featureTree.expandAll() self.addButton = QtGui.QPushButton("Add holes") self.addButton.clicked.connect(self.addCylinders) self.delButton = QtGui.QPushButton("Delete") self.delButton.clicked.connect(self.delCylinders) addWidgets(self.addButton, self.delButton) # End of "Features" section layout = nextToolBoxItem("Drill parameters", ":/icons/Path-OperationB.svg") addCheckBox("Active", "Operation is active") toolLoad = PathUtils.findToolController(obj) tool = toolLoad and toolLoad.Proxy.getTool(toolLoad) if not tool: drmax = None else: drmax = tool.Diameter addQuantity("DeltaR", "Step in Radius", max=drmax) addQuantity("StepDown", "Step in Z") addEnumeration("Direction", "Cut direction", [("Clockwise", "CW"), ("Counter-Clockwise", "CCW")]) addEnumeration("StartSide", "Start Side", [("Start from inside", "inside"), ("Start from outside", "outside")]) # End of "Drill parameters" section addFiller() layout = nextToolBoxItem("Cutting Depths", ":/icons/Path-Depths.svg") addQuantity("Clearance", "Clearance Distance") addQuantity("StartDepth", "Absolute start height", "UseStartDepth") fdcheckbox, fdinput = addQuantity("FinalDepth", "Absolute final height", "UseFinalDepth") tdlabel, tdinput = addQuantity("ThroughDepth", "Extra drill depth\nfor open holes") # End of "Cutting Depths" section addFiller() # make ThroughDepth and FinalDepth mutually exclusive def fd_change(state): if fdcheckbox.isChecked(): tdinput.setStyleSheet(grayed_out) else: tdinput.setStyleSheet("") fdcheckbox.stateChanged.connect(fd_change) def td_change(quantity): fdcheckbox.setChecked(False) QtCore.QObject.connect(tdinput, QtCore.SIGNAL("valueChanged(const Base::Quantity &)"), td_change) if obj.UseFinalDepth: tdinput.setStyleSheet(grayed_out)
def setDefaultValues(self, obj): """setDefaultValues(obj) ... base implementation. Do not overwrite, overwrite opSetDefaultValues() instead.""" if self.job: job = self.job else: job = PathUtils.addToJob(obj) obj.Active = True features = self.opFeatures(obj) if FeatureTool & features: if 1 < len(job.Operations.Group): obj.ToolController = PathUtil.toolControllerForOp( job.Operations.Group[-2]) else: obj.ToolController = PathUtils.findToolController(obj, self) if not obj.ToolController: raise PathNoTCException() obj.OpToolDiameter = obj.ToolController.Tool.Diameter if FeatureCoolant & features: PathLog.track() PathLog.debug(obj.getEnumerationsOfProperty("CoolantMode")) obj.CoolantMode = job.SetupSheet.CoolantMode if FeatureDepths & features: if self.applyExpression(obj, "StartDepth", job.SetupSheet.StartDepthExpression): obj.OpStartDepth = 1.0 else: obj.StartDepth = 1.0 if self.applyExpression(obj, "FinalDepth", job.SetupSheet.FinalDepthExpression): obj.OpFinalDepth = 0.0 else: obj.FinalDepth = 0.0 else: obj.StartDepth = 1.0 if FeatureStepDown & features: if not self.applyExpression(obj, "StepDown", job.SetupSheet.StepDownExpression): obj.StepDown = "1 mm" if FeatureHeights & features: if job.SetupSheet.SafeHeightExpression: if not self.applyExpression( obj, "SafeHeight", job.SetupSheet.SafeHeightExpression): obj.SafeHeight = "3 mm" if job.SetupSheet.ClearanceHeightExpression: if not self.applyExpression( obj, "ClearanceHeight", job.SetupSheet.ClearanceHeightExpression): obj.ClearanceHeight = "5 mm" if FeatureDiameters & features: obj.MinDiameter = "0 mm" obj.MaxDiameter = "0 mm" if job.Stock: obj.MaxDiameter = job.Stock.Shape.BoundBox.XLength if FeatureStartPoint & features: obj.UseStartPoint = False self.opSetDefaultValues(obj, job) return job
def execute(self, obj): from Part import Circle, Cylinder, Plane from PathScripts import PathUtils from math import sqrt output = '(helix cut operation' if obj.Comment: output += ', ' + str(obj.Comment) + ')\n' else: output += ')\n' if obj.Features: if not obj.Active: obj.Path = Path.Path("(helix cut operation inactive)") if obj.ViewObject: obj.ViewObject.Visibility = False return if not obj.ToolController: obj.ToolController = PathUtils.findToolController(obj) toolLoad = obj.ToolController if toolLoad is None or toolLoad.ToolNumber == 0: FreeCAD.Console.PrintError("PathHelix: No tool selected for helix cut operation, insert a tool change operation first\n") obj.Path = Path.Path("(ERROR: no tool selected for helix cut operation)") return tool = toolLoad.Proxy.getTool(toolLoad) zsafe = max(baseobj.Shape.BoundBox.ZMax for baseobj, features in obj.Features) + obj.Clearance.Value output += "G0 Z" + fmt(zsafe) drill_jobs = [] for base, features in obj.Features: for center, by_radius in features_by_centers(base, features).items(): radii = sorted(by_radius.keys(), reverse=True) cylinders = map(lambda radius: getattr(base.Shape, by_radius[radius]), radii) zsafe = max(cyl.BoundBox.ZMax for cyl in cylinders) + obj.Clearance.Value cur_z = cylinders[0].BoundBox.ZMax jobs = [] for cylinder in cylinders: # Find other edge of current cylinder other_edge = None for edge in cylinder.Edges: if isinstance(edge.Curve, Circle) and edge.Curve.Center.z != cur_z: other_edge = edge break next_z = other_edge.Curve.Center.z dz = next_z - cur_z r = cylinder.Surface.Radius if dz < 0: # This is a closed hole if the face connected to # the current cylinder at next_z has the cylinder's # edge as its OuterWire closed = None for face in base.Shape.Faces: if connected(other_edge, face) and not face.isSame(cylinder.Faces[0]): wire = face.OuterWire if len(wire.Edges) == 1 and wire.Edges[0].isSame(other_edge): closed = True else: closed = False if closed is None: raise Exception("Cannot determine if this cylinder is closed on the z = {0} side".format(next_z)) xc, yc, _ = cylinder.Surface.Center jobs.append(dict(xc=xc, yc=yc, zmin=next_z, zmax=cur_z, zsafe=zsafe, r_out=r, r_in=0.0, closed=closed)) elif dz > 0: new_jobs = [] for job in jobs: if job["zmin"] < next_z < job["zmax"]: # split this job job1 = dict(job) job2 = dict(job) job1["zmin"] = next_z job2["zmax"] = next_z job2["r_in"] = r new_jobs.append(job1) new_jobs.append(job2) else: new_jobs.append(job) jobs = new_jobs else: FreeCAD.Console.PrintError("PathHelix: Encountered cylinder with zero height\n") break cur_z = next_z if obj.UseStartDepth: jobs = [job for job in jobs if job["zmin"] < obj.StartDepth.Value] if jobs: jobs[0]["zmax"] = obj.StartDepth.Value if obj.UseFinalDepth: jobs = [job for job in jobs if job["zmax"] > obj.FinalDepth.Value] if jobs: jobs[-1]["zmin"] = obj.FinalDepth.Value else: if not jobs[-1]["closed"]: jobs[-1]["zmin"] -= obj.ThroughDepth.Value drill_jobs.extend(jobs) drill_jobs = self.sort_jobs(drill_jobs) for job in drill_jobs: output += helix_cut((job["xc"], job["yc"]), job["r_out"], job["r_in"], obj.DeltaR.Value, job["zmax"], job["zmin"], obj.StepDown.Value, job["zsafe"], tool.Diameter, toolLoad.VertFeed.Value, toolLoad.HorizFeed.Value, obj.Direction, obj.StartSide) output += '\n' obj.Path = Path.Path(output) if obj.ViewObject: obj.ViewObject.Visibility = True