forked from Zolko-123/FreeCAD_Assembly4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FastenersDummy.py
99 lines (71 loc) · 2.72 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
#!/usr/bin/env python3
# coding: utf-8
#
# FastenersDummy.py
import os
import FreeCADGui as Gui
import FreeCAD as App
#from FastenerBase import FSBaseObject
import libAsm4 as Asm4
"""
+-----------------------------------------------+
| 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 = "Insert Screw"
self.icon = os.path.join( Asm4.iconPath , 'Asm4_Screw.svg')
# Nut:
elif self.fastenerType=='Nut':
self.menutext = "Insert Nut"
self.icon = os.path.join( Asm4.iconPath , 'Asm4_Nut.svg')
# Washer:
elif self.fastenerType=='Washer':
self.menutext = "Insert Washer"
self.icon = os.path.join( Asm4.iconPath , 'Asm4_Washer.svg')
def GetResources(self):
return {"MenuText": self.menutext,
"ToolTip": '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
"""
+-----------------------------------------------+
| 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_placeFastener', placeFastenerCmd() )