forked from Zolko-123/FreeCAD_Assembly4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FastenersDummy.py
149 lines (110 loc) · 4.49 KB
/
FastenersDummy.py
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env python3
# coding: utf-8
#
# FastenersDummy.py
import os
import FreeCADGui as Gui
import FreeCAD as App
#from FastenerBase import FSBaseObject
import Asm4_libs as Asm4
from Asm4_Translate import translate
"""
+-----------------------------------------------+
| a class to create all fasteners |
| from the Fasteners WB (ScrewMaker) |
+-----------------------------------------------+
import ScrewMaker
sm = ScrewMaker.Instance()
screwObj = sm.createFastener('ISO7046', 'M6', '20', 'simple', shapeOnly=False)
"""
class insertFastener:
"My tool object"
def __init__(self, fastenerType):
self.fastenerType = fastenerType
# Screw:
if self.fastenerType=='Screw':
self.menutext = translate("Fasteners", "Insert Screw")
self.icon = os.path.join( Asm4.iconPath , 'Asm4_Screw.svg')
# Nut:
elif self.fastenerType=='Nut':
self.menutext = translate("Fasteners", "Insert Nut")
self.icon = os.path.join( Asm4.iconPath , 'Asm4_Nut.svg')
# Washer:
elif self.fastenerType=='Washer':
self.menutext = translate("Fasteners", "Insert Washer")
self.icon = os.path.join( Asm4.iconPath , 'Asm4_Washer.svg')
# threaded rod:
elif self.fastenerType=='ThreadedRod':
self.menutext = translate("Fasteners", "Insert threaded rod")
self.icon = os.path.join( Asm4.iconPath , 'Asm4_Rod.svg')
def GetResources(self):
return {"MenuText": self.menutext,
"ToolTip": translate("Fasteners", "FastenersWorkbench is not installed.\n \nYou can install it with the FreeCAD AddonsManager:\nMenu Tools > Addon Manager > fasteners"),
"Pixmap" : self.icon }
def IsActive(self):
# it's the dummy, always inactive
return False
def Activated(self):
return
"""
+-----------------------------------------------+
| dummy placeFastener |
+-----------------------------------------------+
"""
class placeFastenerCmd():
"My tool object"
def __init__(self):
super(placeFastenerCmd,self).__init__()
def GetResources(self):
return {"MenuText": "Edit Attachment of a Fastener",
"ToolTip": 'FastenersWorkbench is not installed.\n \nYou can install it with the FreeCAD AddonsManager:\nMenu Tools > Addon Manager > fasteners',
"Pixmap" : os.path.join( Asm4.iconPath , 'Asm4_mvFastener.svg')
}
def IsActive(self):
# it's a dummy, always inactive
return False
def Activated(self):
return
"""
+-----------------------------------------------+
| dummy parameters |
+-----------------------------------------------+
"""
class changeFSparametersCmd():
def __init__(self):
super(changeFSparametersCmd,self).__init__()
def GetResources(self):
return {"MenuText": "Change Fastener parameters",
"ToolTip": "Change Fastener parameters",
"Pixmap" : os.path.join( Asm4.iconPath , 'Asm4_FSparams.svg')
}
def IsActive(self):
# it's a dummy, always inactive
return False
def Activated(self):
return
class cloneFastenersToAxesCmd():
def __init__(self):
super(cloneFastenersToAxesCmd,self).__init__()
def GetResources(self):
return {"MenuText": "Clone Fastener to Axes",
"ToolTip": 'FastenersWorkbench is not installed.\n \nYou can install it with the FreeCAD AddonsManager:\nMenu Tools > Addon Manager > fasteners',
"Pixmap" : os.path.join( Asm4.iconPath , 'Asm4_cloneFasteners.svg')
}
def IsActive(self):
# it's a dummy, always inactive
return False
def Activated(self):
return
"""
+-----------------------------------------------+
| add the commands to the workbench |
+-----------------------------------------------+
"""
Gui.addCommand( 'Asm4_insertScrew', insertFastener('Screw') )
Gui.addCommand( 'Asm4_insertNut', insertFastener('Nut') )
Gui.addCommand( 'Asm4_insertWasher', insertFastener('Washer') )
Gui.addCommand( 'Asm4_insertRod', insertFastener('ThreadedRod') )
Gui.addCommand( 'Asm4_placeFastener', placeFastenerCmd() )
Gui.addCommand( 'Asm4_cloneFastenersToAxes', cloneFastenersToAxesCmd() )
Gui.addCommand( 'Asm4_FSparameters', changeFSparametersCmd() )