diff --git a/a2p_constraintDialog.py b/a2p_constraintDialog.py index a2ef68dc..c1baa14e 100644 --- a/a2p_constraintDialog.py +++ b/a2p_constraintDialog.py @@ -124,7 +124,7 @@ def initUI(self): self.mainLayout.addWidget(lbl4,self.lineNo,0) self.offsetEdit = QtGui.QLineEdit(self) - self.offsetEdit.setText("{}".format(offs.Value)) + self.offsetEdit.setText(FreeCAD.Units.Quantity(offs.Value, FreeCAD.Units.Length).UserString) self.offsetEdit.setFixedHeight(32) self.mainLayout.addWidget(self.offsetEdit,self.lineNo,1) @@ -231,7 +231,7 @@ def setConstraintEditorData(self): else: self.constraintObject.directionConstraint = "none" if hasattr(self.constraintObject,"offset"): - self.constraintObject.offset = float(self.offsetEdit.text()) + self.constraintObject.offset = FreeCAD.Units.Quantity(self.offsetEdit.text()).Value if hasattr(self.constraintObject,"angle"): self.constraintObject.angle = float(self.angleEdit.text()) if hasattr(self.constraintObject,"lockRotation"): @@ -268,24 +268,22 @@ def flipLockRotation(self): def setOffsetZero(self): self.winModified = True - self.offsetEdit.setText("0.0") - if a2plib.getAutoSolveState(): - self.solve() + q = FreeCAD.Units.Quantity(self.offsetEdit.text()) + q.Value = 0.0 + self.offsetEdit.setText(q.UserString) def flipOffsetSign(self): self.winModified = True - try: - o = float(self.offsetEdit.text()) - o = o * -1.0 - if abs(o) > 1e-7: - self.offsetEdit.setText(str(o)) - if a2plib.getAutoSolveState(): - self.solve() - else: - self.offsetEdit.setText("0.0") - except: - self.offsetEdit.setText("0.0") - + q = FreeCAD.Units.Quantity(self.offsetEdit.text()) + q.Value = -q.Value + if abs(q.Value) > 1e-7: + self.offsetEdit.setText(q.UserString) + if a2plib.getAutoSolveState(): + self.solve() + else: + q.Value = 0.0 + self.offsetEdit.setText(q.UserString) + def flipDirection(self): self.winModified = True if self.directionCombo.currentIndex() == 0: