-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathffDesign_HoleWizard.py
More file actions
81 lines (60 loc) · 2.63 KB
/
ffDesign_HoleWizard.py
File metadata and controls
81 lines (60 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import FreeCADGui
import FreeCAD
import ffDesign_Utils as Utils
class HoleWizardTaskPanel:
def __init__(self, hole):
Utils.assert_hole(hole)
self.hole = hole
self.form = FreeCADGui.PySideUic.loadUi(Utils.Resources.get_panel("ffDesign_HoleWizard.ui"))
self.form.AddCounterboreBridges.clicked.connect(self.addCounterboreBridges)
self.form.AddRibThreads.clicked.connect(self.addRibThreads)
self.form.AddRoofBridge.clicked.connect(self.addRoofBridge)
self.form.AddTeardropShape.clicked.connect(self.addTeardropShape)
self.updateCommandAvailability()
def updateCommandAvailability(self):
has_counterbore_maybe = Utils.hole_has_counterbore_maybe(self.hole)
is_threaded = self.hole.Threaded
self.form.AddCounterboreBridges.setEnabled(has_counterbore_maybe)
self.form.AddRibThreads.setEnabled(is_threaded)
# The following hole tools are always available
self.form.AddTeardropShape.setEnabled(True)
self.form.AddRoofBridge.setEnabled(True)
def addCounterboreBridges(self):
FreeCADGui.Control.closeDialog()
FreeCADGui.runCommand("ffDesign_CounterboreBridges")
def addRibThreads(self):
FreeCADGui.Control.closeDialog()
FreeCADGui.runCommand("ffDesign_RibThreads")
def addRoofBridge(self):
FreeCADGui.Control.closeDialog()
FreeCADGui.runCommand("ffDesign_RoofBridge")
def addTeardropShape(self):
FreeCADGui.Control.closeDialog()
FreeCADGui.runCommand("ffDesign_Teardrop")
def accept(self):
FreeCADGui.Control.closeDialog()
def reject(self):
FreeCADGui.Control.closeDialog()
class HoleWizardCommand:
def GetResources(self):
return {
"Pixmap": "icons:ffDesign_HoleWizard.svg",
"MenuText": FreeCAD.Qt.translate("ffDesign", "Hole Wizard"),
"ToolTip": FreeCAD.Qt.translate(
"ffDesign",
"A wizard for adding various FFF 3d-printing geometry to PartDesign Hole features.\n"
"1. Select a Hole feature in the active body.\n"
"2. Run this command.\n"
"3. Select the kind of geometry you want to add in the task panel.",
),
}
def Activated(self):
try:
hole = Utils.get_selected_hole()
dialog = HoleWizardTaskPanel(hole)
FreeCADGui.Control.showDialog(dialog)
except Utils.ffDesignError as e:
e.emit_to_user()
def IsActive(self):
return Utils.check_hole_tool_preconditions()
FreeCADGui.addCommand("ffDesign_HoleWizard", HoleWizardCommand())