forked from shaise/FreeCAD_FastenersWB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPEMInserts.py
625 lines (539 loc) · 19.2 KB
/
PEMInserts.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
# -*- coding: utf-8 -*-
###################################################################################
#
# PEMInserts.py
#
# Copyright 2015 Shai Seger <shaise at gmail dot com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
###################################################################################
from FreeCAD import Gui
from FreeCAD import Base
import FreeCAD, FreeCADGui, Part, os, math
__dir__ = os.path.dirname(__file__)
iconPath = os.path.join( __dir__, 'Icons' )
import FastenerBase
from FastenerBase import FSBaseObject
import ScrewMaker
screwMaker = ScrewMaker.Instance()
tan30 = math.tan(math.radians(30))
cos30 = math.cos(math.radians(30))
###################################################################################
# PEM Self Clinching nuts types: S/SS/CLS/CLSS/SP
CLSSizeCodes = ['00', '0', '1', '2']
CLSDiamCodes = ['Auto', 'M2', 'M2.5', 'M3', 'M3.5', 'M4', 'M5', 'M6', 'M8', 'M10', 'M12']
CLSPEMTable = {
# (00, 0, 1, 2 ) C, E, T, d
'M2': ((0, 0.77, 0.97, 1.38), 4.2, 6.35, 1.5, 1.6),
'M2.5':((0, 0.77, 0.97, 1.38), 4.2, 6.35, 1.5, 2.05),
'M3': ((0, 0.77, 0.97, 1.38), 4.2, 6.35, 1.5, 2.5),
'M3.5':((0, 0.77, 0.97, 1.38), 4.73, 7.11, 1.5, 2.9),
'M4': ((0, 0.77, 0.97, 1.38), 5.38, 7.87, 2.0, 3.3),
'M5': ((0, 0.77, 0.97, 1.38), 6.33, 8.64, 2.0, 4.2),
'M6': ((0.89, 1.15, 1.38, 2.21), 8.73, 11.18, 4.08, 5.0),
'M8': ((0, 0, 1.38, 2.21), 10.47, 12.7, 5.47, 6.8),
'M10': ((0, 0, 2.21, 3.05), 13.97, 17.35, 7.48, 8.5),
'M12': ((0, 0, 3.05, 0), 16.95, 20.57, 8.5, 10.2)
}
def clMakeWire(do, di, a, c, e, t):
do = do / 2
di = di / 2
ch1 = do - di
ch2 = ch1 / 2
if ch2 < 0.2:
ch2 = 0.2
c = c / 2
e = e / 2
c2 = (c + e) / 2
sl = a / 20
a2 = a / 2
fm = FastenerBase.FSFaceMaker()
fm.AddPoint(di, -a + ch1)
fm.AddPoint(do, -a)
fm.AddPoint(c, -a)
fm.AddPoint(c, -a * 0.75,)
fm.AddPoint(c - sl, -a2)
fm.AddPoint(c2, -a2)
fm.AddPoint(c2, 0)
fm.AddPoint(e, 0)
fm.AddPoint(e, t - ch2)
fm.AddPoint(e - ch2, t)
fm.AddPoint(do, t)
fm.AddPoint(di, t - ch1)
return fm.GetFace()
def clMakePressNut(diam, code):
if not (code in CLSSizeCodes):
return None
i = CLSSizeCodes.index(code)
if not(diam in CLSPEMTable):
return None
(key, shape) = FastenerBase.FSGetKey('PressNut', diam, code)
if shape != None:
return shape
ls, c, e, t, di = CLSPEMTable[diam]
a = ls[i]
if a == 0:
return None
do = FastenerBase.MToFloat(diam)
f = clMakeWire(do, di, a, c, e, t)
p = f.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
FastenerBase.FSCache[key] = p
return p
def clFindClosest(diam, code):
''' Find closest standard screw to given parameters '''
if not (code in CLSSizeCodes):
return '1'
i = CLSSizeCodes.index(code)
lens = CLSPEMTable[diam][0]
if lens[i] != 0:
return code
min = 999
max = len(CLSSizeCodes)
j = 0
for c in lens:
if c != 0 and min == 999:
min = j
if c == 0 and min != 999:
max = j - 1
break
j = j + 1
if i < min:
return CLSSizeCodes[min]
# i is probably > max
return CLSSizeCodes[max]
# h = clMakePressNut('M5','1')
class FSPressNutObject(FSBaseObject):
def __init__(self, obj, attachTo):
'''"Add Press nut (self clinching) type fastener" '''
FSBaseObject.__init__(self, obj, attachTo)
self.itemText = "PressNut"
#self.Proxy = obj.Name
obj.addProperty("App::PropertyEnumeration","tcode","Parameters","Thickness code").tcode = CLSSizeCodes
obj.addProperty("App::PropertyEnumeration","diameter","Parameters","Press nut thread diameter").diameter = CLSDiamCodes
obj.invert = FastenerBase.FSLastInvert
obj.tcode = '1'
obj.Proxy = self
def execute(self, fp):
'''"Print a short message when doing a recomputation, this method is mandatory" '''
try:
baseobj = fp.baseObject[0]
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
except:
baseobj = None
shape = None
if (not (hasattr(self,'diameter')) or self.diameter != fp.diameter or self.tcode != fp.tcode):
if fp.diameter == 'Auto':
d = FastenerBase.FSAutoDiameterM(shape, CLSPEMTable, 1)
else:
d = fp.diameter
l = clFindClosest(d, fp.tcode)
if l != fp.tcode:
fp.tcode = l
if d != fp.diameter:
fp.diameter = d
s = clMakePressNut(d, l)
self.diameter = fp.diameter
self.tcode = fp.tcode
FastenerBase.FSLastInvert = fp.invert
fp.Label = fp.diameter + '-PressNut'
fp.Shape = s
else:
FreeCAD.Console.PrintLog("Using cached object\n")
if shape != None:
#feature = FreeCAD.ActiveDocument.getObject(self.Proxy)
#fp.Placement = FreeCAD.Placement() # reset placement
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
FastenerBase.FSClassIcons[FSPressNutObject] = 'PEMPressNut.svg'
class FSPressnutCommand:
"""Add Preass-nut command"""
def GetResources(self):
icon = os.path.join( iconPath , 'PEMPressNut.svg')
return {'Pixmap' : icon , # the name of a svg file available in the resources
'MenuText': "Add Press-Nut" ,
'ToolTip' : "Add PEM Self Clinching Metric Nut"}
def Activated(self):
FastenerBase.FSGenerateObjects(FSPressNutObject, "PressNut")
return
def IsActive(self):
return Gui.ActiveDocument != None
Gui.addCommand("FSPressNut", FSPressnutCommand())
FastenerBase.FSCommands.append("FSPressNut", "screws", "PEM Inserts")
###################################################################################
# PEM Self Clinching standoffs types: SO/SOS/SOA/SO4
SOLengths = {'3':0, '4':0, '6':0, '8':0, '10':4, '12':4, '14':4, '16':8, '18':8, '20':8, '22':11, '25':11}
#BSLengths = {'6':3.2, '8':4, '10':4, '12':5, '14':6.5, '16':6.5, '18':9.5, '20':9.5, '22':9.5, '25':9.5}
SODiameters = ['Auto', 'M3', '3.5M3', 'M3.5', 'M4', 'M5' ]
SOPEMTable = {
# B, C, H, d, Lmin, Lmax
'M3': (3.2, 4.2, 4.8, 2.5, 3, 18),
'3.5M3':(3.2, 5.39, 6.4, 2.5, 3, 25),
'M3.5': (3.9, 5.39, 6.4, 2.9, 3, 25),
'M4': (4.8, 7.12, 7.9, 3.3, 3, 25),
'M5': (5.36, 7.12, 7.9, 4.2, 3, 25)
}
def soMakeFace(b, c, h, d, l):
h10 = h / 10.0
c12 = c / 12.5
c20 = c / 20.0
c40 = c / 40.0
b = b / 2
c = c / 2
d = d / 2
ch1 = b - d
l1 = float(l)
l2 = l1 - SOLengths[l]
c1 = c - c40
c2 = c - c20
l3 = h10 * 2 + (c12 + c20) * 2
fm = FastenerBase.FSFaceMaker()
fm.AddPoint(b, 0)
fm.AddPoint(d, -ch1)
fm.AddPoint(d, -(l2 - ch1))
fm.AddPoint(b, -l2)
if (l1 - l2) > 0.01:
fm.AddPoint(b, -l1)
fm.AddPoint(c, -l1)
if (l3 < l1):
fm.AddPoint(c, -l3)
fm.AddPoint(c1, -l3)
fm.AddPoint(c1, -(l3 - c20))
fm.AddPoint(c, -(l3 - c20))
fm.AddPoint(c, -(h10 * 2 + c12 + c20))
fm.AddPoint(c1, -(h10 * 2 + c12 + c20))
fm.AddPoint(c1, -(h10 * 2 + c12))
fm.AddPoint(c, -(h10 * 2 + c12))
fm.AddPoint(c, -h10 * 2)
fm.AddPoint(c2, -h10 * 2)
fm.AddPoint(c2, -h10)
fm.AddPoint(h * 0.6, -h10)
fm.AddPoint(h * 0.6, 0)
return fm.GetFace()
def bsMakeFace(b, c, h, d, l):
h10 = h / 10.0
h102 = h10 + h10 / 2
c12 = c / 12.5
c20 = c / 20.0
c40 = c / 40.0
b = b / 2
c = c / 2
d = d / 2
ch1 = b - d
ch2 = d * tan30
l1 = float(l)
#l2 = l1 - SOLengths[l]
c1 = c - c40
c2 = c - c20
l3 = h10 * 2 + (c12 + c20) * 2
fm = FastenerBase.FSFaceMaker()
fm.AddPoint(0, 0)
fm.AddPoint(0, -h102)
fm.AddPoint(d, -(h102 + ch2))
fm.AddPoint(d, -(l1 - ch1))
fm.AddPoint(b, -l1)
fm.AddPoint(c, -l1)
if (l3 < l1):
fm.AddPoint(c, -l3)
fm.AddPoint(c1, -l3)
fm.AddPoint(c1, -(l3 - c20))
fm.AddPoint(c, -(l3 - c20))
fm.AddPoint(c, -(h10 * 2 + c12 + c20))
fm.AddPoint(c1, -(h10 * 2 + c12 + c20))
fm.AddPoint(c1, -(h10 * 2 + c12))
fm.AddPoint(c, -(h10 * 2 + c12))
fm.AddPoint(c, -h10 * 2)
fm.AddPoint(c2, -h10 * 2)
fm.AddPoint(c2, -h10)
fm.AddPoint(h * 0.6, -h10)
fm.AddPoint(h * 0.6, 0)
return fm.GetFace()
def soMakeStandOff(diam, len, blind):
if not(len in SOLengths):
return None
if not(diam in SOPEMTable):
return None
(key, shape) = FastenerBase.FSGetKey('StandOff', diam, len, blind)
if shape != None:
return shape
l = int(len)
b, c, h, d, lmin, lmax = SOPEMTable[diam]
if blind:
lmin, lmax = (6, 25)
if l < lmin or l > lmax:
return None
if blind:
f = bsMakeFace(b, c, h, d, len)
else:
f = soMakeFace(b, c, h, d, len)
p = f.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
htool = screwMaker.makeHextool(h, 3, h * 2)
htool.translate(Base.Vector(0.0,0.0,-2.0))
shape = p.cut(htool)
FastenerBase.FSCache[key] = shape
return shape
def soFindClosest(diam, len):
''' Find closest standard screw to given parameters '''
if not(diam in SOPEMTable):
return None
if (float(len) > SOPEMTable[diam][5]):
return str(SOPEMTable[diam][5])
if (float(len) < SOPEMTable[diam][4]):
return str(SOPEMTable[diam][4])
return len
def soGetAllLengths(diam, blind):
if blind:
lmin, lmax = (6, 25)
else:
b, c, h, d, lmin, lmax = SOPEMTable[diam]
list = []
for len in SOLengths:
l = float(len)
if l >= lmin and l <= lmax:
list.append(len)
list.sort(cmp = FastenerBase.NumCompare)
return list
# h = clMakePressNut('M5','1')
class FSStandOffObject(FSBaseObject):
def __init__(self, obj, attachTo):
'''"Add StandOff (self clinching) type fastener" '''
FSBaseObject.__init__(self, obj, attachTo)
self.itemText = "StandOff"
#self.Proxy = obj.Name
obj.addProperty("App::PropertyEnumeration","diameter","Parameters","Standoff thread diameter").diameter = SODiameters
obj.addProperty("App::PropertyBool", "blind", "Parameters", "Blind Standoff type").blind = False
obj.addProperty("App::PropertyEnumeration","length","Parameters","Standoff length").length = soGetAllLengths(SODiameters[1], False)
obj.invert = FastenerBase.FSLastInvert
obj.Proxy = self
def execute(self, fp):
'''"Print a short message when doing a recomputation, this method is mandatory" '''
try:
baseobj = fp.baseObject[0]
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
except:
baseobj = None
shape = None
if (not (hasattr(self,'diameter')) or self.diameter != fp.diameter or self.length != fp.length or self.blind != fp.blind):
diameterchange = False
if not (hasattr(self,'diameter')) or self.diameter != fp.diameter:
diameterchange = True
if fp.diameter == 'Auto':
d = FastenerBase.FSAutoDiameterM(shape, SOPEMTable, 1)
diameterchange = True
else:
d = fp.diameter
blindchange = False
if not(hasattr(self,'blind')) or self.blind != fp.blind:
blindchange = True;
l = soFindClosest(d, fp.length)
if d != fp.diameter:
diameterchange = True
fp.diameter = d
if l != fp.length or diameterchange or blindchange:
if diameterchange or blindchange:
fp.length = soGetAllLengths(fp.diameter, fp.blind)
fp.length = l
s = soMakeStandOff(d, l, fp.blind)
self.diameter = fp.diameter
self.length = fp.length
self.blind = fp.blind
FastenerBase.FSLastInvert = fp.invert
fp.Label = fp.diameter + 'x' + fp.length + '-Standoff'
fp.Shape = s
else:
FreeCAD.Console.PrintLog("Using cached object\n")
if shape != None:
#feature = FreeCAD.ActiveDocument.getObject(self.Proxy)
#fp.Placement = FreeCAD.Placement() # reset placement
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
FastenerBase.FSClassIcons[FSStandOffObject] = 'PEMTHStandoff.svg'
class FSStandOffCommand:
"""Add Standoff command"""
def GetResources(self):
icon = os.path.join( iconPath , 'PEMTHStandoff.svg')
return {'Pixmap' : icon , # the name of a svg file available in the resources
'MenuText': "Add Standoff" ,
'ToolTip' : "Add PEM Self Clinching Metric Standoff"}
def Activated(self):
FastenerBase.FSGenerateObjects(FSStandOffObject, "Standoff")
return
def IsActive(self):
return Gui.ActiveDocument != None
Gui.addCommand("FSStandOff", FSStandOffCommand())
FastenerBase.FSCommands.append("FSStandOff", "screws", "PEM Inserts")
###################################################################################
# PEM Self Clinching studs types: FH/FHS/FHA
FHLengths = ['6', '8', '10', '12', '15', '18', '20', '25', '30', '35']
#BSLengths = {'6':3.2, '8':4, '10':4, '12':5, '14':6.5, '16':6.5, '18':9.5, '20':9.5, '22':9.5, '25':9.5}
FHDiameters = ['Auto', 'M2.5', 'M3', 'M3.5', 'M4', 'M5', 'M6', 'M8' ]
FHPEMTable = {
# H, S, d, Lmin, Lmax
'M2.5': (4.1, 1.95, 2.05, 6, 18),
'M3': (4.6, 2.1, 2.5, 6, 25),
'M3.5': (5.3, 2.25, 2.9, 6, 30),
'M4': (5.9, 2.4, 3.3, 6, 35),
'M5': (6.5, 2.7, 4.2, 8, 35),
'M6': (8.2, 3.0, 5.0, 10, 35),
'M8': (9.6, 3.7, 6.75, 12, 35)
}
def fhMakeFace(m, h, d, l):
h10 = h / 10.0
h20 = h / 20.0
m25 = m * 0.025
hs = 0.8 + 0.125 * m
he = 0.8 + 0.2 * m
h = h / 2.0
m = m / 2.0
d = d / 2.0
h85 = h * 0.85
m9 = m * 0.9
mr = m9 - m25 * (1.0 - cos30)
ch1 = m - d
fm = FastenerBase.FSFaceMaker()
fm.AddPoint(0, 0)
fm.AddPoint(h - h20, 0)
fm.AddArc(h, - h20, h - h20, -h10)
fm.AddPoint(h - h20, -(h10 + h20))
fm.AddPoint(m , -(h10 + h20))
fm.AddPoint(m , -hs)
fm.AddPoint(m9, -(hs + m25))
fm.AddArc(mr, -(hs + m25 * 1.5), m9, -(hs + m25 * 2))
fm.AddPoint(m, -he)
fm.AddPoint(m, -(l - ch1))
fm.AddPoint(m - ch1, -l)
fm.AddPoint(0, -l)
return fm.GetFace()
def fhMakeStud(diam, len):
if not(len in FHLengths):
return None
if not(diam in FHPEMTable):
return None
(key, shape) = FastenerBase.FSGetKey('Stud', diam, len)
if shape != None:
return shape
l = int(len)
m = FastenerBase.MToFloat(diam)
h, s, d, lmin, lmax = FHPEMTable[diam]
if l < lmin or l > lmax:
return None
f = fhMakeFace(m, h, d, l)
p = f.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
FastenerBase.FSCache[key] = p
return p
def fhFindClosest(diam, len):
''' Find closest standard screw to given parameters '''
if not(diam in FHPEMTable):
return None
if (float(len) > FHPEMTable[diam][4]):
return str(FHPEMTable[diam][4])
if (float(len) < FHPEMTable[diam][3]):
return str(FHPEMTable[diam][3])
return len
def fhGetAllLengths(diam):
h, s, d, lmin, lmax = FHPEMTable[diam]
list = []
for len in FHLengths:
l = float(len)
if l >= lmin and l <= lmax:
list.append(len)
list.sort(cmp = FastenerBase.NumCompare)
return list
class FSStudObject(FSBaseObject):
def __init__(self, obj, attachTo):
'''"Add Stud (self clinching) type fastener" '''
FSBaseObject.__init__(self, obj, attachTo)
self.itemText = "Stud"
#self.Proxy = obj.Name
obj.addProperty("App::PropertyEnumeration","diameter","Parameters","Standoff thread diameter").diameter = FHDiameters
obj.addProperty("App::PropertyEnumeration","length","Parameters","Standoff length").length = fhGetAllLengths(FHDiameters[1])
obj.invert = FastenerBase.FSLastInvert
obj.Proxy = self
def execute(self, fp):
'''"Print a short message when doing a recomputation, this method is mandatory" '''
try:
baseobj = fp.baseObject[0]
shape = baseobj.Shape.getElement(fp.baseObject[1][0])
except:
baseobj = None
shape = None
if (not (hasattr(self,'diameter')) or self.diameter != fp.diameter or self.length != fp.length):
diameterchange = False
if not (hasattr(self,'diameter')) or self.diameter != fp.diameter:
diameterchange = True
if fp.diameter == 'Auto':
d = FastenerBase.FSAutoDiameterM(shape, FHPEMTable, -1)
diameterchange = True
else:
d = fp.diameter
l = fhFindClosest(d, fp.length)
if d != fp.diameter:
diameterchange = True
fp.diameter = d
if l != fp.length or diameterchange:
if diameterchange:
fp.length = fhGetAllLengths(fp.diameter)
fp.length = l
s = fhMakeStud(d, l)
self.diameter = fp.diameter
self.length = fp.length
FastenerBase.FSLastInvert = fp.invert
fp.Label = fp.diameter + 'x' + fp.length + '-Stud'
fp.Shape = s
else:
FreeCAD.Console.PrintLog("Using cached object\n")
if shape != None:
#feature = FreeCAD.ActiveDocument.getObject(self.Proxy)
#fp.Placement = FreeCAD.Placement() # reset placement
FastenerBase.FSMoveToObject(fp, shape, fp.invert, fp.offset.Value)
FastenerBase.FSClassIcons[FSStudObject] = 'PEMStud.svg'
class FSStudCommand:
"""Add Standoff command"""
def GetResources(self):
icon = os.path.join( iconPath , 'PEMStud.svg')
return {'Pixmap' : icon , # the name of a svg file available in the resources
'MenuText': "Add Stud" ,
'ToolTip' : "Add PEM Self Clinching Metric Stud"}
def Activated(self):
FastenerBase.FSGenerateObjects(FSStudObject, "Stud")
return
def IsActive(self):
return Gui.ActiveDocument != None
Gui.addCommand("FSStud", FSStudCommand())
FastenerBase.FSCommands.append("FSStud", "screws", "PEM Inserts")
## add fastener types
FastenerBase.FSAddFastenerType("PressNut", False)
FastenerBase.FSAddItemsToType("PressNut", "PressNut")
FastenerBase.FSAddFastenerType("StandOff")
FastenerBase.FSAddItemsToType("StandOff", "StandOff")
FastenerBase.FSAddFastenerType("Stud")
FastenerBase.FSAddItemsToType("Stud", "Stud")
def FSPIGetAllDiameters(type):
if type == "PressNut":
diams = list(CLSDiamCodes)
elif type == "StandOff":
diams = list(SODiameters)
elif type == "Stud":
diams = list(FHDiameters)
diams.pop(0)
return diams
def FSPIGetAllLengths(type, diam):
#if type == "PressNut":
# return []
if type == "StandOff":
return soGetAllLengths(diam, False)
elif type == "Stud":
return fhGetAllLengths(diam)
return []