| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | """Provides the TechDraw HoleShaftFit GuiCommand.""" |
| |
|
| | __title__ = "TechDrawTools.CommandHoleShaftFit" |
| | __author__ = "edi" |
| | __url__ = "https://www.freecad.org" |
| | __version__ = "00.01" |
| | __date__ = "2023/02/07" |
| |
|
| | from PySide.QtCore import QT_TRANSLATE_NOOP |
| | from PySide import QtGui |
| | from PySide.QtGui import QMessageBox |
| |
|
| | import FreeCAD as App |
| | import FreeCADGui as Gui |
| |
|
| | import TechDrawTools |
| |
|
| | translate = App.Qt.translate |
| |
|
| |
|
| | class CommandHoleShaftFit: |
| | """Adds a hole or shaft fit to a selected dimension.""" |
| |
|
| | def GetResources(self): |
| | """Return a dictionary with data that will be used by the button or menu item.""" |
| | return { |
| | "Pixmap": "actions/TechDraw_HoleShaftFit.svg", |
| | "Accel": "", |
| | "MenuText": QT_TRANSLATE_NOOP( |
| | "TechDraw_HoleShaftFit", "Hole/Shaft Fit" |
| | ), |
| | "ToolTip": QT_TRANSLATE_NOOP( |
| | "TechDraw_HoleShaftFit", |
| | "Adds a hole or shaft fit to a selected length or diameter dimension" |
| | ), |
| | } |
| |
|
| | def Activated(self): |
| | """Run the following code when the command is activated (button press).""" |
| | sel = Gui.Selection.getSelectionEx() |
| | |
| | if sel[0].Object.TypeId == "TechDraw::DrawViewDimension": |
| | self.ui = TechDrawTools.TaskHoleShaftFit(sel) |
| | Gui.Control.showDialog(self.ui) |
| | else: |
| | msgBox = QtGui.QMessageBox() |
| | msgTitle = translate( |
| | "TechDraw_HoleShaftFit", "Add a hole or shaft fit to a dimension" |
| | ) |
| | msg = translate( |
| | "TechDraw_HoleShaftFit", |
| | "Select one length dimension or diameter dimension and retry", |
| | ) |
| | msgBox.setText(msg) |
| | msgBox.setWindowTitle(msgTitle) |
| | msgBox.exec_() |
| |
|
| | def IsActive(self): |
| | """Return True when the command should be active or False when it should be disabled (greyed).""" |
| | if App.ActiveDocument: |
| | sel = Gui.Selection.getSelectionEx() |
| | return ( |
| | TechDrawTools.TDToolsUtil.havePage() |
| | and TechDrawTools.TDToolsUtil.haveView() |
| | and len(sel) == 1 |
| | ) |
| | else: |
| | return False |
| |
|
| | |
| | |
| | Gui.addCommand('TechDraw_HoleShaftFit', CommandHoleShaftFit()) |
| |
|