24
24
###################################################################################
28
26
from FreeCAD import Gui
27
import FreeCAD, FreeCADGui, Part, os
30
28
__dir__ = os.path.dirname(__file__)
31
iconPath = os.path.join(__dir__, 'Icons')
29
iconPath = os.path.join( __dir__, 'Icons' )
33
32
import FastenerBase
34
33
from FastenerBase import FSBaseObject
37
35
screwMaker = ScrewMaker.Instance()
40
37
class FSScrewObject(FSBaseObject):
41
def __init__(self, obj, type, attachTo):
42
'''"Add screw type fastener" '''
43
super().__init__(self, obj, attachTo)
44
self.itemText = screwMaker.GetTypeName(type)
45
diameters = screwMaker.GetAllDiams(type)
46
diameters.insert(0, 'Auto')
52
# self.Proxy = obj.Name
53
obj.addProperty("App::PropertyEnumeration", "type", "Parameters", "Screw type").type = screwMaker.GetAllTypes(
56
obj.addProperty("App::PropertyEnumeration", "diameter", "Parameters",
57
"Screw diameter standard").diameter = diameters
58
self.VerifyMissingAttrs(obj, diameters[1])
59
if self.itemText != "Washer":
60
obj.addProperty("App::PropertyBool", "thread", "Parameters", "Generate real thread").thread = False
63
def inswap(self, inpstr):
65
return inpstr.replace('″', 'in')
69
def VerifyMissingAttrs(self, obj, diameter):
71
if not hasattr(obj, 'matchOuter'):
72
obj.addProperty("App::PropertyBool", "matchOuter", "Parameters", "Match outer thread diameter").matchOuter = FastenerBase.FSMatchOuter
73
if self.itemText == "Screw" and not hasattr(obj, 'lengthCustom'):
74
slens = screwMaker.GetAllLengths(obj.type, diameter)
75
if hasattr(obj, 'length'):
80
obj.addProperty("App::PropertyEnumeration", "length", "Parameters", "Screw length").length = slens
81
obj.addProperty("App::PropertyLength", "lengthCustom", "Parameters",
82
"Custom length").lengthCustom = self.inswap(slens[0])
84
def ActiveLength(self, obj):
85
if not hasattr(obj, 'length'):
87
if obj.length == 'Custom':
88
return str(float(obj.lengthCustom)).rstrip("0").rstrip('.')
91
def execute(self, fp):
92
'''"Print a short message when doing a recomputation, this method is mandatory" '''
95
baseobj = fp.baseObject[0]
96
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
101
# for backward compatibility: add missing attribute if needed
102
self.VerifyMissingAttrs(fp, fp.diameter)
104
# FreeCAD.Console.PrintLog("MatchOuter:" + str(fp.matchOuter) + "\n")
107
if fp.type == "ISO7380":
108
fp.type = "ISO7380-1" # backward compatibility
109
if not (hasattr(self, 'type')) or fp.type != self.type:
111
curdiam = fp.diameter
112
diameters = screwMaker.GetAllDiams(fp.type)
113
diameters.insert(0, 'Auto')
114
if not (curdiam in diameters):
116
fp.diameter = diameters
117
fp.diameter = curdiam
119
diameterchange = False
120
if not (hasattr(self, 'diameter')) or self.diameter != fp.diameter:
121
diameterchange = True
123
matchouterchange = not (hasattr(self, 'matchOuter')) or self.matchOuter != fp.matchOuter
125
if fp.diameter == 'Auto' or matchouterchange:
126
d = screwMaker.AutoDiameter(fp.type, shape, baseobj, fp.matchOuter)
128
diameterchange = True
132
if hasattr(fp, 'length'):
133
if fp.length != self.length:
134
if fp.length != 'Custom':
135
fp.lengthCustom = FastenerBase.LenStr2Num(fp.length) # ***
136
elif hasattr(self, 'customlen') and float(fp.lengthCustom) != self.customlen:
138
origLen = self.ActiveLength(fp)
139
origIsCustom = fp.length == 'Custom'
140
d, l = screwMaker.FindClosest(fp.type, d, origLen)
142
diameterchange = True
148
if l != origLen or diameterchange or typechange:
149
if diameterchange or typechange:
150
fp.length = screwMaker.GetAllLengths(fp.type, fp.diameter)
159
screwMaker.updateFastenerParameters()
161
threadType = 'simple'
162
if hasattr(fp, 'thread') and fp.thread:
165
(key, s) = FastenerBase.FSGetKey(self.itemText, fp.type, d, l, threadType)
167
s = screwMaker.createFastener(fp.type, d, l, threadType, True)
168
FastenerBase.FSCache[key] = s
170
FreeCAD.Console.PrintLog("Using cached object\n")
173
self.diameter = fp.diameter
174
self.matchOuter = fp.matchOuter
175
if hasattr(fp, 'length'):
177
self.customlen = float(fp.lengthCustom)
178
fp.Label = fp.diameter + 'x' + l + '-' + self.itemText
180
fp.Label = fp.diameter + '-' + self.itemText
182
if hasattr(fp, 'thread'):
183
self.realThread = fp.thread
184
# self.itemText = s[1]
187
if shape is not None:
188
# feature = FreeCAD.ActiveDocument.getObject(self.Proxy)
189
# fp.Placement = FreeCAD.Placement() # reset placement
190
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
193
# return self.itemText
38
def __init__(self, obj, type, attachTo):
39
'''"Add screw type fastener" '''
40
FSBaseObject.__init__(self, obj, attachTo)
41
self.itemText = screwMaker.GetTypeName(type)
42
diameters = screwMaker.GetAllDiams(type)
43
diameters.insert(0, 'Auto')
49
#self.Proxy = obj.Name
50
obj.addProperty("App::PropertyEnumeration","type","Parameters","Screw type").type = screwMaker.GetAllTypes(self.itemText)
52
obj.addProperty("App::PropertyEnumeration","diameter","Parameters","Screw diameter standard").diameter = diameters
53
self.VerifyMissingAttrs(obj, diameters[1])
54
if self.itemText != "Washer":
55
obj.addProperty("App::PropertyBool", "thread", "Parameters", "Generate real thread").thread = False
58
def inswap(self, inpstr):
60
return inpstr.replace('″', 'in')
64
def VerifyMissingAttrs(self, obj, diameter):
66
if not (hasattr(obj, 'matchOuter')):
67
obj.addProperty("App::PropertyBool", "matchOuter", "Parameters", "Match outer thread diameter").matchOuter = FastenerBase.FSMatchOuter
68
if self.itemText == "Screw" and not hasattr(obj, 'lengthCustom'):
69
slens = screwMaker.GetAllLengths(obj.type, diameter)
70
if hasattr(obj, 'length'):
75
obj.addProperty("App::PropertyEnumeration","length","Parameters","Screw length").length = slens
76
obj.addProperty("App::PropertyLength","lengthCustom","Parameters","Custom length").lengthCustom = self.inswap(slens[0])
78
def ActiveLength(self, obj):
79
if not hasattr(obj,'length'):
81
if obj.length == 'Custom':
82
return str(float(obj.lengthCustom)).rstrip("0").rstrip('.')
85
def execute(self, fp):
86
'''"Print a short message when doing a recomputation, this method is mandatory" '''
89
baseobj = fp.baseObject[0]
90
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
95
# for backward compatibility: add missing attribute if needed
96
self.VerifyMissingAttrs(fp, fp.diameter)
98
#FreeCAD.Console.PrintLog("MatchOuter:" + str(fp.matchOuter) + "\n")
101
if fp.type == "ISO7380":
102
fp.type = "ISO7380-1" # backward compatibility
103
if not (hasattr(self, 'type')) or fp.type != self.type:
105
curdiam = fp.diameter
106
diameters = screwMaker.GetAllDiams(fp.type)
107
diameters.insert(0, 'Auto')
108
if not(curdiam in diameters):
110
fp.diameter = diameters
111
fp.diameter = curdiam
113
diameterchange = False
114
if not (hasattr(self, 'diameter')) or self.diameter != fp.diameter:
115
diameterchange = True
117
matchouterchange = not (hasattr(self, 'matchOuter')) or self.matchOuter != fp.matchOuter
119
if fp.diameter == 'Auto' or matchouterchange:
120
d = screwMaker.AutoDiameter(fp.type, shape, baseobj, fp.matchOuter)
122
diameterchange = True
126
if hasattr(fp,'length'):
127
if fp.length != self.length:
128
if fp.length != 'Custom':
129
fp.lengthCustom = FastenerBase.LenStr2Num(fp.length) #***
130
elif hasattr(self,'customlen') and float(fp.lengthCustom) != self.customlen:
132
origLen = self.ActiveLength(fp)
133
origIsCustom = fp.length == 'Custom'
134
d , l = screwMaker.FindClosest(fp.type, d, origLen)
136
diameterchange = True
142
if l != origLen or diameterchange or typechange:
143
if diameterchange or typechange:
144
fp.length = screwMaker.GetAllLengths(fp.type, fp.diameter)
153
screwMaker.updateFastenerParameters()
155
threadType = 'simple'
156
if hasattr(fp,'thread') and fp.thread:
159
(key, s) = FastenerBase.FSGetKey(self.itemText, fp.type, d, l, threadType)
161
s = screwMaker.createFastener(fp.type, d, l, threadType, True)
162
FastenerBase.FSCache[key] = s
164
FreeCAD.Console.PrintLog("Using cached object\n")
167
self.diameter = fp.diameter
168
self.matchOuter = fp.matchOuter
169
if hasattr(fp,'length'):
171
self.customlen = float(fp.lengthCustom)
172
fp.Label = fp.diameter + 'x' + l + '-' + self.itemText
174
fp.Label = fp.diameter + '-' + self.itemText
176
if hasattr(fp,'thread'):
177
self.realThread = fp.thread
178
#self.itemText = s[1]
181
if shape is not None:
182
#feature = FreeCAD.ActiveDocument.getObject(self.Proxy)
183
#fp.Placement = FreeCAD.Placement() # reset placement
184
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
187
# return self.itemText
196
191
class FSViewProviderTree:
197
"A View provider for custom icon"
199
def __init__(self, obj):
201
self.Object = obj.Object
203
def attach(self, obj):
204
self.Object = obj.Object
207
def updateData(self, fp, prop):
210
def getDisplayModes(self, obj):
214
def setDisplayMode(self, mode):
217
def onChanged(self, vp, prop):
220
def __getstate__(self):
221
# return {'ObjectName' : self.Object.Name}
224
def __setstate__(self, state):
225
if state is not None:
227
doc = FreeCAD.ActiveDocument # crap
228
self.Object = doc.getObject(state['ObjectName'])
231
if hasattr(self.Object, "type"):
232
return os.path.join(iconPath, self.Object.type + '.svg')
233
elif hasattr(self.Object.Proxy, "type"):
234
return os.path.join(iconPath, self.Object.Proxy.type + '.svg')
235
# default to ISO4017.svg
236
return os.path.join(iconPath, 'ISO4017.svg')
192
"A View provider for custom icon"
194
def __init__(self, obj):
196
self.Object = obj.Object
198
def attach(self, obj):
199
self.Object = obj.Object
202
def updateData(self, fp, prop):
205
def getDisplayModes(self,obj):
209
def setDisplayMode(self,mode):
212
def onChanged(self, vp, prop):
215
def __getstate__(self):
216
# return {'ObjectName' : self.Object.Name}
219
def __setstate__(self,state):
220
if state is not None:
222
doc = FreeCAD.ActiveDocument #crap
223
self.Object = doc.getObject(state['ObjectName'])
226
if hasattr(self.Object, "type"):
227
return os.path.join( iconPath , self.Object.type + '.svg')
228
elif hasattr(self.Object.Proxy, "type"):
229
return os.path.join( iconPath, self.Object.Proxy.type + '.svg')
230
# default to ISO4017.svg
231
return os.path.join( iconPath , 'ISO4017.svg')
239
235
class FSScrewCommand:
240
"""Add Screw command"""
242
def __init__(self, type, help):
245
self.TypeName = screwMaker.GetTypeName(type)
247
def GetResources(self):
248
icon = os.path.join(iconPath, self.Type + '.svg')
250
'Pixmap': icon, # the name of a svg file available in the resources
251
'MenuText': "Add " + self.Help,
256
for selObj in FastenerBase.FSGetAttachableSelections():
257
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", self.TypeName)
258
FSScrewObject(a, self.Type, selObj)
259
a.Label = a.Proxy.itemText
260
FSViewProviderTree(a.ViewObject)
261
FreeCAD.ActiveDocument.recompute()
265
return Gui.ActiveDocument is not None
268
def FSAddScrewCommand(type, help, dropGroup=None):
270
Gui.addCommand(cmd, FSScrewCommand(type, help))
271
FastenerBase.FSCommands.append(cmd, "screws", dropGroup)
236
"""Add Screw command"""
238
def __init__(self, type, help):
241
self.TypeName = screwMaker.GetTypeName(type)
243
def GetResources(self):
244
icon = os.path.join( iconPath , self.Type + '.svg')
245
return {'Pixmap' : icon , # the name of a svg file available in the resources
246
'MenuText': "Add " + self.Help ,
247
'ToolTip' : self.Help}
250
for selObj in FastenerBase.FSGetAttachableSelections():
251
a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython",self.TypeName)
252
FSScrewObject(a, self.Type, selObj)
253
a.Label = a.Proxy.itemText
254
FSViewProviderTree(a.ViewObject)
255
FreeCAD.ActiveDocument.recompute()
259
return Gui.ActiveDocument is not None
261
def FSAddScrewCommand(type, help, dropGroup = None):
263
Gui.addCommand(cmd,FSScrewCommand(type, help))
264
FastenerBase.FSCommands.append(cmd, "screws", dropGroup)
274
266
FSAddScrewCommand("ISO4017", "ISO 4017 Hex head screw", "Hex head")
275
267
FSAddScrewCommand("ISO4014", "ISO 4014 Hex head bolt", "Hex head")
276
268
FSAddScrewCommand("EN1662", "EN 1662 Hexagon bolt with flange, small series", "Hex head")
336
328
FSAddScrewCommand("ASMEB18.21.1.12C", "ASME B18.21.1 UN washers, wide series", "Washer")
340
334
class FSWasherObject(FSBaseObject):
341
def __init__(self, obj, type, attachTo):
342
'''"Add washer / nut type fastener" '''
343
FSBaseObject.__init__(self, obj, attachTo)
344
self.itemText = screwMaker.GetTypeName(type)
345
diameters = screwMaker.GetAllDiams(type)
346
diameters.insert(0, 'Auto')
347
# self.Proxy = obj.Name
349
obj.addProperty("App::PropertyEnumeration", "type", "Parameters", "Screw type").type = screwMaker.GetAllTypes(
351
obj.addProperty("App::PropertyEnumeration", "diameter", "Parameters",
352
"Screw diameter standard").diameter = diameters
356
def execute(self, fp):
357
'''"Print a short message when doing a recomputation, this method is mandatory" '''
360
baseobj = fp.baseObject[0]
361
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
366
if not (hasattr(self, 'diameter')) or self.diameter != fp.diameter:
367
if fp.diameter == 'Auto':
368
d = screwMaker.AutoDiameter(fp.type, shape)
369
diameterchange = True
373
d, l = screwMaker.FindClosest(fp.type, d, '0')
376
s = screwMaker.createScrew(fp.type, d, l, 'simple', True)
377
self.diameter = fp.diameter
378
fp.Label = fp.diameter + '-' + self.itemText
379
# self.itemText = s[1]
382
FreeCAD.Console.PrintLog("Using cached object\n")
383
if shape is not None:
384
# feature = FreeCAD.ActiveDocument.getObject(self.Proxy)
385
# fp.Placement = FreeCAD.Placement() # reset placement
386
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
388
def getItemText(self):
335
def __init__(self, obj, type, attachTo):
336
'''"Add washer / nut type fastener" '''
337
FSBaseObject.__init__(self, obj, attachTo)
338
self.itemText = screwMaker.GetTypeName(type)
339
diameters = screwMaker.GetAllDiams(type)
340
diameters.insert(0, 'Auto')
341
#self.Proxy = obj.Name
343
obj.addProperty("App::PropertyEnumeration","type","Parameters","Screw type").type = screwMaker.GetAllTypes(self.itemText)
344
obj.addProperty("App::PropertyEnumeration","diameter","Parameters","Screw diameter standard").diameter = diameters
348
def execute(self, fp):
349
'''"Print a short message when doing a recomputation, this method is mandatory" '''
352
baseobj = fp.baseObject[0]
353
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
358
if not (hasattr(self, 'diameter')) or self.diameter != fp.diameter:
359
if fp.diameter == 'Auto':
360
d = screwMaker.AutoDiameter(fp.type, shape)
361
diameterchange = True
365
d , l = screwMaker.FindClosest(fp.type, d, '0')
368
s = screwMaker.createScrew(fp.type, d, l, 'simple', True)
369
self.diameter = fp.diameter
370
fp.Label = fp.diameter + '-' + self.itemText
371
#self.itemText = s[1]
374
FreeCAD.Console.PrintLog("Using cached object\n")
375
if shape is not None:
376
#feature = FreeCAD.ActiveDocument.getObject(self.Proxy)
377
#fp.Placement = FreeCAD.Placement() # reset placement
378
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
393
384
class FSWasherCommand:
394
"""Add Screw command"""
396
def __init__(self, type, help):
400
def GetResources(self):
401
icon = os.path.join(iconPath, self.Type + '.svg')
403
'Pixmap': icon, # the name of a svg file available in the resources
404
'MenuText': "Add " + self.Help,
409
for selObj in FastenerBase.FSGetAttachableSelections():
410
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "Washer")
411
FSWasherObject(a, self.Type, selObj)
412
a.Label = a.Proxy.itemText
413
FSViewProviderTree(a.ViewObject)
414
FreeCAD.ActiveDocument.recompute()
418
return Gui.ActiveDocument is not None
421
# Gui.addCommand("FSISO7089",FSWasherCommand("ISO7089", "Washer"))
422
# FastenerBase.FSCommands.append("FSISO7089")
385
"""Add Screw command"""
387
def __init__(self, type, help):
391
def GetResources(self):
392
icon = os.path.join( iconPath , self.Type + '.svg')
393
return {'Pixmap' : icon , # the name of a svg file available in the resources
394
'MenuText': "Add " + self.Help ,
395
'ToolTip' : self.Help}
398
for selObj in FastenerBase.FSGetAttachableSelections():
399
a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","Washer")
400
FSWasherObject(a, self.Type, selObj)
401
a.Label = a.Proxy.itemText
402
FSViewProviderTree(a.ViewObject)
403
FreeCAD.ActiveDocument.recompute()
407
return Gui.ActiveDocument is not None
409
#Gui.addCommand("FSISO7089",FSWasherCommand("ISO7089", "Washer"))
410
#FastenerBase.FSCommands.append("FSISO7089")
424
412
class FSScrewRodObject(FSBaseObject):
425
def __init__(self, obj, attachTo, typeStr):
426
'''"Add screw rod" '''
427
FSBaseObject.__init__(self, obj, attachTo)
428
self.itemText = "ScrewTap"
430
diameters = screwMaker.GetAllDiams(self.type) + ["Custom"]
431
diameters.insert(0, 'Auto')
432
obj.addProperty("App::PropertyEnumeration", "diameter", "Parameters", "Screw diameter standard").diameter = diameters
433
obj.addProperty("App::PropertyLength", "diameterCustom", "Parameters", "Screw major diameter custom").diameterCustom = 6
434
obj.addProperty("App::PropertyLength", "pitchCustom", "Parameters", "Screw pitch custom").pitchCustom = 1.0
435
obj.addProperty("App::PropertyLength", "length", "Parameters", "Screw length").length = 20.0
436
self.VerifyMissingAttrs(obj)
437
obj.addProperty("App::PropertyBool", "thread", "Parameters", "Generate real thread").thread = False
440
def VerifyMissingAttrs(self, obj):
441
self.updateProps(obj)
442
if not (hasattr(obj, 'matchOuter')):
443
obj.addProperty("App::PropertyBool", "matchOuter", "Parameters", "Match outer thread diameter").matchOuter = FastenerBase.FSMatchOuter
444
# for old objects from before custom diameter and pitch were implemented
445
if not hasattr(obj, "pitchCustom"):
446
obj.addProperty("App::PropertyLength", "pitchCustom", "Parameters", "Screw pitch custom").pitchCustom = 1.0
447
obj.addProperty("App::PropertyLength", "diameterCustom", "Parameters", "Screw major diameter custom").diameterCustom = 6
448
dia_tmp = obj.diameter
449
self.type = "ScrewTap"
450
obj.diameter = screwMaker.GetAllDiams(self.type) + ["Custom"]
451
obj.diameter = dia_tmp
453
def execute(self, fp):
454
'''"Print a short message when doing a recomputation, this method is mandatory" '''
457
baseobj = fp.baseObject[0]
458
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
462
self.VerifyMissingAttrs(fp)
463
diameterchange = False
464
if not (hasattr(self, 'diameter')) or self.diameter != fp.diameter:
465
diameterchange = True
467
matchouterchange = not (hasattr(self, 'matchOuter')) or self.matchOuter != fp.matchOuter
469
if fp.diameter == 'Auto' or matchouterchange:
470
d = screwMaker.AutoDiameter(self.type, shape, baseobj, fp.matchOuter)
472
diameterchange = True
474
elif fp.diameter == 'Custom':
476
d_custom = fp.diameterCustom.Value
486
if fp.diameter == 'Custom':
487
p = fp.pitchCustom.Value
490
screwMaker.updateFastenerParameters()
491
threadType = 'simple'
492
if hasattr(fp, 'thread') and fp.thread:
494
# since we are bypassing the createScrew() method, we must set
495
# the rThread parameter manually
496
screwMaker.rThread = (threadType == 'real')
497
s = screwMaker.makeScrewTap(self.type, d, l, p, d_custom)
499
self.diameter = fp.diameter
501
self.matchOuter = fp.matchOuter
502
diastr = fp.diameter if fp.diameter != 'Custom' else str(fp.diameterCustom)
503
fp.Label = diastr + 'x' + str(l) + '-' + self.itemText
504
self.realThread = fp.thread
507
if shape is not None:
508
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
413
def __init__(self, obj, attachTo, typeStr):
414
'''"Add screw rod" '''
415
FSBaseObject.__init__(self, obj, attachTo)
416
self.itemText = "ScrewTap"
418
diameters = screwMaker.GetAllDiams(self.type) + ["Custom"]
419
diameters.insert(0, 'Auto')
420
obj.addProperty("App::PropertyEnumeration","diameter","Parameters","Screw diameter standard").diameter = diameters
421
obj.addProperty("App::PropertyLength","diameterCustom","Parameters","Screw major diameter custom").diameterCustom = 6
422
obj.addProperty("App::PropertyLength","pitchCustom","Parameters","Screw pitch custom").pitchCustom = 1.0
423
obj.addProperty("App::PropertyLength","length","Parameters","Screw length").length = 20.0
424
self.VerifyMissingAttrs(obj)
425
obj.addProperty("App::PropertyBool", "thread", "Parameters", "Generate real thread").thread = False
428
def VerifyMissingAttrs(self, obj):
429
self.updateProps(obj)
430
if not (hasattr(obj, 'matchOuter')):
431
obj.addProperty("App::PropertyBool", "matchOuter", "Parameters", "Match outer thread diameter").matchOuter = FastenerBase.FSMatchOuter
432
# for old objects from before custom diameter and pitch were implemented
433
if not hasattr(obj,"pitchCustom"):
434
obj.addProperty("App::PropertyLength","pitchCustom","Parameters","Screw pitch custom").pitchCustom = 1.0
435
obj.addProperty("App::PropertyLength","diameterCustom","Parameters","Screw major diameter custom").diameterCustom = 6
436
dia_tmp = obj.diameter
437
self.type = "ScrewTap"
438
obj.diameter = screwMaker.GetAllDiams(self.type) + ["Custom"]
439
obj.diameter = dia_tmp
442
def execute(self, fp):
443
'''"Print a short message when doing a recomputation, this method is mandatory" '''
446
baseobj = fp.baseObject[0]
447
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
451
self.VerifyMissingAttrs(fp)
452
diameterchange = False
453
if not (hasattr(self, 'diameter')) or self.diameter != fp.diameter:
454
diameterchange = True
456
matchouterchange = not (hasattr(self, 'matchOuter')) or self.matchOuter != fp.matchOuter
458
if fp.diameter == 'Auto' or matchouterchange:
459
d = screwMaker.AutoDiameter(self.type, shape, baseobj, fp.matchOuter)
461
diameterchange = True
463
elif fp.diameter == 'Custom':
465
d_custom = fp.diameterCustom.Value
475
if fp.diameter == 'Custom':
476
p = fp.pitchCustom.Value
479
screwMaker.updateFastenerParameters()
480
threadType = 'simple'
481
if hasattr(fp,'thread') and fp.thread:
483
# since we are bypassing the createScrew() method, we must set
484
# the rThread parameter manually
485
screwMaker.rThread = (threadType == 'real')
486
s = screwMaker.makeScrewTap(self.type,d,l,p,d_custom)
488
self.diameter = fp.diameter
490
self.matchOuter = fp.matchOuter
491
diastr = fp.diameter if fp.diameter != 'Custom' else str(fp.diameterCustom)
492
fp.Label = diastr + 'x' + str(l) + '-' + self.itemText
493
self.realThread = fp.thread
496
if shape is not None:
497
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
511
499
class FSScrewRodCommand:
512
"""Add Screw Rod command"""
514
def GetResources(self):
515
icon = os.path.join(iconPath, 'ScrewTap.svg')
517
'Pixmap': icon, # the name of a svg file available in the resources
518
'MenuText': "Add threaded rod for tapping holes",
519
'ToolTip': "Add arbitrary length threaded rod for tapping holes"
523
for selObj in FastenerBase.FSGetAttachableSelections():
524
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ScrewTap")
525
FSScrewRodObject(a, selObj, "ScrewTap")
526
a.Label = a.Proxy.itemText
527
FSViewProviderTree(a.ViewObject)
528
FreeCAD.ActiveDocument.recompute()
532
return Gui.ActiveDocument is not None
535
Gui.addCommand("FSScrewTap", FSScrewRodCommand())
500
"""Add Screw Rod command"""
502
def GetResources(self):
503
icon = os.path.join( iconPath , 'ScrewTap.svg')
504
return {'Pixmap' : icon , # the name of a svg file available in the resources
505
'MenuText': "Add threaded rod for tapping holes" ,
506
'ToolTip' : "Add arbitrary length threaded rod for tapping holes"}
509
for selObj in FastenerBase.FSGetAttachableSelections():
510
a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ScrewTap")
511
FSScrewRodObject(a, selObj, "ScrewTap")
512
a.Label = a.Proxy.itemText
513
FSViewProviderTree(a.ViewObject)
514
FreeCAD.ActiveDocument.recompute()
518
return Gui.ActiveDocument is not None
520
Gui.addCommand("FSScrewTap",FSScrewRodCommand())
536
521
FastenerBase.FSCommands.append("FSScrewTap", "screws", "misc")
539
523
class FSScrewRodCommandInch:
540
"""Add Screw Rod command"""
542
def GetResources(self):
543
icon = os.path.join(iconPath, 'ScrewTapInch.svg')
545
'Pixmap': icon, # the name of a svg file available in the resources
546
'MenuText': "Add inch threaded rod for tapping holes",
547
'ToolTip': "Add arbitrary length threaded rod for tapping holes (inch sizes)"
551
for selObj in FastenerBase.FSGetAttachableSelections():
552
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ScrewTap")
553
FSScrewRodObject(a, selObj, "ScrewTapInch")
554
a.Label = a.Proxy.itemText
555
FSViewProviderTree(a.ViewObject)
556
FreeCAD.ActiveDocument.recompute()
560
return Gui.ActiveDocument is not None
563
Gui.addCommand("FSScrewTapInch", FSScrewRodCommandInch())
524
"""Add Screw Rod command"""
526
def GetResources(self):
527
icon = os.path.join( iconPath , 'ScrewTapInch.svg')
528
return {'Pixmap' : icon , # the name of a svg file available in the resources
529
'MenuText': "Add inch threaded rod for tapping holes" ,
530
'ToolTip' : "Add arbitrary length threaded rod for tapping holes (inch sizes)"}
533
for selObj in FastenerBase.FSGetAttachableSelections():
534
a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ScrewTap")
535
FSScrewRodObject(a, selObj, "ScrewTapInch")
536
a.Label = a.Proxy.itemText
537
FSViewProviderTree(a.ViewObject)
538
FreeCAD.ActiveDocument.recompute()
542
return Gui.ActiveDocument is not None
544
Gui.addCommand("FSScrewTapInch",FSScrewRodCommandInch())
564
545
FastenerBase.FSCommands.append("FSScrewTapInch", "screws", "misc")
567
549
class FSScrewDieObject(FSBaseObject):
568
def __init__(self, obj, attachTo, typeStr):
569
'''"Add screw die" '''
570
FSBaseObject.__init__(self, obj, attachTo)
571
self.itemText = "ScrewDie"
573
diameters = screwMaker.GetAllDiams(self.type) + ["Custom"]
574
diameters.insert(0, 'Auto')
575
# self.Proxy = obj.Name
577
obj.addProperty("App::PropertyEnumeration", "diameter", "Parameters", "Screw diameter standard").diameter = diameters
578
obj.addProperty("App::PropertyLength", "length", "Parameters", "Screw length").length = 20.0
579
obj.addProperty("App::PropertyLength", "diameterCustom", "Parameters", "Screw major diameter custom").diameterCustom = 6
580
obj.addProperty("App::PropertyLength", "pitchCustom", "Parameters", "Screw pitch custom").pitchCustom = 1.0
581
self.VerifyMissingAttrs(obj)
582
obj.addProperty("App::PropertyBool", "thread", "Parameters", "Generate real thread").thread = False
585
def VerifyMissingAttrs(self, obj):
586
self.updateProps(obj)
587
if not hasattr(obj, 'matchOuter'):
588
obj.addProperty("App::PropertyBool", "matchOuter", "Parameters", "Match outer thread diameter").matchOuter = FastenerBase.FSMatchOuter
589
# for old objects from before custom diameter and pitch were implemented
590
if not hasattr(obj, "pitchCustom"):
591
obj.addProperty("App::PropertyLength", "pitchCustom", "Parameters", "Screw pitch custom").pitchCustom = 1.0
592
obj.addProperty("App::PropertyLength", "diameterCustom", "Parameters", "Screw major diameter custom").diameterCustom = 6
593
dia_tmp = obj.diameter
594
self.type = "ScrewDie"
595
obj.diameter = screwMaker.GetAllDiams(self.type) + ["Custom"]
596
obj.diameter = dia_tmp
598
def execute(self, fp):
599
'''"Print a short message when doing a recomputation, this method is mandatory" '''
602
baseobj = fp.baseObject[0]
603
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
608
self.VerifyMissingAttrs(fp)
609
diameterchange = False
610
if not (hasattr(self, 'diameter')) or self.diameter != fp.diameter:
611
diameterchange = True
613
matchouterchange = not (hasattr(self, 'matchOuter')) or self.matchOuter != fp.matchOuter
615
if fp.diameter == 'Auto' or matchouterchange:
616
d = screwMaker.AutoDiameter(self.type, shape, baseobj, fp.matchOuter)
618
diameterchange = True
620
elif fp.diameter == 'Custom':
622
d_custom = fp.diameterCustom.Value
632
if fp.diameter == 'Custom':
633
p = fp.pitchCustom.Value
637
screwMaker.updateFastenerParameters()
639
threadType = 'simple'
640
if hasattr(fp, 'thread') and fp.thread:
642
# since we are bypassing the createScrew() method, we must set
643
# the rThread parameter manually
644
screwMaker.rThread = (threadType == 'real')
645
s = screwMaker.makeScrewDie(self.type, d, l, p, d_custom)
646
self.diameter = fp.diameter
648
self.matchOuter = fp.matchOuter
649
diastr = fp.diameter if fp.diameter != 'Custom' else str(fp.diameterCustom)
650
fp.Label = diastr + 'x' + str(l) + '-' + self.itemText
651
self.realThread = fp.thread
654
if shape is not None:
655
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
550
def __init__(self, obj, attachTo, typeStr):
551
'''"Add screw die" '''
552
FSBaseObject.__init__(self, obj, attachTo)
553
self.itemText = "ScrewDie"
555
diameters = screwMaker.GetAllDiams(self.type) + ["Custom"]
556
diameters.insert(0, 'Auto')
557
#self.Proxy = obj.Name
559
obj.addProperty("App::PropertyEnumeration","diameter","Parameters","Screw diameter standard").diameter = diameters
560
obj.addProperty("App::PropertyLength","length","Parameters","Screw length").length = 20.0
561
obj.addProperty("App::PropertyLength","diameterCustom","Parameters","Screw major diameter custom").diameterCustom = 6
562
obj.addProperty("App::PropertyLength","pitchCustom","Parameters","Screw pitch custom").pitchCustom = 1.0
563
self.VerifyMissingAttrs(obj)
564
obj.addProperty("App::PropertyBool", "thread", "Parameters", "Generate real thread").thread = False
567
def VerifyMissingAttrs(self, obj):
568
self.updateProps(obj)
569
if not (hasattr(obj, 'matchOuter')):
570
obj.addProperty("App::PropertyBool", "matchOuter", "Parameters", "Match outer thread diameter").matchOuter = FastenerBase.FSMatchOuter
571
# for old objects from before custom diameter and pitch were implemented
572
if not hasattr(obj,"pitchCustom"):
573
obj.addProperty("App::PropertyLength","pitchCustom","Parameters","Screw pitch custom").pitchCustom = 1.0
574
obj.addProperty("App::PropertyLength","diameterCustom","Parameters","Screw major diameter custom").diameterCustom = 6
575
dia_tmp = obj.diameter
576
self.type = "ScrewDie"
577
obj.diameter = screwMaker.GetAllDiams(self.type) + ["Custom"]
578
obj.diameter = dia_tmp
580
def execute(self, fp):
581
'''"Print a short message when doing a recomputation, this method is mandatory" '''
584
baseobj = fp.baseObject[0]
585
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
590
self.VerifyMissingAttrs(fp)
591
diameterchange = False
592
if not (hasattr(self, 'diameter')) or self.diameter != fp.diameter:
593
diameterchange = True
595
matchouterchange = not (hasattr(self, 'matchOuter')) or self.matchOuter != fp.matchOuter
597
if fp.diameter == 'Auto' or matchouterchange:
598
d = screwMaker.AutoDiameter(self.type, shape, baseobj, fp.matchOuter)
600
diameterchange = True
602
elif fp.diameter == 'Custom':
604
d_custom = fp.diameterCustom.Value
614
if fp.diameter == 'Custom':
615
p = fp.pitchCustom.Value
619
screwMaker.updateFastenerParameters()
621
threadType = 'simple'
622
if hasattr(fp,'thread') and fp.thread:
624
# since we are bypassing the createScrew() method, we must set
625
# the rThread parameter manually
626
screwMaker.rThread = (threadType == 'real')
627
s = screwMaker.makeScrewDie(self.type,d,l,p,d_custom)
628
self.diameter = fp.diameter
630
self.matchOuter = fp.matchOuter
631
diastr = fp.diameter if fp.diameter != 'Custom' else str(fp.diameterCustom)
632
fp.Label = diastr + 'x' + str(l) + '-' + self.itemText
633
self.realThread = fp.thread
636
if shape is not None:
637
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
658
639
class FSScrewDieCommand:
659
"""Add Screw Die command"""
661
def GetResources(self):
662
icon = os.path.join(iconPath, 'ScrewDie.svg')
664
'Pixmap': icon, # the name of a svg file available in the resources
665
'MenuText': "Add object to cut external threads",
666
'ToolTip': "Add arbitrary length threaded tube for cutting external threads"
670
for selObj in FastenerBase.FSGetAttachableSelections():
671
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ScrewDie")
672
FSScrewDieObject(a, selObj, "ScrewDie")
673
a.Label = a.Proxy.itemText
674
FSViewProviderTree(a.ViewObject)
675
FreeCAD.ActiveDocument.recompute()
679
return Gui.ActiveDocument is not None
682
Gui.addCommand("FSScrewDie", FSScrewDieCommand())
640
"""Add Screw Die command"""
642
def GetResources(self):
643
icon = os.path.join( iconPath , 'ScrewDie.svg')
644
return {'Pixmap' : icon , # the name of a svg file available in the resources
645
'MenuText': "Add object to cut external threads" ,
646
'ToolTip' : "Add arbitrary length threaded tube for cutting external threads"}
649
for selObj in FastenerBase.FSGetAttachableSelections():
650
a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ScrewDie")
651
FSScrewDieObject(a, selObj, "ScrewDie")
652
a.Label = a.Proxy.itemText
653
FSViewProviderTree(a.ViewObject)
654
FreeCAD.ActiveDocument.recompute()
658
return Gui.ActiveDocument is not None
660
Gui.addCommand("FSScrewDie",FSScrewDieCommand())
683
661
FastenerBase.FSCommands.append("FSScrewDie", "screws", "misc")
686
666
class FSScrewDieCommandInch:
687
"""Add Screw Die command"""
689
def GetResources(self):
690
icon = os.path.join(iconPath, 'ScrewDieInch.svg')
692
'Pixmap': icon, # the name of a svg file available in the resources
693
'MenuText': 'Add object to cut external non-metric threads',
694
'ToolTip': 'Add arbitrary length threaded tube for cutting inch standard external threads'
698
for selObj in FastenerBase.FSGetAttachableSelections():
699
a = FreeCAD.ActiveDocument.addObject('Part::FeaturePython', 'ScrewDie')
700
FSScrewDieObject(a, selObj, 'ScrewDieInch')
701
a.Label = a.Proxy.itemText
702
FSViewProviderTree(a.ViewObject)
703
FreeCAD.ActiveDocument.recompute()
707
return Gui.ActiveDocument is not None
710
Gui.addCommand('FSScrewDieInch', FSScrewDieCommandInch())
711
FastenerBase.FSCommands.append('FSScrewDieInch', 'screws', 'misc')
667
"""Add Screw Die command"""
669
def GetResources(self):
670
icon = os.path.join( iconPath , 'ScrewDieInch.svg')
671
return {'Pixmap' : icon , # the name of a svg file available in the resources
672
'MenuText': "Add object to cut external non-metric threads" ,
673
'ToolTip' : "Add arbitrary length threaded tube for cutting inch standard external threads"}
676
for selObj in FastenerBase.FSGetAttachableSelections():
677
a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ScrewDie")
678
FSScrewDieObject(a, selObj, "ScrewDieInch")
679
a.Label = a.Proxy.itemText
680
FSViewProviderTree(a.ViewObject)
681
FreeCAD.ActiveDocument.recompute()
685
return Gui.ActiveDocument is not None
687
Gui.addCommand("FSScrewDieInch",FSScrewDieCommandInch())
688
FastenerBase.FSCommands.append("FSScrewDieInch", "screws", "misc")
714
693
class FSThreadedRodObject(FSBaseObject):
715
def __init__(self, obj, attachTo, typeStr):
716
'''"Add threaded rod" '''
717
FSBaseObject.__init__(self, obj, attachTo)
718
self.itemText = "ThreadedRod"
720
diameters = screwMaker.GetAllDiams(self.type) + ["Custom"]
721
diameters.insert(0, 'Auto')
722
# self.Proxy = obj.Name
724
obj.addProperty("App::PropertyEnumeration", "diameter", "Parameters", "Screw diameter standard").diameter = diameters
725
obj.addProperty("App::PropertyLength", "length", "Parameters", "Screw length").length = 20.0
726
obj.addProperty("App::PropertyLength", "diameterCustom", "Parameters", "Screw major diameter custom").diameterCustom = 6
727
obj.addProperty("App::PropertyLength", "pitchCustom", "Parameters", "Screw pitch custom").pitchCustom = 1.0
728
self.VerifyMissingAttrs(obj)
729
obj.addProperty("App::PropertyBool", "thread", "Parameters", "Generate real thread").thread = False
732
def VerifyMissingAttrs(self, obj):
733
self.updateProps(obj)
734
if not (hasattr(obj, 'matchOuter')):
735
obj.addProperty("App::PropertyBool", "matchOuter", "Parameters", "Match outer thread diameter").matchOuter = FastenerBase.FSMatchOuter
736
# for old objects from before custom diameter and pitch were implemented
737
if not hasattr(obj, "pitchCustom"):
738
obj.addProperty("App::PropertyLength", "pitchCustom", "Parameters", "Screw pitch custom").pitchCustom = 1.0
739
obj.addProperty("App::PropertyLength", "diameterCustom", "Parameters", "Screw major diameter custom").diameterCustom = 6
740
dia_tmp = obj.diameter
741
self.type = "ThreadedRod"
742
obj.diameter = screwMaker.GetAllDiams(self.type) + ["Custom"]
743
obj.diameter = dia_tmp
745
def execute(self, fp):
746
'''"Print a short message when doing a recomputation, this method is mandatory" '''
749
baseobj = fp.baseObject[0]
750
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
755
self.VerifyMissingAttrs(fp)
756
diameterchange = False
757
if not (hasattr(self, 'diameter')) or self.diameter != fp.diameter:
758
diameterchange = True
760
matchouterchange = not (hasattr(self, 'matchOuter')) or self.matchOuter != fp.matchOuter
762
if fp.diameter == 'Auto' or matchouterchange:
763
d = screwMaker.AutoDiameter(self.type, shape, baseobj, fp.matchOuter)
765
diameterchange = True
767
elif fp.diameter == 'Custom':
769
d_custom = fp.diameterCustom.Value
779
if fp.diameter == 'Custom':
780
p = fp.pitchCustom.Value
784
screwMaker.updateFastenerParameters()
786
threadType = 'simple'
787
if hasattr(fp, 'thread') and fp.thread:
789
# since we are bypassing the createScrew() method, we must set
790
# the rThread parameter manually
791
screwMaker.rThread = (threadType == 'real')
792
s = screwMaker.makeThreadedRod(self.type, d, l, p, d_custom)
794
self.diameter = fp.diameter
796
self.matchOuter = fp.matchOuter
797
diastr = fp.diameter if fp.diameter != 'Custom' else str(fp.diameterCustom)
798
fp.Label = diastr + 'x' + str(l) + '-' + self.itemText
799
self.realThread = fp.thread
802
if shape is not None:
803
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
694
def __init__(self, obj, attachTo, typeStr):
695
'''"Add threaded rod" '''
696
FSBaseObject.__init__(self, obj, attachTo)
697
self.itemText = "ThreadedRod"
699
diameters = screwMaker.GetAllDiams(self.type) + ["Custom"]
700
diameters.insert(0, 'Auto')
701
#self.Proxy = obj.Name
703
obj.addProperty("App::PropertyEnumeration","diameter","Parameters","Screw diameter standard").diameter = diameters
704
obj.addProperty("App::PropertyLength","length","Parameters","Screw length").length = 20.0
705
obj.addProperty("App::PropertyLength","diameterCustom","Parameters","Screw major diameter custom").diameterCustom = 6
706
obj.addProperty("App::PropertyLength","pitchCustom","Parameters","Screw pitch custom").pitchCustom = 1.0
707
self.VerifyMissingAttrs(obj)
708
obj.addProperty("App::PropertyBool", "thread", "Parameters", "Generate real thread").thread = False
711
def VerifyMissingAttrs(self, obj):
712
self.updateProps(obj)
713
if not (hasattr(obj, 'matchOuter')):
714
obj.addProperty("App::PropertyBool", "matchOuter", "Parameters", "Match outer thread diameter").matchOuter = FastenerBase.FSMatchOuter
715
# for old objects from before custom diameter and pitch were implemented
716
if not hasattr(obj,"pitchCustom"):
717
obj.addProperty("App::PropertyLength","pitchCustom","Parameters","Screw pitch custom").pitchCustom = 1.0
718
obj.addProperty("App::PropertyLength","diameterCustom","Parameters","Screw major diameter custom").diameterCustom = 6
719
dia_tmp = obj.diameter
720
self.type = "ThreadedRod"
721
obj.diameter = screwMaker.GetAllDiams(self.type) + ["Custom"]
722
obj.diameter = dia_tmp
724
def execute(self, fp):
725
'''"Print a short message when doing a recomputation, this method is mandatory" '''
728
baseobj = fp.baseObject[0]
729
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
734
self.VerifyMissingAttrs(fp)
735
diameterchange = False
736
if not (hasattr(self, 'diameter')) or self.diameter != fp.diameter:
737
diameterchange = True
739
matchouterchange = not (hasattr(self, 'matchOuter')) or self.matchOuter != fp.matchOuter
741
if fp.diameter == 'Auto' or matchouterchange:
742
d = screwMaker.AutoDiameter(self.type, shape, baseobj, fp.matchOuter)
744
diameterchange = True
746
elif fp.diameter == 'Custom':
748
d_custom = fp.diameterCustom.Value
758
if fp.diameter == 'Custom':
759
p = fp.pitchCustom.Value
763
screwMaker.updateFastenerParameters()
765
threadType = 'simple'
766
if hasattr(fp,'thread') and fp.thread:
768
# since we are bypassing the createScrew() method, we must set
769
# the rThread parameter manually
770
screwMaker.rThread = (threadType == 'real')
771
s = screwMaker.makeThreadedRod(self.type,d,l,p,d_custom)
773
self.diameter = fp.diameter
775
self.matchOuter = fp.matchOuter
776
diastr = fp.diameter if fp.diameter != 'Custom' else str(fp.diameterCustom)
777
fp.Label = diastr + 'x' + str(l) + '-' + self.itemText
778
self.realThread = fp.thread
781
if shape is not None:
782
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
806
784
class FSThreadedRodCommand:
807
"""Add Threaded Rod command"""
809
def GetResources(self):
810
icon = os.path.join(iconPath, 'ThreadedRod.svg')
812
'Pixmap': icon, # the name of a svg file available in the resources
813
'MenuText': "Add DIN 975 threaded rod",
814
'ToolTip': "Add arbitrary length threaded rod object"
818
for selObj in FastenerBase.FSGetAttachableSelections():
819
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ThreadedRod")
820
FSThreadedRodObject(a, selObj, "ThreadedRod")
821
a.Label = a.Proxy.itemText
822
FSViewProviderTree(a.ViewObject)
823
FreeCAD.ActiveDocument.recompute()
827
return Gui.ActiveDocument is not None
830
Gui.addCommand("FSThreadedRod", FSThreadedRodCommand())
785
"""Add Threaded Rod command"""
787
def GetResources(self):
788
icon = os.path.join( iconPath , 'ThreadedRod.svg')
789
return {'Pixmap' : icon , # the name of a svg file available in the resources
790
'MenuText': "Add DIN 975 threaded rod" ,
791
'ToolTip' : "Add arbitrary length threaded rod object"}
794
for selObj in FastenerBase.FSGetAttachableSelections():
795
a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ThreadedRod")
796
FSThreadedRodObject(a, selObj, "ThreadedRod")
797
a.Label = a.Proxy.itemText
798
FSViewProviderTree(a.ViewObject)
799
FreeCAD.ActiveDocument.recompute()
803
return Gui.ActiveDocument is not None
805
Gui.addCommand("FSThreadedRod",FSThreadedRodCommand())
831
806
FastenerBase.FSCommands.append("FSThreadedRod", "screws", "misc")
834
809
class FSThreadedRodCommandInch:
835
"""Add Threaded Rod command"""
837
def GetResources(self):
838
icon = os.path.join(iconPath, 'ThreadedRodInch.svg')
840
'Pixmap': icon, # the name of a svg file available in the resources
841
'MenuText': "Add UNC threaded rod",
842
'ToolTip': "Add arbitrary length threaded rod object, inch standard coarse threads"
846
for selObj in FastenerBase.FSGetAttachableSelections():
847
a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", "ThreadedRod")
848
FSThreadedRodObject(a, selObj, "ThreadedRodInch")
849
a.Label = a.Proxy.itemText
850
FSViewProviderTree(a.ViewObject)
851
FreeCAD.ActiveDocument.recompute()
855
return Gui.ActiveDocument is not None
858
Gui.addCommand("FSThreadedRodInch", FSThreadedRodCommandInch())
810
"""Add Threaded Rod command"""
812
def GetResources(self):
813
icon = os.path.join( iconPath , 'ThreadedRodInch.svg')
814
return {'Pixmap' : icon , # the name of a svg file available in the resources
815
'MenuText': "Add UNC threaded rod" ,
816
'ToolTip' : "Add arbitrary length threaded rod object, inch standard coarse threads"}
819
for selObj in FastenerBase.FSGetAttachableSelections():
820
a=FreeCAD.ActiveDocument.addObject("Part::FeaturePython","ThreadedRod")
821
FSThreadedRodObject(a, selObj, "ThreadedRodInch")
822
a.Label = a.Proxy.itemText
823
FSViewProviderTree(a.ViewObject)
824
FreeCAD.ActiveDocument.recompute()
828
return Gui.ActiveDocument is not None
830
Gui.addCommand("FSThreadedRodInch",FSThreadedRodCommandInch())
859
831
FastenerBase.FSCommands.append("FSThreadedRodInch", "screws", "misc")
861
834
## add fastener types
862
835
FastenerBase.FSAddFastenerType("Screw")
863
836
FastenerBase.FSAddFastenerType("Washer", False)