FreeCAD-macros
5413 строк · 193.2 Кб
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3"""
4Macro to generate screws with FreeCAD.
5Version 1.4 from 1st of September 2013
6Version 1.5 from 23rd of December 2013
7Corrected hex-heads above M12 not done.
8Version 1.6 from 15th of March 2014
9Added PySide support
10
11Version 1.7 from April 2014
12fixed bool type error. (int is not anymore accepted at linux)
13fixed starting point of real thread at some screw types.
14
15Version 1.8 from July 2014
16first approach for a faster real thread
17
18Version 1.9 / 2.0 July 2015
19new calculation of starting point of thread
20shell-based approach for screw generation
21added:
22ISO 14582 Hexalobular socket countersunk head screws, high head
23ISO 14584 Hexalobular socket raised countersunk head screws
24ISO 7380-2 Hexagon socket button head screws with collar
25DIN 967 Cross recessed pan head screws with collar
26ISO 4032 Hexagon nuts, Style 1
27ISO 4033 Hexagon nuts, Style 2
28ISO 4035 Hexagon thin nuts, chamfered
29EN 1661 Hexagon nuts with flange
30ISO 7094 definitions Plain washers - Extra large series
31ISO 7092 definitions Plain washers - Small series
32ISO 7093-1 Plain washer - Large series
33Screw-tap to drill inner threads in parts with user defined length
34
35ScrewMaker can now also used as a python module.
36The following shows how to generate a screw from a python script:
37import screw_maker2_0
38
39threadDef = 'M3.5'
40o = screw_maker2_0.Screw()
41t = screw_maker2_0.Screw.setThreadType(o,'real')
42# Creates a Document-Object with label describing the screw
43d = screw_maker2_0.Screw.createScrew(o, 'ISO1207', threadDef, '20', 'real')
44
45# creates a shape in memory
46t = screw_maker2_0.Screw.setThreadType(o,'real')
47s = screw_maker1_9d.Screw.makeIso7046(o, 'ISO14582', threadDef, 40.0)
48Part.show(s)
49
50Version 2.1 August 2015
51added:
52ISO 8676 Hexagon head screw with metric fine pitch thread
53
54Version 2.2 May 2018
55- Extend function "moveScrew" to check for Body and Part.
56- Add Screw to Part if Body is in Part.
57- Search for plane support face to get correct orientation
58- fix failed hex-head
59
60Version 2.3 Oct 2018
61- fix missing function equal_vertex
62
63to do: check ISO7380 usage of rs and rt, actual only rs is used
64check chamfer angle on hexogon heads and nuts
65***************************************************************************
66* Copyright (c) 2013, 2014, 2015 2018 *
67* Ulrich Brammer <ulrich1a[at]users.sourceforge.net> *
68* *
69* This file is a supplement to the FreeCAD CAx development system. *
70* *
71* This program is free software; you can redistribute it and/or modify *
72* it under the terms of the GNU Lesser General Public License (LGPL) *
73* as published by the Free Software Foundation; either version 2 of *
74* the License, or (at your option) any later version. *
75* for detail see the LICENCE text file. *
76* *
77* This software is distributed in the hope that it will be useful, *
78* but WITHOUT ANY WARRANTY; without even the implied warranty of *
79* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
80* GNU Library General Public License for more details. *
81* *
82* You should have received a copy of the GNU Library General Public *
83* License along with this macro; if not, write to the Free Software *
84* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
85* USA *
86* *
87***************************************************************************
88"""
89from __future__ import division
90
91__Name__ = 'Screw Maker'
92__Comment__ = 'Generate a screw'
93__Author__ = "Ulrich Brammer <ulrich1a@users.sourceforge.net>"
94__Version__ = '2.3.1'
95__Date__ = '2018-10-22'
96__License__ = 'LGPL2+'
97__Web__ = 'http://freecadweb.org/wiki/Macro_screw_maker1_2'
98__Wiki__ = 'http://freecadweb.org/wiki/Macro_screw_maker1_2'
99__Icon__ = ''
100__Help__ = 'Select the characteristics of the screw and click on the create button'
101__Status__ = ''
102__Requires__ = ''
103__Communication__ = ''
104__Files__ = ''
105
106import math
107
108import FreeCAD
109import FreeCADGui
110import Part
111from FreeCAD import Base
112import DraftVecUtils
113
114try:
115from PySide import QtCore, QtGui
116#FreeCAD.Console.PrintMessage("PySide is used" + "\n")
117except ImportError:
118#FreeCAD.Console.PrintMessage("PyQt4 is needed" + "\n")
119from PyQt4 import QtCore, QtGui
120
121try:
122_encoding = QtGui.QApplication.UnicodeUTF8
123def tr(context, text):
124return QtGui.QApplication.translate(context, text, None, _encoding)
125except AttributeError:
126def tr(context, text):
127return QtGui.QApplication.translate(context, text, None)
128
129DEBUG = False # set to True to show debug messages; does not work, still todo.
130
131debObject = None
132
133# Diameters included in this library/macro.
134# Some ISO-standards may include more diameters!
135# Dictionary used for user messages
136standard_diameters = {
137'ISO4017': ('M1.6', 'M64'), # ISO 4017 Hex-head-screw
138'ISO4014': ('M1.6', 'M64'), # ISO 4014 Hex-head-bolt
139'EN1662': ('M5', 'M16'), # EN 1662 Hexagon bolts with flange, small series
140'EN1665': ('M5', 'M20'), # EN 1665 Hexagon bolts with flange, heavy series
141'ISO8676': ('M8x1', 'M64x4'), # ISO 8676 Hexagon head screw with metric fine pitch thread
142'ISO4762': ('M1.6', 'M64'), # ISO 4762 Hexagon socket head cap screws
143'ISO2009': ('M1.6', 'M10'), # ISO 2009 Slotted countersunk flat head screws
144'ISO2010': ('M1.6', 'M10'), # ISO 2010 Slotted raised countersunk head screws
145'ISO1580': ('M1.6', 'M10'), # ISO 1580 Slotted pan head screws
146'ISO7045': ('M1.6', 'M10'), # ISO 7045 Pan head screws type H cross recess
147'ISO7046': ('M1.6', 'M10'),
148'ISO7047': ('M1.6', 'M10'),
149'ISO1207': ('M3', 'M10'), # ISO 1207 Slotted cheese head screws
150'ISO7048': ('M2.5', 'M8'), # ISO 7048 Cross-recessed cheese head screws with type H cross recess
151'ISO7380-1':('M3', 'M16'), # ISO 7380 Hexagon socket button head screws
152'ISO7380-2':('M3', 'M16'), # ISO 7380 Hexagon socket button head screws with collar
153'DIN967' :('M3', 'M8'), # DIN 967 Cross recessed pan head screws with collar
154'ISO10642':('M3', 'M20'), # ISO 10642 Hexagon socket countersunk head screws
155'ISO14579':('M2', 'M20'), # ISO 14579 Hexalobular socket head cap screws
156'ISO14580':('M2', 'M10'), # ISO 14580 Hexalobular socket cheese head screws
157'ISO14581':('M2', 'M10'), # ISO 14581 Hexalobular socket countersunk flat head screws (to do!!)
158'ISO14582':('M3', 'M10'), # ISO 14582 Hexalobular socket countersunk head screws, high head
159'ISO14583':('M2', 'M10'), # ISO 14583 Hexalobular socket pan head screws
160'ISO14584':('M2', 'M10'), # ISO 14584 Hexalobular socket raised countersunk head screws
161'ISO7089': ('M1.6', 'M64'), # Washer
162'ISO7090': ('M5', 'M64'), # ISO 7090 definitions Plain washers, chamfered - Normal series
163'ISO7091': ('M1.6', 'M64'), # ISO 7091 definitions Plain washer - Normal series Product Grade C
164'ISO7092': ('M1.6', 'M36'), # ISO 7092 definitions Plain washers - Small series
165'ISO7093-1': ('M3', 'M36'), # ISO 7093-1 Plain washer - Large series
166'ISO7094': ('M5', 'M36'), # ISO 7094 definitions Plain washers - Extra large series
167'ISO4032': ('M1.6', 'M64'), # ISO 4032 Hexagon nuts, Style 1
168'ISO4033': ('M5', 'M36'), # ISO 4033 Hexagon nuts, Style 2
169'ISO4035': ('M1.6', 'M64'), # ISO 4035 Hexagon thin nuts, chamfered
170'ISO4036': ('M1.6', 'M10'), # ISO 4035 Hexagon thin nuts, unchamfered, todo no function coded
171'EN1661': ('M5', 'M20')} # EN 1661 Hexagon nuts with flange
172
173# ISO 4017 Hex-head-screw
174# P, c, dw, e, k, r, s
175iso4017head={
176'M1.6': (0.35, 0.2, 2.9, 3.4, 1.1, 0.1, 3.2),
177'M2': (0.40, 0.2, 3.7, 4.4, 1.4, 0.1, 4.0),
178'M2.5': (0.45, 0.2, 4.6, 5.5, 1.7, 0.1, 5.0),
179'M3': (0.5, 0.2, 5.2, 6.1, 2.0, 0.1, 5.5),
180'(M3.5)':(0.6, 0.2, 5.2, 6.6, 2.4, 0.1, 5.5),
181'M4': (0.7, 0.2, 6.6, 7.7, 2.8, 0.2, 7.0),
182'M5': (0.8, 0.2, 7.5, 8.9, 3.5, 0.2, 8.0),
183'M6': (1.0, 0.2, 9.5, 11.05, 4.0, 0.25, 10.0),
184'M8': (1.25, 0.3, 11.7, 14.5, 5.3, 0.25, 13.0),
185'M10': (1.50, 0.3, 14.7, 17.9, 6.4, 0.4, 16.0),
186'M12': (1.75, 0.3, 16.7, 20.1, 7.5, 0.6, 18.0),
187'(M14)': (2.00, 0.3, 20.5, 24.5, 8.8, 0.6, 22.0),
188'M16': (2.00, 0.4, 22.4, 26.9, 10.0, 0.6, 24.0),
189'(M18)': (2.50, 0.4, 25.4, 30.2, 11.5, 0.6, 27.0),
190'M20': (2.50, 0.4, 28.2, 33.7, 12.5, 0.8, 30.0),
191'(M22)': (2.50, 0.4, 31.8, 37.7, 14.0, 0.8, 34.0),
192'M24': (3.00, 0.4, 33.7, 40.1, 15.0, 0.8, 36.0),
193'(M27)': (3.00, 0.4, 38.0, 45.2, 17.0, 1.0, 41.0),
194'M30': (3.50, 0.4, 42.8, 50.9, 18.7, 1.0, 46.0), #dw not in class A, e not in class A
195'(M33)': (3.50, 0.4, 46.6, 55.4, 21.0, 1.0, 50.0),
196'M36': (4.00, 0.4, 51.2, 61.0, 22.5, 1.0, 55.0), #dw not in class A, e not in class A
197'(M39)': (4.00, 0.5, 55.9, 66.5, 25.0, 1.0, 60.0),
198'M42': (4.50, 0.7, 60.0, 71.3, 26.0, 1.2, 65.0),
199'(M45)': (4.50, 0.7, 64.7, 77.0, 28.0, 1.2, 70.0),
200'M48': (5.00, 0.7, 69.5, 82.6, 30.0, 1.6, 75.0),
201'(M52)': (5.00, 0.7, 74.5, 88.3, 33.0, 1.6, 80.0),
202'M56': (5.50, 0.7, 78.7, 93.6, 35.0, 2.0, 85.0),
203'(M60)': (5.50, 0.7, 82.7, 99.2, 38.0, 2.0, 90.0),
204'M64': (6.00, 0.7, 88.2,104.9, 40.0, 2.0, 95.0)
205}
206
207iso4017length = {
208'2': ( 1.8, 2.2),
209'3': ( 2.8, 3.2),
210'4': ( 3.76, 4.24),
211'5': ( 4.76, 5.24),
212'6': ( 5.76, 6.24),
213'8': ( 7.71, 8.29),
214'10':( 9.71, 10.29),
215'12':(11.65, 12.35),
216'14':(13.65, 14.35),
217'16':(15.65, 16.35),
218'20':(19.58, 20.42),
219'25':(24.58, 25.42),
220'30':(29.58, 30.42),
221'35':(34.5, 35.5),
222'40':(39.5, 40.5),
223'45':(44.5, 45.5),
224'50':(49.5, 50.5),
225'55':(54.4, 55.6),
226'60':(59.4, 60.6),
227'65':(64.4, 65.6),
228'70':(69.4, 70.6),
229'80':(79.4, 80.6),
230'100':(99.3, 100.7),
231'110':(109.3, 110.7),
232'120':(119.3, 120.7),
233'130':(129.2, 130.8),
234'140':(139.2, 130.8),
235'150':(149.2, 150.8),
236'160':(159.2, 160.8),
237'180':(179.2, 180.8),
238'200':(199.1, 200.9)
239}
240
241# range of typical screw lengths
242# min_length, max_length
243iso4017range = {
244'M1.6': ('2', '16'),
245'M2': ('4', '20'),
246'M2.5': ('5', '25'),
247'M3': ('5', '30'),
248'(M3.5)':('8', '35'),
249'M4': ('6', '40'),
250'M5': ('8', '50'),
251'M6': ('12', '60'),
252'M8': ('16', '80'),
253'M10': ('20','100'),
254'M12': ('25','120'),
255'(M14)':('25','140'),
256'M16': ('30','150'),
257'(M18)':('35','200'),
258'M20': ('40','160'),
259'(M22)':('45','200'),
260'M24': ('50','180'),
261'(M27)':('50','100'),
262'M30': ('60','200'),
263'(M33)':('65','200'),
264'M36': ('70','200'),
265'(M39)':('80','200'),
266'M42': ('70','200'),
267'(M45)':('90','200'),
268'M48': ('100','200'),
269'(M52)':('100','200'),
270'M56': ('110','200'),
271'(M60)':('120','200'),
272'M64': ('120','200')
273}
274
275# ISO 8676 Hexagon head screw with metric fine pitch thread
276# P, c, dw, e, k, r, s
277iso8676def={
278'M8x1': (1.00, 0.3, 11.7, 14.5, 5.3, 0.25, 13.0),
279'M10x1': (1.00, 0.3, 14.7, 17.9, 6.4, 0.4, 16.0),
280'(M10x1.25)':(1.25, 0.3, 14.7, 17.9, 6.4, 0.4, 16.0),
281'M12x1.5': (1.50, 0.3, 16.7, 20.1, 7.5, 0.6, 18.0),
282'(M12x1.25)':(1.75, 0.3, 16.7, 20.1, 7.5, 0.6, 18.0),
283'(M14x1.5)': (1.50, 0.3, 20.5, 24.5, 8.8, 0.6, 22.0),
284'M16x1.5': (1.50, 0.4, 22.4, 26.9, 10.0, 0.6, 24.0),
285'(M18x1.5)': (1.50, 0.4, 25.4, 30.2, 11.5, 0.6, 27.0),
286'M20x1.5': (1.50, 0.4, 28.2, 33.7, 12.5, 0.8, 30.0),
287'(M20x2)': (2.00, 0.4, 28.2, 33.7, 12.5, 0.8, 30.0),
288'(M22x1.5)': (1.50, 0.4, 31.8, 37.7, 14.0, 0.8, 34.0),
289'M24x2': (2.00, 0.4, 33.7, 40.1, 15.0, 0.8, 36.0),
290'(M27x2)': (2.00, 0.4, 38.0, 45.2, 17.0, 1.0, 41.0),
291'M30x2': (2.00, 0.4, 42.8, 50.9, 18.7, 1.0, 46.0), #dw not in class A, e not in class A
292'(M33x2)': (2.00, 0.4, 46.6, 55.4, 21.0, 1.0, 50.0),
293'M36x3': (3.00, 0.4, 51.2, 61.0, 22.5, 1.0, 55.0), #dw not in class A, e not in class A
294'(M39x3)': (3.00, 0.5, 55.9, 66.5, 25.0, 1.0, 60.0),
295'M42x3': (3.00, 0.7, 60.0, 71.3, 26.0, 1.2, 65.0),
296'(M45x3)': (3.00, 0.7, 64.7, 77.0, 28.0, 1.2, 70.0),
297'M48x3': (3.00, 0.7, 69.5, 82.6, 30.0, 1.6, 75.0),
298'(M52x4)': (4.00, 0.7, 74.5, 88.3, 33.0, 1.6, 80.0),
299'M56x4': (4.00, 0.7, 78.7, 93.6, 35.0, 2.0, 85.0),
300'(M60x4)': (4.00, 0.7, 82.7, 99.2, 38.0, 2.0, 90.0),
301'M64x4': (4.00, 0.7, 88.2,104.9, 40.0, 2.0, 95.0)
302}
303
304iso8676length = {
305'16':(15.65, 16.35),
306'20':(19.58, 20.42),
307'25':(24.58, 25.42),
308'30':(29.58, 30.42),
309'35':(34.5, 35.5),
310'40':(39.5, 40.5),
311'45':(44.5, 45.5),
312'50':(49.5, 50.5),
313'55':(54.4, 55.6),
314'60':(59.4, 60.6),
315'65':(64.4, 65.6),
316'70':(69.4, 70.6),
317'80':(79.4, 80.6),
318'100':(99.3, 100.7),
319'110':(109.3, 110.7),
320'120':(119.3, 120.7),
321'130':(129.2, 130.8),
322'140':(139.2, 130.8),
323'150':(149.2, 150.8),
324'160':(159.2, 160.8),
325'180':(179.2, 180.8),
326'200':(199.1, 200.9),
327'220':(217.7, 222.3),
328'240':(237.7, 242.3),
329'260':(219.1, 220.9),
330'280':(219.1, 220.9),
331'300':(219.1, 220.9),
332'320':(219.1, 220.9),
333'340':(219.1, 220.9),
334'360':(219.1, 220.9),
335'380':(219.1, 220.9),
336'400':(219.1, 220.9),
337'420':(219.1, 220.9),
338'440':(219.1, 220.9),
339'460':(219.1, 220.9),
340'480':(219.1, 220.9),
341'500':(496.85, 503.15)
342}
343
344# range of typical screw lengths
345# min_length, max_length
346iso8676range = {
347'M8x1': ('16', '80'),
348'M10x1': ('20','100'),
349'(M10x1.25)':('20','100'),
350'M12x1.5': ('25','120'),
351'(M12x1.25)':('25','120'),
352'(M14x1.5)': ('30','140'),
353'M16x1.5': ('35','160'),
354'(M18x1.5)': ('35','180'),
355'M20x1.5': ('40','200'),
356'(M20x2)': ('40','200'),
357'(M22x1.5)': ('45','220'),
358'M24x2': ('40','200'),
359'(M27x2)': ('55','260'),
360'M30x2': ('40','200'),
361'(M33x2)': ('65','360'),
362'M36x3': ('40','200'),
363'(M39x3)': ('80','380'),
364'M42x3': ('90','420'),
365'(M45x3)': ('90','440'),
366'M48x3': ('100','480'),
367'(M52x4)': ('100','500'),
368'M56x4': ('120','500'),
369'(M60x4)': ('120','500'),
370'M64x4': ('130','500')
371}
372
373# ISO 4014 Hex-head-bolt
374# P, b1, b2, b3, c, dw, e, k, r, s
375iso4014head={
376'M1.6': (0.35, 9.0, 15.0, 28.0, 0.2, 2.3, 3.4, 1.1, 0.1, 3.2),
377'M2': (0.40, 10.0, 16.0, 29.0, 0.2, 3.0, 4.4, 1.4, 0.1, 4.0),
378'M2.5': (0.45, 11.0, 17.0, 30.0, 0.2, 4.0, 5.5, 1.7, 0.1, 5.0),
379'M3': (0.50, 12.0, 18.0, 31.0, 0.2, 4.6, 6.1, 2.0, 0.1, 5.5),
380'(M3.5)':(0.60, 13.0, 19.0, 32.0, 0.2, 5.1, 6.6, 2.4, 0.1, 6.0),
381'M4': (0.70, 14.0, 20.0, 33.0, 0.2, 5.9, 7.7, 2.8, 0.2, 7.0),
382'M5': (0.80, 16.0, 22.0, 35.0, 0.2, 6.9, 8.9, 3.5, 0.2, 8.0),
383'M6': (1.00, 18.0, 24.0, 37.0, 0.2, 8.9, 11.05, 4.0, 0.25,10.0),
384'M8': (1.25, 22.0, 28.0, 41.0, 0.3, 11.7, 14.5, 5.3, 0.4, 13.0),
385'M10': (1.50, 26.0, 32.0, 45.0, 0.3, 14.7, 17.9, 6.4, 0.4, 16.0),
386'M12': (1.75, 30.0, 36.0, 49.0, 0.3, 16.7, 20.1, 7.5, 0.6, 18.0),
387'(M14)': (2.00, 34.0, 40.0, 53.0, 0.3, 20.5, 24.5, 8.8, 0.6, 22.0),
388'M16': (2.00, 38.0, 44.0, 57.0, 0.4, 22.4, 26.9, 10.0, 0.6, 24.0),
389'(M18)': (2.50, 42.0, 48.0, 61.0, 0.4, 25.4, 30.2, 11.5, 0.6, 27.0),
390'M20': (2.50, 46.0, 52.0, 65.0, 0.4, 28.2, 33.7, 12.5, 0.8, 30.0),
391'(M22)': (2.50, 50.0, 56.0, 69.0, 0.4, 31.8, 37.7, 14.0, 0.8, 34.0),
392'M24': (3.00, 54.0, 60.0, 73.0, 0.4, 33.7, 40.1, 15.0, 0.8, 36.0),
393'(M27)': (3.00, 60.0, 66.0, 79.0, 0.4, 38.0, 45.2, 17.0, 1.0, 41.0),
394'M30': (3.50, 66.0, 72.0, 85.0, 0.4, 42.8, 50.9, 18.7, 1.0, 46.0), #dw not in class A, e not in class A
395'(M33)': (3.50, 78.0, 78.0, 91.0, 0.4, 46.6, 55.4, 21.0, 1.0, 50.0),
396'M36': (4.00, 84.0, 84.0, 97.0, 0.4, 51.2, 60.8, 22.5, 1.0, 55.0),
397'(M39)': (4.00, 90.0, 90.0, 103.0, 0.5, 55.9, 66.5, 25.0, 1.0, 60.0),
398'M42': (4.50, 96.0, 96.0, 109.0, 0.6, 60.0, 71.3, 26.0, 1.2, 65.0),
399'(M45)': (4.50, 102.0, 102.0, 115.0, 0.7, 64.7, 77.0, 28.0, 1.2, 70.0),
400'M48': (5.00, 108.0, 108.0, 121.0, 0.6, 69.5, 82.6, 30.0, 1.6, 75.0),
401'(M52)': (5.00, 116.0, 116.0, 129.0, 0.7, 74.5, 88.3, 33.0, 1.6, 80.0),
402'M56': (5.50, 137.0, 137.0, 137.0, 0.6, 78.7, 93.6, 35.0, 2.0, 85.0),
403'(M60)': (5.50, 145.0, 145.0, 145.0, 0.7, 82.7, 99.2, 38.0, 2.0, 90.0),
404'M64': (6.00, 153.0, 153.0, 153.0, 0.6, 88.2,104.9, 40.0, 2.0, 55.0)
405}
406
407iso4014length = {
408'12':(11.65, 12.35),
409'16':(15.65, 16.35),
410'20':(19.58, 20.42),
411'25':(24.58, 25.42),
412'30':(29.58, 30.42),
413'35':(34.5, 35.5),
414'40':(39.5, 40.5),
415'45':(44.5, 45.5),
416'50':(49.5, 50.5),
417'55':(54.4, 55.6),
418'60':(59.4, 60.6),
419'65':(64.4, 65.6),
420'70':(69.4, 70.6),
421'80':(79.4, 80.6),
422'100':(99.3, 100.7),
423'110':(109.3, 110.7),
424'120':(119.3, 120.7),
425'130':(129.2, 130.8),
426'140':(139.2, 130.8),
427'150':(149.2, 150.8),
428'160':(159.2, 160.8),
429'180':(179.2, 180.8),
430'200':(199.1, 200.9),
431'220':(219.1, 220.9),
432'240':(237.7, 242.3),
433'260':(219.1, 220.9),
434'280':(219.1, 220.9),
435'300':(219.1, 220.9),
436'320':(219.1, 220.9),
437'340':(219.1, 220.9),
438'360':(219.1, 220.9),
439'380':(219.1, 220.9),
440'400':(219.1, 220.9),
441'420':(219.1, 220.9),
442'440':(219.1, 220.9),
443'460':(219.1, 220.9),
444'480':(219.1, 220.9),
445'500':(496.85, 503.15),
446}
447
448# range of typical screw lengths
449# min_length, max_length
450iso4014range = {
451'M1.6':('12', '16'),
452'M2': ('16', '20'),
453'M2.5':('16', '25'),
454'M3': ('20', '30'),
455'(M3.5)':('20', '35'),
456'M4': ('25', '50'),
457'M5': ('25', '50'),
458'M6': ('30', '130'),
459'M8': ('30', '180'),
460'M10': ('35', '150'),
461'M12': ('50', '150'),
462'(M14)': ('50', '160'),
463'M16': ('55', '200'),
464'(M18)':('70','180'),
465'M20': ('60', '300'),
466'(M22)':('70','220'),
467'M24': ('80', '220'),
468'(M27)':('90', '220'),
469'M30': ('110','300'),
470'(M33)':('130','320'),
471'M36': ('140','360'),
472'(M39)':('150','380'),
473'M42': ('160','440'),
474'(M45)':('180','440'),
475'M48': ('180','480'),
476'(M52)':('200','480'),
477'M56': ('220','500'),
478'(M60)':('220','500'),
479'M64': ('260','500')
480}
481
482# EN 1662 Hexagon bolts with flange, small series
483# P, b0, b1, b2, b3, c, dc, dw, e, k, kw, lf, r1, s
484en1662def={
485'M5': (0.80, 25.0, 16.0, 0.0, 0.0, 1.0, 11.4, 9.4, 7.59, 5.6, 2.3, 1.4, 0.2, 7.0),
486'M6': (1.00, 30.0, 18.0, 0.0, 0.0, 1.1, 13.6, 11.6, 8.71, 6.9, 2.9, 1.6, 0.25, 8.0),
487'M8': (1.25, 35.0, 22.0, 28.0, 0.0, 1.2, 17.0, 14.9, 10.95, 8.5, 3.8, 2.1, 0.4, 10.0),
488'M10':(1.50, 40.0, 26.0, 32.0, 0.0, 1.5, 20.8, 18.7, 14.26, 9.7, 4.3, 2.1, 0.4, 13.0),
489'M12':(1.75, 45.0, 30.0, 36.0, 0.0, 1.8, 24.7, 22.5, 17.62, 12.1, 5.4, 2.1, 0.6, 16.0),
490'(M14)':(2.00, 50.0, 34.0, 40.0, 0.0, 2.1, 28.6, 26.4, 19.86, 12.9, 5.6, 2.1, 0.6, 18.0),
491'M16':(2.00, 55.0, 38.0, 44.0, 57.0, 2.4, 32.8, 30.6, 23.15, 15.2, 6.8, 3.2, 0.6, 21.0)}
492
493# range of typical screw lengths
494# min_length, max_length
495en1662range = {
496'M5': ('10', '50'),
497'M6': ('12', '60'),
498'M8': ('16', '80'),
499'M10':('20','100'),
500'M12':('25','120'),
501'(M14)':('30','140'),
502'M16':('35','160')
503}
504
505en1662length = {
506'10':( 9.71, 10.29),
507'12':(11.65, 12.35),
508'16':(15.65, 16.35),
509'20':(19.58, 20.42),
510'25':(24.58, 25.42),
511'30':(29.58, 30.42),
512'35':(34.5, 35.5),
513'40':(39.5, 40.5),
514'45':(44.5, 45.5),
515'50':(49.5, 50.5),
516'55':(54.4, 55.6),
517'60':(59.4, 60.6),
518'65':(64.4, 65.6),
519'70':(69.4, 70.6),
520'80':(79.4, 80.6),
521'90':(89.3, 90.7),
522'100':(99.3, 100.7),
523'110':(109.3, 110.7),
524'120':(119.3, 120.7),
525'130':(129.2, 130.8),
526'140':(139.2, 130.8),
527'150':(149.2, 150.8),
528'160':(159.2, 160.8)
529}
530
531# EN 1665 Hexagon bolts with flange, heavy series
532# P, b0, b1, b2, b3, c, dc, dw, e, k, kw, lf, r1, s
533en1665def={
534'M5': (0.80, 25.0, 16.0, 0.0, 0.0, 1.0, 11.8, 9.8, 8.71, 5.8, 2.6, 1.4, 0.2, 8.0),
535'M6': (1.00, 30.0, 18.0, 0.0, 0.0, 1.1, 14.2, 12.2, 10.95, 6.6, 3.0, 1.6, 0.25,10.0),
536'M8': (1.25, 35.0, 22.0, 28.0, 0.0, 1.2, 18.0, 15.8, 14.26, 8.1, 3.9, 2.1, 0.4, 13.0),
537'M10':(1.50, 40.0, 26.0, 32.0, 0.0, 1.5, 22.3, 19.6, 17.62, 10.4, 4.1, 2.1, 0.4, 16.0),
538'M12':(1.75, 45.0, 30.0, 36.0, 0.0, 1.8, 26.6, 23.8, 19.86, 11.8, 5.6, 2.1, 0.6, 18.0),
539'(M14)':(2.00, 50.0, 34.0, 40.0, 0.0, 2.1, 30.5, 27.6, 23.15, 13.7, 6.5, 2.1, 0.6, 21.0),
540'M16':(2.00, 55.0, 38.0, 44.0, 57.0, 2.4, 35.0, 31.9, 26.51, 15.4, 7.3, 3.2, 0.6, 24.0),
541'M20':(2.50, 65.0, 46.0, 52.0, 65.0, 3.0, 43.0, 39.9, 33.23, 18.9, 8.9, 4.2, 0.8, 30.0)}
542
543# range of typical screw lengths
544# min_length, max_length
545en1665range = {
546'M5': ('10', '50'),
547'M6': ('12', '60'),
548'M8': ('16', '80'),
549'M10':('20','100'),
550'M12':('25','120'),
551'(M14)':('30','140'),
552'M16':('35','160'),
553'M20':('65','200')
554}
555
556en1665length = {
557'10':( 9.71, 10.29),
558'12':(11.65, 12.35),
559'16':(15.65, 16.35),
560'20':(19.58, 20.42),
561'25':(24.58, 25.42),
562'30':(29.58, 30.42),
563'35':(34.5, 35.5),
564'40':(39.5, 40.5),
565'45':(44.5, 45.5),
566'50':(49.5, 50.5),
567'55':(54.4, 55.6),
568'60':(59.4, 60.6),
569'65':(64.4, 65.6),
570'70':(69.4, 70.6),
571'80':(79.4, 80.6),
572'90':(89.3, 90.7),
573'100':(99.3, 100.7),
574'110':(109.3, 110.7),
575'120':(119.3, 120.7),
576'130':(129.2, 130.8),
577'140':(139.2, 130.8),
578'150':(149.2, 150.8),
579'160':(159.2, 160.8),
580'180':(179.2, 180.8),
581'200':(199.1, 200.9)
582}
583
584# ISO 1207 definitions Class A, Slotted cheese head screws
585# P, a, b, dk, dk_mean, da, k, n_min, r, t_min, x
586iso1207def={
587'M1.6':(0.35, 0.7, 25.0, 3.0, 2.9, 2.0, 1.1, 0.46, 0.1, 0.45, 0.9),
588'M2': (0.40, 0.8, 25.0, 3.8, 3.7, 2.6, 1.4, 0.56, 0.1, 0.6, 1.0),
589'M2.5':(0.45, 0.9, 25.0, 4.5, 4.4, 3.1, 1.8, 0.66, 0.1, 0.7, 1.1),
590'M3': (0.50, 1.0, 25.0, 5.5, 5.4, 3.6, 2.0, 0.86, 0.1, 0.85, 1.25),
591'(M3.5)':(0.60, 1.2, 38.0, 6.0, 5.9, 4.1, 2.4, 1.06, 0.1, 1.0, 1.5),
592'M4': (0.70, 1.4, 38.0, 7.0, 6.9, 4.7, 2.6, 1.26, 0.2, 1.1, 1.75),
593'M5': (0.80, 1.6, 38.0, 8.5, 8.4, 5.7, 3.3, 1.26, 0.2, 1.3, 2.0),
594'M6': (1.00, 2.0, 38.0, 10.0, 9.9, 6.8, 3.9, 1.66, 0.25,1.6, 2.5),
595'M8': (1.25, 2.5, 38.0, 13.0, 12.85, 9.2, 5.0, 2.06, 0.4, 2.0, 3.2),
596'M10': (1.50, 3.0, 38.0, 16.0, 15.85, 11.2,6.0, 2.56, 0.4, 2.4, 3.8)}
597
598# range of typical screw lengths
599# min_length, max_length
600iso1207range = {
601'M1.6':('2', '16'),
602'M2': ('3', '20'),
603'M2.5':('3', '25'),
604'M3': ('4', '30'),
605'(M3.5)':('5', '35'),
606'M4': ('5', '40'),
607'M5': ('6', '50'),
608'M6': ('8', '60'),
609'M8': ('10', '80'),
610'M10':('12', '80')}
611
612# slotted cheese head screws
613# nom length: l_min, l_max
614iso1207length = {
615'2': (1.8, 2.2),
616'3': ( 2.8, 3.2),
617'4': ( 3.76, 4.24),
618'5': ( 4.76, 5.24),
619'6': ( 5.76, 6.24),
620'8': ( 7.71, 8.29),
621'10':( 9.71, 10.29),
622'12':(11.65, 12.35),
623'14':(13.65, 14.35),
624'16':(15.65, 16.35),
625'20':(19.58, 20.42),
626'25':(24.58, 25.42),
627'30':(29.58, 30.42),
628'35':(34.5, 35.5),
629'40':(39.5, 40.5),
630'45':(44.5, 45.5),
631'50':(49.5, 50.5),
632'55':(54.05, 55.95),
633'60':(59.05, 60.95),
634'65':(64.05, 65.95),
635'70':(69.05, 70.95),
636'75':(74.05, 75.95),
637'80':(79.05, 80.95)
638}
639
640# ISO 14580 definitions , Hexalobular socket cheese head screws
641# P, a, b, dk, dk_mean, da, k, n_min, r, t_min, x
642# tt, k, A, t_mean
643iso14580def={
644'M2': ('T6', 1.55, 1.75, 0.8),
645'M2.5':('T8', 1.85, 2.40, 0.9),
646'M3': ('T10', 2.40, 2.80, 1.2),
647'(M3.5)':('T15', 2.60, 3.35, 1.3),
648'M4': ('T20', 3.10, 3.95, 1.5),
649'M5': ('T25', 3.65, 4.50, 1.7),
650'M6': ('T30', 4.40, 5.60, 2.1),
651'M8': ('T45', 5.80, 7.95, 2.9),
652'M10': ('T50', 6.90, 8.95, 3.3)}
653
654# range of typical screw lengths
655# min_length, max_length
656# iso14580range = iso1207range
657
658# nom length: l_min, l_max
659iso14580length = {
660'3': ( 2.8, 3.2),
661'4': ( 3.76, 4.24),
662'5': ( 4.76, 5.24),
663'6': ( 5.76, 6.24),
664'8': ( 7.71, 8.29),
665'10':( 9.71, 10.29),
666'12':(11.65, 12.35),
667'14':(13.65, 14.35),
668'16':(15.65, 16.35),
669'20':(19.58, 20.42),
670'25':(24.58, 25.42),
671'30':(29.58, 30.42),
672'35':(34.5, 35.5),
673'40':(39.5, 40.5),
674'45':(44.5, 45.5),
675'50':(49.5, 50.5),
676'55':(54.05, 55.95),
677'60':(59.05, 60.95),
678'65':(64.05, 65.95),
679'70':(69.05, 70.95),
680'75':(74.05, 75.95),
681'80':(79.05, 80.95)
682}
683
684
685
686# ISO 7048 definitions Class A,
687# Cross-recessed cheese head screws with type H or Z cross recess
688# P, a, b, dk, dk_mean, da, k, r, x, cT, mH, mZ
689iso7048def={
690'M2.5':(0.45, 0.9, 25.0, 4.5, 4.4, 3.1, 1.8, 0.1, 1.1, '1', 2.7, 2.4),
691'M3': (0.50, 1.0, 25.0, 5.5, 5.4, 3.6, 2.0, 0.1, 1.25,'2', 3.5, 3.5),
692'(M3.5)':(0.60, 1.2, 38.0, 6.0, 5.9, 4.1, 2.4, 0.1, 1.5, '2', 3.8, 3.7),
693'M4': (0.70, 1.4, 38.0, 7.0, 6.9, 4.7, 2.6, 0.2, 1.75,'2', 4.1, 4.0),
694'M5': (0.80, 1.6, 38.0, 8.5, 8.4, 5.7, 3.3, 0.2, 2.0, '2', 4.8, 4.6),
695'M6': (1.00, 2.0, 38.0, 10.0, 9.9, 6.8, 3.9, 0.25,2.5, '3', 6.2, 6.1),
696'M8': (1.25, 2.5, 38.0, 13.0, 12.85, 9.2, 5.0, 0.4, 3.2, '3', 7.7, 7.5)
697}
698
699# range of typical screw lengths
700# min_length, max_length
701iso7048range = {
702'M2.5':('3', '25'),
703'M3': ('4', '30'),
704'(M3.5)':('5', '35'),
705'M4': ('5', '40'),
706'M5': ('6', '50'),
707'M6': ('8', '60'),
708'M8': ('10', '80')}
709
710# nom length: l_min, l_max
711iso7048length = {
712'3': ( 2.8, 3.2),
713'4': ( 3.76, 4.24),
714'5': ( 4.76, 5.24),
715'6': ( 5.76, 6.24),
716'8': ( 7.71, 8.29),
717'10':( 9.71, 10.29),
718'12':(11.65, 12.35),
719'16':(15.65, 16.35),
720'20':(19.58, 20.42),
721'25':(24.58, 25.42),
722'30':(29.58, 30.42),
723'35':(34.5, 35.5),
724'40':(39.5, 40.5),
725'45':(44.5, 45.5),
726'50':(49.5, 50.5),
727'60':(59.05, 60.95),
728'70':(69.05, 70.95),
729'80':(79.05, 80.95)
730}
731
732
733# Button Head Screw
734# nom length: l_min, l_max
735iso7380length = {
736#'2.5':(2.3, 2.7),
737#'3': ( 2.8, 3.2),
738'4': ( 3.76, 4.24),
739'5': ( 4.76, 5.24),
740'6': ( 5.76, 6.24),
741'8': ( 7.71, 8.29),
742'10':( 9.71, 10.29),
743'12':(11.65, 12.35),
744'14':(13.65, 14.35),
745'16':(15.65, 16.35),
746'20':(19.58, 20.42),
747'25':(24.58, 25.42),
748'30':(29.58, 30.42),
749'35':(34.5, 35.5),
750'40':(39.5, 40.5),
751'45':(44.5, 45.5),
752'50':(49.5, 50.5),
753'55':(54.05, 55.95),
754'60':(59.05, 60.95),
755'65':(64.4, 65.6),
756'70':(69.4, 70.6),
757'80':(79.4, 80.6),
758'90':(89.3, 90.7)
759}
760
761# ISO 7380-1 definitions Class A
762# http://www.agrati.com/it/unificati/it/gamma/unificati/home02.htm
763# P, b, a, da, dk, dk_mean,s_mean,t_min, r, k, e, w,
764iso7380def={
765'M3': (0.50, 18.0, 1.0, 3.6, 5.7, 5.5, 2.03, 1.04, 0.1, 1.65, 2.3, 0.2),
766'M4': (0.70, 20.0, 1.4, 4.7, 7.6, 7.4, 2.54, 1.30, 0.2, 2.20, 2.87, 0.3),
767'M5': (0.80, 22.0, 1.6, 5.7, 9.5, 9.3, 3.05, 1.56, 0.2, 2.75, 3.44, 0.38),
768'M6': (1.00, 24.0, 2.0, 6.8, 10.5, 10.3, 4.05, 2.08, 0.25,3.3, 4.58, 0.74),
769'M8': (1.25, 28.0, 2.5, 9.2, 14.0, 13.8, 5.05, 2.60, 0.4, 4.4, 5.72, 1.05),
770'M10': (1.50, 32.0, 3.0, 11.2, 17.5, 17.3, 6.05, 3.12, 0.4, 5.5, 6.86, 1.45),
771'M12': (1.75, 36.0, 3.5, 13.7, 21.0, 20.7, 8.06, 4.16, 0.6, 6.6, 9.15, 1.63),
772'M16': (2.00, 44.0, 3.5, 17.7, 28.0, 27.8, 10.06,5.20, 0.6, 8.8, 11.43, 2.25)
773}
774
775# range of typical screw lengths
776# min_length, max_length
777iso7380range = {
778'M3': ('6', '30'),
779'M4': ('6', '40'),
780'M5': ('8', '50'),
781'M6': ('10', '60'),
782'M8': ('12', '80'),
783'M10':('16', '90'),
784'M12':('20', '90'),
785'M16':('25', '90')}
786
787# ISO 7380-2 definitions
788# P, b, c, da, dk, dk_c,s_mean,t_min, r, k, e, w,
789iso7380_2def={
790'M3': (0.50, 18.0, 0.7, 3.6, 5.2, 6.9, 2.03, 1.04, 0.1, 1.65, 2.3, 0.2),
791'M4': (0.70, 20.0, 0.8, 4.7, 7.2, 9.4, 2.54, 1.30, 0.2, 2.20, 2.87, 0.3),
792'M5': (0.80, 22.0, 1.0, 5.7, 8.8, 11.8, 3.05, 1.56, 0.2, 2.75, 3.44, 0.38),
793'M6': (1.00, 24.0, 1.2, 6.8, 10.0, 13.6, 4.05, 2.08, 0.25,3.3, 4.58, 0.74),
794'M8': (1.25, 28.0, 1.5, 9.2, 13.2, 17.8, 5.05, 2.60, 0.4, 4.4, 5.72, 1.05),
795'M10': (1.50, 32.0, 2.0, 11.2, 16.5, 21.9, 6.05, 3.12, 0.4, 5.5, 6.86, 1.45),
796'M12': (1.75, 36.0, 2.4, 13.7, 19.4, 26.0, 8.06, 4.16, 0.6, 6.6, 9.15, 1.63),
797'M16': (2.00, 44.0, 2.8, 17.7, 26.0, 34.0, 10.06,5.20, 0.6, 8.8, 11.43, 2.25)
798}
799
800
801# DIN 967 definitions: Cross recessed pan head screw with collar
802# P, b, c, da, dk, r, k, rf, x, cT, mH, mZ
803din967def={
804'M3': (0.50, 25.0, 0.7, 3.6, 7.5, 0.1, 2.35, 3.8, 1.25, '1', 3.0, 2.9),
805'(M3.5)':(0.60, 38.0, 0.8, 4.1, 9.0, 0.1, 2.60, 4.6, 1.5, '2', 4.2, 3.9),
806'M4': (0.70, 38.0, 1.0, 4.7, 10.0, 0.2, 3.05, 5.8, 1.75, '2', 4.6, 4.3),
807'M5': (0.80, 38.0, 1.2, 5.7, 11.5, 0.2, 3.55, 6.6, 2.0, '2', 5.0, 4.7),
808'M6': (1.00, 38.0, 1.6, 6.8, 14.5, 0.25,4.55, 8.2, 2.5, '3', 7.1, 6.7),
809'M8': (1.25, 38.0, 2.0, 9.2, 19.0, 0.4, 5.90, 11.0, 3.2, '4', 9.0, 8.8)
810}
811
812# range of typical screw lengths
813# min_length, max_length
814din967range = {
815'M3': ('4', '30'),
816'(M3.5)': ('5', '35'),
817'M4': ('5', '40'),
818'M5': ('6', '45'),
819'M6': ('8', '60'),
820'M8': ('10', '60')
821}
822# Button Head Screw
823# nom length: l_min, l_max
824din967length = {
825'4': ( 3.76, 4.24),
826'5': ( 4.76, 5.24),
827'6': ( 5.76, 6.24),
828'8': ( 7.71, 8.29),
829'10':( 9.71, 10.29),
830'12':(11.65, 12.35),
831'14':(13.65, 14.35),
832'16':(15.65, 16.35),
833'20':(19.58, 20.42),
834'25':(24.58, 25.42),
835'30':(29.58, 30.42),
836'35':(34.5, 35.5),
837'40':(39.5, 40.5),
838'45':(44.5, 45.5),
839'50':(49.5, 50.5),
840'55':(54.05, 55.95),
841'60':(59.05, 60.95)
842}
843
844
845L_iso2009length =['2.5','3','4','5','6','8','10','12','14','16','20', \
846'25','30','35','40','45','50','55','60','65','70','75','80']
847# nom length: l_min, l_max
848iso2009length = {
849'2.5':(2.3, 2.7),
850'3': ( 2.8, 3.2),
851'4': ( 3.76, 4.24),
852'5': ( 4.76, 5.24),
853'6': ( 5.76, 6.24),
854'8': ( 7.71, 8.29),
855'10':( 9.71, 10.29),
856'12':(11.65, 12.35),
857'14':(13.65, 14.35),
858'16':(15.65, 16.35),
859'20':(19.58, 20.42),
860'25':(24.58, 25.42),
861'30':(29.58, 30.42),
862'35':(34.5, 35.5),
863'40':(39.5, 40.5),
864'45':(44.5, 45.5),
865'50':(49.5, 50.5),
866'55':(54.05, 55.95),
867'60':(59.05, 60.95),
868'65':(64.05, 65.95),
869'70':(69.05, 70.95),
870'75':(74.05, 75.95),
871'80':(79.05, 80.95)
872}
873
874
875# ISO 2009 definitions Class A
876# P, a, b, dk_theo, dk_mean, k, n_min, r, t_mean, x
877iso2009def={
878'M1.6':(0.35, 0.7, 25, 3.6, 2.8, 1.0, 0.46, 0.2, 0.4, 0.9),
879'M2': (0.40, 0.8, 25, 4.4, 3.6, 1.2, 0.56, 0.3, 0.5, 1.0),
880'M2.5':(0.45, 0.9, 25, 5.5, 4.5, 1.5, 0.66, 0.3, 0.6, 1.1),
881'M3': (0.50, 1.0, 25, 6.3, 5.3, 1.65, 0.86, 0.4, 0.7, 1.25),
882'(M3.5)':(0.60, 1.2, 38, 8.2, 7.1, 2.35, 1.06, 0.4, 1.0, 1.5),
883'M4': (0.70, 1.4, 38, 9.4, 8.2, 2.7, 1.26, 0.5, 1.1, 1.75),
884'M5': (0.80, 1.6, 38,10.4, 9.2, 2.7, 1.26, 0.6, 1.2, 2.0),
885'M6': (1.00, 2.0, 38,12.6, 11.2, 3.3, 1.66, 0.7, 1.4, 2.5),
886'M8': (1.25, 2.5, 38,17.3, 15.6, 4.65, 2.06, 1.0, 2.0, 3.2),
887'M10': (1.50, 3.0, 38,20.0, 18.1, 5.0, 2.56, 1.2, 2.3, 3.8)}
888
889# range of typical screw lengths
890# min_length, max_length
891iso2009range = {
892'M1.6':('2.5', '16'),
893'M2': ('3', '20'),
894'M2.5':('4', '25'),
895'M3': ('5', '30'),
896'(M3.5)':('6', '35'),
897'M4': ('6', '40'),
898'M5': ('8', '50'),
899'M6': ('8', '60'),
900'M8': ('10', '80'),
901'M10':('12', '80')}
902
903
904# ISO 7046 definitions Class A
905# ISO 7046 Countersunk flat head screws (common head style)
906# with type H or type Z cross recess
907# Parameters P, a, b, dk_theo, dk_mean, k, r, x to be read from iso2009def
908# Length = iso7045length
909# cT, mH, mZ
910iso7046def={
911'M1.6':('0', 1.6, 1.6),
912'M2': ('0', 1.9, 1.9),
913'M2.5':('1', 2.9, 2.8),
914'M3': ('1', 3.2, 3.0),
915'(M3.5)':('2', 4.4, 4.1),
916'M4': ('2', 4.6, 4.4),
917'M5': ('2', 5.2, 4.0),
918'M6': ('3', 6.8, 6.6),
919'M8': ('4', 8.9, 8.8),
920'M10': ('4', 10.0,9.8)}
921
922# range of typical screw lengths
923# min_length, max_length
924iso7046range = {
925'M1.6':('3', '16'),
926'M2': ('3', '20'),
927'M2.5':('3', '25'),
928'M3': ('4', '30'),
929'(M3.5)':('5', '35'),
930'M4': ('5', '40'),
931'M5': ('6', '50'),
932'M6': ('8', '60'),
933'M8': ('10', '60'),
934'M10':('12', '60')}
935
936# ISO 2010, ISO 7047 definitions Class A: Raised Countersunk head screws
937# ISO 2010 slotted screws (common head style) range = iso2009range
938# ISO 7047 with type H or type Z cross recess range = iso7046range
939# Parameters P, a, b, dk_theo, dk_mean, k, r, x to be read from iso2009def
940# Length = iso7045length
941# rf, t_mean, cT, mH, mZ
942Raised_countersunk_def={
943'M1.6':(3.0, 0.7, '0', 1.9, 1.9),
944'M2': (4.0, 0.9, '0', 2.0, 2.2),
945'M2.5':(5.0, 1.1, '1', 3.0, 2.8),
946'M3': (6.0, 1.3, '1', 3.4, 3.1),
947'(M3.5)':(8.5, 1.5, '2', 4.8, 4.6),
948'M4': (9.5, 1.8, '2', 5.2, 5.0),
949'M5': (9.5, 2.2, '2', 5.4, 5.3),
950'M6': (12.0, 2.6, '3', 7.3, 7.1),
951'M8': (16.5, 3.5, '4', 9.6, 9.5),
952'M10': (19.5, 4.1, '4', 10.4,10.3)}
953
954
955
956# ISO 14582 definitions
957# P, a, b, dk_theo, dk_mean,k, r, tt, A, t_mean
958iso14582def={
959'M3': (0.50, 1.0, 18.0, 7.40, 6.5, 2.20, 0.10, 'T10', 2.80, 1.1),
960'M4': (0.70, 1.4, 20.0, 10.02, 9.0, 3.01, 0.20, 'T20', 3.95, 1.6),
961'M5': (0.80, 1.6, 22.0, 12.00, 10.8, 3.50, 0.20, 'T25', 4.50, 1.8),
962'M6': (1.00, 2.0, 24.0, 14.44, 13.1, 4.22, 0.25, 'T30', 5.60, 2.2),
963'M8': (1.25, 2.5, 28.0, 19.38, 17.8, 5.69, 0.40, 'T45', 7.93, 2.8),
964'M10': (1.50, 3.0, 32.0, 23.00, 21.1, 6.50, 0.40, 'T50', 8.95, 3.3)}
965
966# range of typical screw lengths
967# min_length, max_length
968iso14582range = {
969'M3': ('8', '30'),
970'M4': ('8', '40'),
971'M5': ('8', '50'),
972'M6': ('8', '60'),
973'M8': ('10', '80'),
974'M10':('12', '100')}
975
976# nom length: l_min, l_max
977iso14582length = {
978'8': ( 7.71, 8.29),
979'10':( 9.71, 10.29),
980'12':(11.65, 12.35),
981'14':(13.65, 14.35),
982'16':(15.65, 16.35),
983'20':(19.58, 20.42),
984'25':(24.58, 25.42),
985'30':(29.58, 30.42),
986'35':(34.5, 35.5),
987'40':(39.5, 40.5),
988'45':(44.5, 45.5),
989'50':(49.5, 50.5),
990'55':(54.4, 55.6),
991'60':(59.4, 60.6),
992'65':(64.4, 65.6),
993'70':(69.4, 70.6),
994'80':(79.4, 80.6),
995'90':(89.3, 90.7),
996'100':(99.3, 100.7)
997}
998
999
1000
1001# ISO 1580 definitions Class A, Slotted pan head screws
1002# P, a, b, dk_max,da, k, n_min, r, rf, t_mean, x
1003iso1580def={
1004'M1.6':(0.35, 0.7, 25, 3.2, 2.0, 1.0, 0.46, 0.1, 0.5, 0.4, 0.9),
1005'M2': (0.4, 0.8, 25, 4.0, 2.6, 1.3, 0.56, 0.1, 0.6, 0.5, 1.0),
1006'M2.5':(0.45, 0.9, 25, 5.0, 3.1, 1.5, 0.66, 0.1, 0.8, 0.6, 1.1),
1007'M3': (0.5, 1.0, 25, 5.6, 3.6, 1.8, 0.86, 0.1, 0.9, 0.7, 1.25),
1008'(M3.5)':(0.6, 1.2, 38, 7.0, 4.1, 2.1, 1.06, 0.1, 1.0, 0.8, 1.5),
1009'M4': (0.7, 1.4, 38, 8.0, 4.7, 2.4, 1.26, 0.2, 1.2, 1.0, 1.75),
1010'M5': (0.8, 1.6, 38, 9.5, 5.7, 3.0, 1.26, 0.2, 1.5, 1.2, 2.0),
1011'M6': (1.0, 2.0, 38, 12.0, 6.8, 3.6, 1.66, 0.25,1.8, 1.4, 2.5),
1012'M8': (1.25, 2.5, 38, 16.0, 9.2, 4.8, 2.06, 0.4, 2.4, 1.9, 3.2),
1013'M10': (1.50, 3.0, 38, 20.0,11.2, 6.0, 2.56, 0.4, 3.0, 2.4, 3.8)}
1014
1015
1016
1017# ISO 7045 definitions Class A, Pan head screws with type H or type Z
1018# partly used also for ISO 14583 Hexalobular socket pan head screws
1019# cross recess; cT = size of cross recess
1020# P, a, b, dk_max,da, k, r, rf, x, cT, mH, mZ
1021iso7045def={
1022'M1.6':(0.35, 0.7, 25, 3.2, 2.0, 1.3, 0.1, 2.5, 0.9, '0', 1.7, 1.6),
1023'M2': (0.4, 0.8, 25, 4.0, 2.6, 1.6, 0.1, 3.2, 1.0, '0', 1.9, 2.1),
1024'M2.5':(0.45, 0.9, 25, 5.0, 3.1, 2.1, 0.1, 4.0, 1.1, '1', 2.7, 2.6),
1025'M3': (0.5, 1.0, 25, 5.6, 3.6, 2.4, 0.1, 5.0, 1.25,'1', 3.0, 2.8),
1026'(M3.5)':(0.6, 1.2, 38, 7.0, 4.1, 2.6, 0.1, 6.0, 1.5, '2', 3.9, 3.9),
1027'M4': (0.7, 1.4, 38, 8.0, 4.7, 3.1, 0.2, 6.5, 1.75,'2', 4.4, 4.3),
1028'M5': (0.8, 1.6, 38, 9.5, 5.7, 3.7, 0.2, 8.0, 2.0, '2', 4.9, 4.7),
1029'M6': (1.0, 2.0, 38, 12.0, 6.8, 4.6, 0.25,10., 2.5, '3', 6.9, 6.7),
1030'M8': (1.25, 2.5, 38, 16.0, 9.2, 6.0, 0.4, 13., 3.2, '4', 9.0, 8.8),
1031'M10': (1.50, 3.0, 38, 20.0,11.2, 7.5, 0.4, 16., 3.8, '4', 10.1,9.9)}
1032
1033# nom length: l_min, l_max
1034iso7045length = {
1035'3': ( 2.8, 3.2),
1036'4': ( 3.76, 4.24),
1037'5': ( 4.76, 5.24),
1038'6': ( 5.76, 6.24),
1039'8': ( 7.71, 8.29),
1040'10':( 9.71, 10.29),
1041'12':(11.65, 12.35),
1042'14':(13.65, 14.35),
1043'16':(15.65, 16.35),
1044'20':(19.58, 20.42),
1045'25':(24.58, 25.42),
1046'30':(29.58, 30.42),
1047'35':(34.5, 35.5),
1048'40':(39.5, 40.5),
1049'45':(44.5, 45.5),
1050'50':(49.5, 50.5),
1051'55':(54.05, 55.95),
1052'60':(59.05, 60.95)
1053}
1054
1055# range of typical screw lengths
1056# min_length, max_length
1057iso7045range = {
1058'M1.6':('3', '16'),
1059'M2': ('3', '20'),
1060'M2.5':('3', '25'),
1061'M3': ('4', '30'),
1062'(M3.5)':('5', '35'),
1063'M4': ('5', '40'),
1064'M5': ('6', '45'),
1065'M6': ('8', '60'),
1066'M8': ('10', '60'),
1067'M10':('12', '60')}
1068
1069
1070# ISO 14583 Hexalobular socket pan head screws
1071# hexalobular recess; tt = size of hexalobular recess
1072
1073# tt, A, t_mean
1074iso14583def={
1075'M2': ('T6', 1.75, 0.7),
1076'M2.5':('T8', 2.40, 1.0),
1077'M3': ('T10', 2.80, 1.2),
1078'(M3.5)':('T15', 3.35, 1.3),
1079'M4': ('T20', 3.95, 1.5),
1080'M5': ('T25', 4.50, 1.7),
1081'M6': ('T30', 5.60, 2.2),
1082'M8': ('T45', 7.95, 3.0),
1083'M10': ('T50', 8.95, 3.8)}
1084
1085
1086#iso14583range = iso7046range
1087#iso14583length = iso7045length
1088
1089# ISO 14584 Hexalobular socket raised countersunk head screws
1090# P, b, dk_theo, dk_mean, f, k, r, rf, x, tt, A, t_mean
1091iso14584def={
1092'M2': (0.40, 25.0, 4.4, 3.8, 0.5, 1.20, 0.2, 4.0, 1.00, 'T6', 1.75, 0.7),
1093'M2.5':(0.45, 25.0, 5.5, 4.7, 0.6, 1.50, 0.3, 5.0, 1.10, 'T8', 2.40, 1.0),
1094'M3': (0.50, 25.0, 6.3, 5.5, 0.7, 1.65, 0.4, 6.0, 1.25, 'T10', 2.80, 1.2),
1095'(M3.5)':(0.60, 38.0, 8.2, 7.3, 0.8, 2.35, 0.4, 8.5, 1.50, 'T15', 3.35, 1.3),
1096'M4': (0.70, 38.0, 9.4, 8.4, 1.0, 2.70, 0.5, 9.5, 1.75, 'T20', 3.95, 1.5),
1097'M5': (0.80, 38.0, 10.4, 9.3, 1.2, 2.70, 0.6, 9.5, 2.00, 'T25', 4.50, 1.7),
1098'M6': (1.00, 38.0, 12.6, 11.3, 1.4, 3.30, 0.7, 12.0, 2.50, 'T30', 5.60, 2.2),
1099'M8': (1.25, 38.0, 17.3, 15.8, 2.0, 4.65, 1.0, 16.5, 3.20, 'T45', 7.95, 3.0),
1100'M10': (1.50, 38.0, 20.0, 18.3, 2.3, 5.00, 1.2, 19.5, 3.80, 'T50', 8.95, 3.8)}
1101
1102
1103# range of typical screw lengths
1104# min_length, max_length
1105iso14584range = {
1106'M2': ('3', '20'),
1107'M2.5':('3', '25'),
1108'M3': ('4', '30'),
1109'(M3.5)':('5', '35'),
1110'M4': ('5', '40'),
1111'M5': ('6', '50'),
1112'M6': ('8', '60'),
1113'M8': ('10', '60'),
1114'M10':('12', '60')}
1115
1116#iso14584length = iso7045length
1117
1118
1119# ISO 4762 Hexagon socket head cap screws (Allen screw)
1120# ISO 4762 definitions
1121# P, b, dk_max, da, ds_min, e, lf, k, r, s_mean, t, v, dw, w
1122iso4762def={
1123'M1.6':(0.35, 15.0, 3.0, 2.0, 1.46, 1.73, 0.34, 1.6, 0.1, 1.56, 0.7, 0.16, 2.72, 0.55),
1124'M2': (0.40, 16.0, 3.8, 2.6, 1.86, 1.73, 0.51, 2.0, 0.1, 1.56, 1.0, 0.2, 3.48, 0.55),
1125'M2.5':(0.45, 17.0, 4.5, 3.1, 2.36, 2.30, 0.51, 2.5, 0.1, 2.06, 1.1, 0.25, 4.18, 0.85),
1126'M3': (0.50, 18.0, 5.5, 3.6, 2.86, 2.87, 0.51, 3.0, 0.1, 2.56, 1.3, 0.3, 5.07, 1.15),
1127'M4': (0.70, 20.0, 7.0, 4.7, 3.82, 3.44, 0.60, 4.0, 0.2, 3.06, 2.0, 0.4, 6.53, 1.40),
1128'M5': (0.80, 22.0, 8.5, 5.7, 4.82, 4.58, 0.60, 5.0, 0.2, 4.06, 2.5, 0.5, 8.03, 1.9),
1129'M6': (1.00, 24.0, 10.0, 6.8, 5.82, 5.72, 0.68, 6.0, 0.25, 5.06, 3.0, 0.6, 9.38, 2.3),
1130'M8': (1.25, 28.0, 13.0, 9.2, 7.78, 6.86, 1.02, 8.0, 0.4, 6.06, 4.0, 0.8, 12.33, 3.3),
1131'M10': (1.50, 32.0, 16.0, 11.2, 9.78, 9.15, 1.02, 10.0, 0.4, 8.07, 5.0, 1.0, 15.33, 4.0),
1132'M12': (1.75, 36.0, 18.0, 13.7, 11.73, 11.43, 1.45, 12.0, 0.6, 10.07, 6.0, 1.2, 17.23, 4.8),
1133'(M14)':(2.00, 40.0, 21.0, 15.7, 13.73, 13.72, 1.45, 14.0, 0.6, 12.07, 7.0, 1.4, 20.17, 5.8),
1134'M16': (2.00, 44.0, 24.0, 17.7, 15.73, 16.00, 1.45, 16.0, 0.6, 14.08, 8.0, 1.6, 23.17, 6.8),
1135'M20': (2.50, 52.0, 30.0, 22.4, 19.67, 19.44, 2.04, 20.0, 0.8, 17.10, 10.0, 2.0, 28.87, 8.6),
1136'M24': (3.00, 60.0, 36.0, 26.4, 23.67, 21.73, 2.04, 24.0, 0.8, 19.15, 12.0, 2.0, 34.81, 10.4),
1137'M30': (3.50, 72.0, 45.0, 33.4, 29.67, 25.15, 2.89, 30.0, 1.0, 22.15, 15.5, 2.4, 43.61, 13.1),
1138'M36': (4.00, 84.0, 54.0, 39.4, 35.61, 30.85, 2.89, 36.0, 1.0, 27.15, 19.0, 3.0, 52.54, 15.3),
1139'M42': (4.50, 96.0, 63.0, 45.6, 41.61, 36.58, 3.06, 42.0, 1.2, 32.15, 24.0, 4.2, 61.34, 16.3),
1140'M48': (5.00, 108.0, 72.0, 52.6, 47.61, 41.14, 3.91, 48.0, 1.6, 36.15, 28.0, 4.8, 70.34, 17.5),
1141'M56': (5.50, 124.0, 84.0, 63.0, 55.54, 46.84, 5.95, 56.0, 2.0, 41.15, 34.0, 5.6, 82.26, 19.0),
1142'M64': (6.00, 140.0, 96.0, 71.0, 63.54, 52.54, 5.95, 64.0, 2.0, 46.15, 38.0, 6.4, 94.26, 22.0)
1143}
1144
1145# nom length: l_min, l_max
1146iso4762length = {
1147'2.5':(2.3, 2.7),
1148'3': ( 2.8, 3.2),
1149'4': ( 3.76, 4.24),
1150'5': ( 4.76, 5.24),
1151'6': ( 5.76, 6.24),
1152'8': ( 7.71, 8.29),
1153'10':( 9.71, 10.29),
1154'12':(11.65, 12.35),
1155'14':(13.65, 14.35),
1156'16':(15.65, 16.35),
1157'20':(19.58, 20.42),
1158'25':(24.58, 25.42),
1159'30':(29.58, 30.42),
1160'35':(34.5, 35.5),
1161'40':(39.5, 40.5),
1162'45':(44.5, 45.5),
1163'50':(49.5, 50.5),
1164'55':(54.4, 55.6),
1165'60':(59.4, 60.6),
1166'65':(64.4, 65.6),
1167'70':(69.4, 70.6),
1168'75':(74.4, 75.6),
1169'80':(79.4, 80.6),
1170'100':(99.3, 100.7),
1171'110':(109.3, 110.7),
1172'120':(119.3, 120.7),
1173'130':(129.2, 130.8),
1174'140':(139.2, 130.8),
1175'150':(149.2, 150.8),
1176'160':(159.2, 160.8),
1177'180':(179.2, 180.8),
1178'200':(199.1, 200.9),
1179'220':(219.1, 220.9),
1180'240':(237.7, 242.3),
1181'260':(219.1, 220.9),
1182'280':(219.1, 220.9),
1183'300':(219.1, 220.9)
1184}
1185
1186# range of typical screw lengths
1187# min_length, max_length
1188iso4762range = {
1189'M1.6':('2.5', '16'),
1190'M2': ('3', '20'),
1191'M2.5':('4', '25'),
1192'M3': ('5', '30'),
1193'(M3.5)':('6', '35'),
1194'M4': ('6', '40'),
1195'M5': ('8', '50'),
1196'M6': ('8', '60'),
1197'M8': ('10', '80'),
1198'M10':('16', '100'),
1199'M12':('20', '120'),
1200'(M14)':('25', '140'),
1201'M16':('25', '160'),
1202'M20':('16', '100'),
1203'M24':('40', '200'),
1204'M30':('45', '200'),
1205'M36':('55', '200'),
1206'M42':('60', '300'),
1207'M48':('100','300'),
1208'M56':('110','300'),
1209'M64':('120','300')
1210}
1211
1212
1213# ISO 14579 Hexalobular socket head cap screws
1214# hexalobular recess; tt = size of hexalobular recess
1215
1216# tt, A, t_mean
1217iso14579def={
1218'M2': ( 'T6', 1.75, 0.8),
1219'M2.5':( 'T8', 2.40, 1.0),
1220'M3': ('T10', 2.80, 1.2),
1221'M4': ('T20', 3.95, 1.7),
1222'M5': ('T25', 4.50, 1.9),
1223'M6': ('T30', 5.60, 2.3),
1224'M8': ('T45', 7.95, 3.2),
1225'M10': ('T50', 8.95, 3.8),
1226'M12': ('T55', 11.35, 5.0),
1227'(M14)': ('T60', 13.45, 5.8),
1228'M16': ('T70', 15.70, 6.8),
1229'(M18)': ('T80', 17.75, 7.8),
1230'M20': ('T90', 20.20, 9.0),
1231}
1232
1233# range of typical screw lengths
1234# min_length, max_length
1235iso14579range = {
1236'M2': ('3', '20'),
1237'M2.5':('4', '25'),
1238'M3': ('5', '30'),
1239'M4': ('6', '40'),
1240'M5': ('8', '50'),
1241'M6': ('10', '60'),
1242'M8': ('12', '80'),
1243'M10':('16','100'),
1244'M12':('20','120'),
1245'(M14)':('25','140'),
1246'M16':('25','160'),
1247'(M18)':('30','180'),
1248'M20':('30','200'),
1249}
1250
1251iso14579length = {
1252'3': ( 2.8, 3.2),
1253'4': ( 3.76, 4.24),
1254'5': ( 4.76, 5.24),
1255'6': ( 5.76, 6.24),
1256'8': ( 7.71, 8.29),
1257'10':( 9.71, 10.29),
1258'12':(11.65, 12.35),
1259'16':(15.65, 16.35),
1260'20':(19.58, 20.42),
1261'25':(24.58, 25.42),
1262'30':(29.58, 30.42),
1263'35':(34.5, 35.5),
1264'40':(39.5, 40.5),
1265'45':(44.5, 45.5),
1266'50':(49.5, 50.5),
1267'55':(54.4, 55.6),
1268'60':(59.4, 60.6),
1269'65':(64.4, 65.6),
1270'70':(69.4, 70.6),
1271'80':(79.4, 80.6),
1272'90':(89.3, 90.7),
1273'100':(99.3, 100.7),
1274'110':(109.3, 110.7),
1275'120':(119.3, 120.7),
1276'130':(129.2, 130.8),
1277'140':(139.2, 130.8),
1278'150':(149.2, 150.8),
1279'160':(159.2, 160.8),
1280'180':(179.2, 180.8),
1281'200':(199.1, 200.9)
1282}
1283
1284
1285# ISO 10642 Hexagon socket countersunk head screws (Allen screw)
1286# ISO 10642 definitions
1287# P, b, dk_theo, dk_mean,da, ds_min, e, k, r, s_mean, t, w
1288iso10642def={
1289'M3': (0.50, 18.0, 6.72, 6.0, 3.3, 2.86, 2.31, 1.86, 0.1, 2.06, 1.1, 0.25),
1290'M4': (0.70, 20.0, 8.96, 8.0, 4.4, 3.82, 2.88, 2.48, 0.2, 2.56, 1.5, 0.45),
1291'M5': (0.80, 22.0, 11.20, 10.0, 5.5, 4.82, 3.45, 3.10, 0.2, 3.06, 1.9, 0.66),
1292'M6': (1.00, 24.0, 13.44, 12.0, 6.6, 5.82, 4.59, 3.72, 0.25, 4.06, 2.2, 0.70),
1293'M8': (1.25, 28.0, 17.92, 16.0, 8.54, 7.78, 5.73, 4.96, 0.4, 5.06, 3.0, 1.16),
1294'M10': (1.50, 32.0, 22.40, 20.5, 10.62, 9.78, 6.87, 6.20, 0.4, 6.06, 3.6, 1.62),
1295'M12': (1.75, 36.0, 26.88, 25.0, 13.5, 11.73, 9.15, 7.44, 0.6, 8.07, 4.3, 1.80),
1296'(M14)': (2.00, 40.0, 30.80, 28.4, 15.5, 13.73, 11.43, 8.40, 0.6, 10.07, 4.5, 1.62),
1297'M16': (2.00, 44.0, 33.60, 31.0, 17.5, 15.73, 11.43, 8.80, 0.6, 10.07, 4.8, 2.20),
1298'M20': (2.50, 52.0, 40.32, 38.0, 22.0, 19.67, 13.72, 10.16, 0.8, 12.10, 5.6, 2.20)}
1299
1300# range of typical screw lengths
1301# min_length, max_length
1302iso10642range = {
1303'M3': ('8', '30'),
1304'M4': ('8', '40'),
1305'M5': ('8', '50'),
1306'M6': ('8', '60'),
1307'M8': ('10', '80'),
1308'M10':('12','100'),
1309'M12':('20','100'),
1310'(M14)':('25','100'),
1311'M16':('30','100'),
1312'M20':('35','100'),
1313}
1314
1315iso10642length = {
1316'8': ( 7.71, 8.29),
1317'10':( 9.71, 10.29),
1318'12':(11.65, 12.35),
1319'16':(15.65, 16.35),
1320'20':(19.58, 20.42),
1321'25':(24.58, 25.42),
1322'30':(29.58, 30.42),
1323'35':(34.5, 35.5),
1324'40':(39.5, 40.5),
1325'45':(44.5, 45.5),
1326'50':(49.5, 50.5),
1327'55':(54.4, 55.6),
1328'60':(59.4, 60.6),
1329'65':(64.4, 65.6),
1330'70':(69.4, 70.6),
1331'80':(79.4, 80.6),
1332'90':(89.3, 90.7),
1333'100':(99.3, 100.7),
1334}
1335
1336
1337# ISO 7089 definitions Washer
1338# d1_min, d2_max, h, h_max
1339iso7089def={
1340'M1.6':( 1.7, 4.0, 0.3, 0.35),
1341'M2': ( 2.2, 5.0, 0.3, 0.35),
1342'M2.5':( 2.7, 6.0, 0.5, 0.55),
1343'M3': ( 3.2, 7.0, 0.5, 0.55),
1344'M4': ( 4.3, 9.0, 0.8, 0.90),
1345'M5': ( 5.3, 10.0, 1.0, 1.10),
1346'M6': ( 6.4, 12.0, 1.6, 1.80),
1347'M8': ( 8.4, 16.0, 1.6, 1.80),
1348'M10': (10.5, 20.0, 2.0, 2.20),
1349'M12': (13.0, 24.0, 2.5, 2.70),
1350'M16': (17.0, 30.0, 3.0, 3.30),
1351'M20': (21.0, 37.0, 3.0, 3.30),
1352'M24': (25.0, 44.0, 4.0, 4.30),
1353'M30': (31.0, 56.0, 4.0, 4.30),
1354'M36': (37.0, 66.0, 5.0, 5.60),
1355'M42': (45.0, 78.0, 8.0, 9.0),
1356'M48': (52.0, 92.0, 8.0, 9.0),
1357'M56': (62.0,105.0,10.0, 11.0),
1358'M64': (70.0,115.0,10.0, 11.0)
1359}
1360
1361
1362# ISO 7090 definitions Plain washers, chamfered - Normal series
1363# chamfer angle 30° / 45°
1364# chamfer h/4 / h/2
1365# d1_min, d2_max, h, h_max
1366iso7090def={
1367'M5': ( 5.3, 10.0, 1.0, 1.10),
1368'M6': ( 6.4, 12.0, 1.6, 1.80),
1369'M8': ( 8.4, 16.0, 1.6, 1.80),
1370'M10': (10.5, 20.0, 2.0, 2.20),
1371'M12': (13.0, 24.0, 2.5, 2.70),
1372'M16': (17.0, 30.0, 3.0, 3.30),
1373'M20': (21.0, 37.0, 3.0, 3.30),
1374'M24': (25.0, 44.0, 4.0, 4.30),
1375'M30': (31.0, 56.0, 4.0, 4.30),
1376'M36': (37.0, 66.0, 5.0, 5.60),
1377'M42': (45.0, 78.0, 8.0, 9.0),
1378'M48': (52.0, 92.0, 8.0, 9.0),
1379'M56': (62.0,105.0,10.0, 11.0),
1380'M64': (70.0,115.0,10.0, 11.0)
1381}
1382
1383
1384# ISO 7091 definitions Plain washer - Normal series Product Grade C
1385# d1_min, d2_max, h, h_max
1386iso7091def={
1387'M1.6':( 1.8, 4.0, 0.3, 0.35),
1388'M2': ( 2.4, 5.0, 0.3, 0.35),
1389'M2.5':( 2.9, 6.0, 0.5, 0.55),
1390'M3': ( 3.4, 7.0, 0.5, 0.55),
1391'M4': ( 4.5, 9.0, 0.8, 0.90),
1392'M5': ( 5.5, 10.0, 1.0, 1.10),
1393'M6': ( 6.6, 12.0, 1.6, 1.80),
1394'M8': ( 9.0, 16.0, 1.6, 1.80),
1395'M10': (11.0, 20.0, 2.0, 2.20),
1396'M12': (13.5, 24.0, 2.5, 2.70),
1397'M16': (17.5, 30.0, 3.0, 3.30),
1398'M20': (22.0, 37.0, 3.0, 3.30),
1399'M24': (26.0, 44.0, 4.0, 4.30),
1400'M30': (33.0, 56.0, 4.0, 4.30),
1401'M36': (39.0, 66.0, 5.0, 5.60),
1402'M42': (45.0, 78.0, 8.0, 9.0),
1403'M48': (52.0, 92.0, 8.0, 9.0),
1404'M56': (62.0,105.0,10.0, 11.0),
1405'M64': (70.0,115.0,10.0, 11.0)
1406}
1407
1408
1409# ISO 7092 definitions Plain washers - Small series
1410# d1_min, d2_max, h, h_max
1411iso7092def={
1412'M1.6':( 1.7, 3.5, 0.3, 0.35),
1413'M2': ( 2.2, 4.5, 0.3, 0.35),
1414'M2.5':( 2.7, 5.0, 0.5, 0.55),
1415'M3': ( 3.2, 6.0, 0.5, 0.55),
1416'M4': ( 4.3, 8.0, 0.5, 0.55),
1417'M5': ( 5.3, 9.0, 1.0, 1.10),
1418'M6': ( 6.4, 11.0, 1.6, 1.80),
1419'M8': ( 8.4, 15.0, 1.6, 1.80),
1420'M10': (10.5, 18.0, 1.6, 1.80),
1421'M12': (13.0, 20.0, 2.0, 2.20),
1422'M16': (17.0, 28.0, 2.5, 2.70),
1423'M20': (21.0, 34.0, 3.0, 3.30),
1424'M24': (25.0, 39.0, 4.0, 4.30),
1425'M30': (31.0, 50.0, 4.0, 4.30),
1426'M36': (37.0, 60.0, 5.0, 5.60)
1427}
1428
1429
1430
1431# ISO 7093-1 definitions Plain washers - Large series
1432# d1_min, d2_max, h, h_max
1433iso7093def={
1434'M3': ( 3.2, 9.0, 0.8, 0.90),
1435'(M3.5)':( 3.7, 11.0, 0.8, 0.90),
1436'M4': ( 4.3, 12.0, 1.0, 1.10),
1437'M5': ( 5.3, 15.0, 1.0, 1.10),
1438'M6': ( 6.4, 18.0, 1.6, 1.80),
1439'M8': ( 8.4, 24.0, 2.0, 2.20),
1440'M10': (10.5, 30.0, 2.5, 2.70),
1441'M12': (13.0, 37.0, 3.0, 3.30),
1442'(M14)': (15.0, 44.0, 3.0, 3.30),
1443'M16': (17.0, 50.0, 3.0, 3.30),
1444'(M18)': (19.0, 56.0, 4.0, 4.30),
1445'M20': (21.0, 60.0, 4.0, 4.30),
1446'(M22)': (23.0, 66.0, 5.0, 5.60),
1447'M24': (25.0, 72.0, 5.0, 5.60),
1448'(M27)': (30.0, 85.0, 6.0, 6.60),
1449'M30': (33.0, 92.0, 6.0, 6.60),
1450'(M33)': (36.0,105.0, 6.0, 6.60),
1451'M36': (39.0,110.0, 8.0, 9.00)
1452}
1453
1454
1455# ISO 7094 definitions Plain washers - Extra large series
1456# d1_min, d2_max, h, h_max
1457iso7094def={
1458'M5': ( 5.5, 18.0, 2.0, 2.3),
1459'M6': ( 6.6, 22.0, 2.0, 2.3),
1460'M8': ( 9.0, 28.0, 3.0, 3.6),
1461'M10': (11.0, 34.0, 3.0, 3.6),
1462'M12': (13.5, 44.0, 4.0, 4.6),
1463'(M14)': (15.5, 50.0, 4.0, 4.6),
1464'M16': (17.5, 56.0, 5.0, 6.0),
1465'(M18)': (20.0, 60.0, 5.0, 6.0),
1466'M20': (22.0, 72.0, 6.0, 7.0),
1467'(M22)': (24.0, 80.0, 6.0, 7.0),
1468'M24': (26.0, 85.0, 6.0, 7.0),
1469'(M27)': (30.0, 98.0, 6.0, 7.0),
1470'M30': (33.0,105.0, 6.0, 7.0),
1471'(M33)': (36.0,115.0, 8.0, 9.2),
1472'M36': (39.0,125.0, 8.0, 9.2)
1473}
1474
1475
1476
1477
1478# ISO 4757:1983 Definition of cross recess type H
1479# b, e_min, g, f_mean, r, t1, alpha, beta
1480iso4757def = {
1481'0': (0.61, 0.26, 0.81, 0.34, 0.3, 0.22, 138.0, 7.0 ),
1482'1': (0.97, 0.41, 1.27, 0.54, 0.5, 0.34, 138.0, 7.0 ),
1483'2': (1.47, 0.79, 2.29, 0.70, 0.6, 0.61, 140.0, 5.75),
1484'3': (2.41, 1.98, 3.81, 0.83, 0.8, 1.01, 146.0, 5.75),
1485'4': (3.48, 2.39, 5.08, 1.23, 1.0, 1.35, 153.0, 7.0 )
1486}
1487
1488# ISO 10664 Hexalobular internal driving feature for bolts and screws
1489# A, B, Re
1490iso10664def = {
1491'T6': ( 1.75, 1.205, 0.14),
1492'T8': ( 2.40, 1.67, 0.20),
1493'T10':( 2.80, 1.98, 0.24),
1494'T15':( 3.35, 2.35, 0.28),
1495'T20':( 3.95, 2.75, 0.32),
1496'T25':( 4.50, 3.16, 0.39),
1497'T30':( 5.60, 3.95, 0.46),
1498'T40':( 6.75, 4.76, 0.56),
1499'T45':( 7.93, 5.55, 0.59),
1500'T50':( 8.95, 6.36, 0.78),
1501'T55':(11.35, 7.92, 0.77),
1502'T60':(13.45, 9.48, 1.07),
1503'T70':(15.70, 11.08, 1.20),
1504'T80':(17.75, 12.64, 1.53),
1505'T90':(20.20, 14.22, 1.54),
1506'T100':(22.40,15.81, 1.73)
1507}
1508
1509
1510
1511# ISO 4032 Hex-head-nut
1512# P, c, damax, dw, e, m, mw, s_nom
1513iso4032def={
1514'M1.6': (0.35, 0.2, 1.84, 2.9, 3.4, 1.3, 0.8, 3.2),
1515'M2': (0.40, 0.2, 2.3, 3.7, 4.4, 1.6, 1.1, 4.0),
1516'M2.5': (0.45, 0.2, 2.9, 4.6, 5.5, 2.0, 1.4, 5.0),
1517'M3': (0.5, 0.2, 3.45, 5.2, 6.1, 2.4, 1.7, 5.5),
1518'(M3.5)':(0.6, 0.2, 4.00, 5.7, 6.6, 2.8, 2.0, 6.0),
1519'M4': (0.7, 0.2, 4.6, 6.6, 7.7, 3.2, 2.3, 7.0),
1520'M5': (0.8, 0.2, 5.75, 7.5, 8.9, 3.5, 3.5, 8.0),
1521'M6': (1.0, 0.2, 6.75, 9.5, 11.05, 4.7, 3.9, 10.0),
1522'M8': (1.25, 0.3, 8.75, 11.7, 14.5, 6.8, 5.2, 13.0),
1523'M10': (1.50, 0.3, 10.8, 14.7, 17.9, 8.4, 6.4, 16.0),
1524'M12': (1.75, 0.3, 13.0, 16.7, 20.1, 10.8, 8.3, 18.0),
1525'(M14)': (2.00, 0.3, 15.1, 20.5, 24.5, 12.8, 9.7, 22.0),
1526'M16': (2.00, 0.4, 17.3, 22.4, 26.9, 14.8, 11.3, 24.0),
1527'(M18)': (2.50, 0.4, 19.5, 24.9, 29.6, 15.8, 12.3, 27.0),
1528'M20': (2.50, 0.4, 21.6, 28.2, 33.7, 18.0, 13.5, 30.0),
1529'(M22)': (2.50, 0.4, 23.7, 31.4, 37.3, 19.4, 15.0, 34.0),
1530'M24': (3.00, 0.4, 25.9, 33.7, 40.1, 21.5, 16.2, 36.0),
1531'(M27)': (3.00, 0.4, 29.1, 38.0, 45.2, 23.8, 18.0, 41.0),
1532'M30': (3.50, 0.4, 32.4, 42.8, 50.9, 25.6, 19.4, 46.0),
1533'(M33)': (3.50, 0.4, 35.6, 46.6, 55.4, 28.7, 21.4, 50.0),
1534'M36': (4.00, 0.4, 38.9, 51.2, 61.0, 31.0, 23.5, 55.0),
1535'(M39)': (4.00, 0.5, 42.1, 55.9, 66.5, 33.4, 24.5, 60.0),
1536'M42': (4.50, 0.7, 45.4, 60.0, 71.3, 34.0, 25.9, 65.0),
1537'(M45)': (4.50, 0.7, 48.6, 64.7, 77.0, 36.0, 27.9, 70.0),
1538'M48': (5.00, 0.7, 51.8, 69.5, 82.6, 38.0, 29.1, 75.0),
1539'(M52)': (5.00, 0.7, 56.2, 74.5, 88.3, 42.0, 32.1, 80.0),
1540'M56': (5.50, 0.7, 60.5, 78.7, 93.6, 45.0, 34.7, 85.0),
1541'(M60)': (5.50, 0.7, 64.8, 82.7, 99.2, 48.0, 38.7, 90.0),
1542'M64': (6.00, 0.7, 69.1, 88.2,104.9, 51.0, 39.3, 95.0)
1543}
1544
1545
1546
1547# ISO 4033 Hexagon nuts style 2
1548# P, c, damax, dw, e, m, mw, s_nom
1549iso4033def={
1550'M5': (0.8, 0.2, 5.75, 7.5, 8.9, 5.1, 3.5, 8.0),
1551'M6': (1.0, 0.2, 6.75, 9.5, 11.05, 5.7, 3.9, 10.0),
1552'M8': (1.25, 0.3, 8.75, 11.7, 14.5, 7.5, 5.2, 13.0),
1553'M10': (1.50, 0.3, 10.8, 14.7, 17.9, 9.3, 6.4, 16.0),
1554'M12': (1.75, 0.3, 13.0, 16.7, 20.1, 12.0, 8.3, 18.0),
1555'(M14)': (2.00, 0.3, 15.1, 20.5, 24.5, 14.1, 9.7, 22.0),
1556'M16': (2.00, 0.4, 17.3, 22.4, 26.9, 16.4, 11.3, 24.0),
1557'M20': (2.50, 0.4, 21.6, 28.2, 33.7, 20.3, 13.5, 30.0),
1558'M24': (3.00, 0.4, 25.9, 33.7, 40.1, 23.9, 16.2, 36.0),
1559'M30': (3.50, 0.4, 32.4, 42.8, 50.9, 28.6, 19.4, 46.0),
1560'M36': (4.00, 0.4, 38.9, 51.2, 61.0, 33.1, 23.5, 55.0)
1561}
1562
1563# ISO 4035 Hexagon thin nuts, chamfered
1564# P, c, damax, dw, e, m, mw, s_nom
1565iso4035def={
1566'M1.6': (0.35, 0.2, 1.84, 2.9, 3.4, 1.0, 0.8, 3.2),
1567'M2': (0.40, 0.2, 2.3, 3.7, 4.4, 1.2, 1.1, 4.0),
1568'M2.5': (0.45, 0.2, 2.9, 4.6, 5.5, 1.6, 1.4, 5.0),
1569'M3': (0.5, 0.2, 3.45, 5.2, 6.1, 1.8, 1.7, 5.5),
1570'(M3.5)':(0.6, 0.2, 4.00, 5.7, 6.6, 2.0, 2.0, 6.0),
1571'M4': (0.7, 0.2, 4.6, 6.6, 7.7, 2.2, 2.3, 7.0),
1572'M5': (0.8, 0.2, 5.75, 7.5, 8.9, 2.7, 3.5, 8.0),
1573'M6': (1.0, 0.2, 6.75, 9.5, 11.05, 3.2, 3.9, 10.0),
1574'M8': (1.25, 0.3, 8.75, 11.7, 14.5, 4.0, 5.2, 13.0),
1575'M10': (1.50, 0.3, 10.8, 14.7, 17.9, 5.0, 6.4, 16.0),
1576'M12': (1.75, 0.3, 13.0, 16.7, 20.1, 6.0, 8.3, 18.0),
1577'(M14)': (2.00, 0.3, 15.1, 20.5, 24.5, 7.0, 9.7, 22.0),
1578'M16': (2.00, 0.4, 17.3, 22.4, 26.9, 8.0, 11.3, 24.0),
1579'(M18)': (2.50, 0.4, 19.5, 24.9, 29.6, 9.0, 12.3, 27.0),
1580'M20': (2.50, 0.4, 21.6, 28.2, 33.7, 10.0, 13.5, 30.0),
1581'(M22)': (2.50, 0.4, 23.7, 31.4, 37.3, 11.0, 15.0, 34.0),
1582'M24': (3.00, 0.4, 25.9, 33.7, 40.1, 12.0, 16.2, 36.0),
1583'(M27)': (3.00, 0.4, 29.1, 38.0, 45.2, 13.5, 18.0, 41.0),
1584'M30': (3.50, 0.4, 32.4, 42.8, 50.9, 15.0, 19.4, 46.0),
1585'(M33)': (3.50, 0.4, 35.6, 46.6, 55.4, 16.5, 21.4, 50.0),
1586'M36': (4.00, 0.4, 38.9, 51.2, 61.0, 18.0, 23.5, 55.0),
1587'(M39)': (4.00, 0.5, 42.1, 55.9, 66.5, 19.5, 24.5, 60.0),
1588'M42': (4.50, 0.7, 45.4, 60.0, 71.3, 21.0, 25.9, 65.0),
1589'(M45)': (4.50, 0.7, 48.6, 64.7, 77.0, 22.5, 27.9, 70.0),
1590'M48': (5.00, 0.7, 51.8, 69.5, 82.6, 24.0, 29.1, 75.0),
1591'(M52)': (5.00, 0.7, 56.2, 74.5, 88.3, 26.0, 32.1, 80.0),
1592'M56': (5.50, 0.7, 60.5, 78.7, 93.6, 28.0, 34.7, 85.0),
1593'(M60)': (5.50, 0.7, 64.8, 82.7, 99.2, 30.0, 38.7, 90.0),
1594'M64': (6.00, 0.7, 69.1, 88.2,104.9, 32.0, 39.3, 95.0)
1595}
1596
1597# ISO 4036 Hexagon thin nuts, unchamfered
1598# P, e, m, s_nom
1599iso4036def={
1600'M1.6': (0.35, 3.4, 1.0, 3.2),
1601'M2': (0.40, 4.4, 1.2, 4.0),
1602'M2.5': (0.45, 5.5, 1.6, 5.0),
1603'M3': (0.5, 6.1, 1.8, 5.5),
1604'(M3.5)':(0.6, 6.6, 2.0, 6.0),
1605'M4': (0.7, 7.7, 2.2, 7.0),
1606'M5': (0.8, 8.9, 2.7, 8.0),
1607'M6': (1.0, 10.9, 3.2, 10.0),
1608'M8': (1.25, 14.5, 4.0, 13.0),
1609'M10': (1.50, 17.9, 5.0, 16.0)}
1610
1611# EN 1661 Hexagon nuts with flange
1612# P, damax, c, dc, dw, e, m, mw, r, s
1613en1661def={
1614'M5' :(0.80, 5.75, 1.0, 11.8, 9.8, 8.79, 5.0, 2.5, 0.30, 8.0),
1615'M6' :(1.00, 6.75, 1.1, 14.2, 12.2, 11.05, 6.0, 3.1, 0.36, 10.0),
1616'M8' :(1.25, 8.75, 1.2, 17.9, 15.8, 14.38, 8.0, 4.6, 0.48, 13.0),
1617'M10' :(1.50, 10.80, 1.5, 21.8, 19.6, 17.77, 10.0, 5.9, 0.60, 16.0),
1618'M12' :(1.75, 13.00, 1.8, 26.0, 23.8, 20.03, 12.0, 6.8, 0.72, 18.0),
1619'(M14)':(2.00, 15.10, 2.1, 29.9, 27.6, 23.36, 14.0, 7.7, 0.88, 21.0),
1620'M16' :(2.00, 17.30, 2.4, 34.5, 31.9, 26.75, 16.0, 8.9, 0.96, 24.0),
1621'M20' :(2.50, 21.60, 3.0, 42.8, 39.9, 33.23, 20.0,10.7, 1.20, 30.0)}
1622
1623# Tuning table to get valid shapes
1624# P, tunIn, tunEx
1625tuningTable={
1626'M1.6':(0.35, 516, 516),
1627'M2': (0.40, 515, 516),
1628'M2.5':(0.45, 515, 515),
1629'M3': (0.5, 480, 502),
1630'(M3.5)':(0.6, 480, 502),
1631'M4': (0.7, 510, 519), #last value needed for ISO7380
1632'M5': (0.8, 510, 510),
1633'M6': (1.0, 515, 515),
1634'M8': (1.25, 516, 516),
1635'M10': (1.50, 515, 515),
1636'M12': (1.75, 513, 513),
1637'(M14)': (2.00, 513, 513),
1638'M16': (2.00, 513, 513),
1639'M20': (2.50, 513, 513),
1640'M24': (3.00, 513, 513),
1641'(M27)': (3.00, 513, 513),
1642'M30': (3.50, 513, 513),
1643'(M33)': (3.50, 513, 513),
1644'M36': (4.00, 513, 513),
1645'M42': (4.50, 515, 515),
1646'(M45)': (4.50, 515, 515),
1647'M48': (5.00, 515, 505), # ISO4014: 505, 502 or 488; ISO4017: above 505
1648'(M52)': (5.00, 508, 508),
1649'M56': (5.50, 508, 508),
1650'(M60)': (5.50, 508, 508),
1651'M64': (6.00, 489, 489) # Nut ISO4032: 489
1652}
1653
1654
1655def equal_vertex(vert1, vert2, p=5):
1656# compares two vertices
1657return (round(vert1.X - vert2.X,p)==0 and round(vert1.Y - vert2.Y,p)==0 and round(vert1.Z - vert2.Z,p)==0)
1658
1659try:
1660_fromUtf8 = QtCore.QString.fromUtf8
1661except AttributeError:
1662_fromUtf8 = lambda s: s
1663
1664class Ui_ScrewMaker(object):
1665def setupUi(self, ScrewMaker):
1666FCUi = FreeCADGui.UiLoader()
1667
1668ScrewMaker.setObjectName(_fromUtf8("ScrewMaker"))
1669ScrewMaker.resize(450, 362)
1670ScrewMaker.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedKingdom))
1671self.layoutWidget = QtGui.QWidget(ScrewMaker)
1672self.layoutWidget.setGeometry(QtCore.QRect(348, 35, 102, 161))
1673self.layoutWidget.setObjectName(_fromUtf8("layoutWidget"))
1674self.verticalLayout_2 = QtGui.QVBoxLayout(self.layoutWidget)
1675#self.verticalLayout_2.setMargin(0)
1676self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
1677self.ScrewTypeLabel = QtGui.QLabel(self.layoutWidget)
1678self.ScrewTypeLabel.setObjectName(_fromUtf8("ScrewTypeLabel"))
1679self.verticalLayout_2.addWidget(self.ScrewTypeLabel)
1680self.NomDiaLabel = QtGui.QLabel(self.layoutWidget)
1681self.NomDiaLabel.setObjectName(_fromUtf8("NomDiaLabel"))
1682self.verticalLayout_2.addWidget(self.NomDiaLabel)
1683self.NomLenLabel = QtGui.QLabel(self.layoutWidget)
1684self.NomLenLabel.setObjectName(_fromUtf8("NomLenLabel"))
1685self.verticalLayout_2.addWidget(self.NomLenLabel)
1686self.UserLenLabel = QtGui.QLabel(self.layoutWidget)
1687self.UserLenLabel.setObjectName(_fromUtf8("UserLenLabel"))
1688self.verticalLayout_2.addWidget(self.UserLenLabel)
1689
1690self.layoutWidget1 = QtGui.QWidget(ScrewMaker)
1691self.layoutWidget1.setGeometry(QtCore.QRect(3, 35, 350, 166))
1692#self.layoutWidget1.setGeometry(QtCore.QRect(10, 5, 315, 200))
1693self.layoutWidget1.setObjectName(_fromUtf8("layoutWidget1"))
1694self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget1)
1695#self.verticalLayout.setMargin(0)
1696self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
1697self.ScrewType = QtGui.QComboBox(self.layoutWidget1)
1698self.ScrewType.setObjectName(_fromUtf8("ScrewType"))
1699for i in range(33):
1700self.ScrewType.addItem(_fromUtf8("")) # 0
1701
1702self.verticalLayout.addWidget(self.ScrewType)
1703self.NominalDiameter = QtGui.QComboBox(self.layoutWidget1)
1704self.NominalDiameter.setObjectName(_fromUtf8("NominalDiameter"))
1705for i in range(52):
1706self.NominalDiameter.addItem(_fromUtf8("")) # 0
1707
1708self.verticalLayout.addWidget(self.NominalDiameter)
1709self.NominalLength = QtGui.QComboBox(self.layoutWidget1)
1710self.NominalLength.setObjectName(_fromUtf8("NominalLength"))
1711for i in range(48):
1712self.NominalLength.addItem(_fromUtf8("")) #0
1713
1714self.verticalLayout.addWidget(self.NominalLength)
1715#self.UserLen = QtGui.QComboBox(self.layoutWidget1)
1716self.UserLen = FCUi.createWidget("Gui::InputField")
1717self.UserLen.setObjectName(_fromUtf8("UserLen"))
1718#self.UserLen.addItem(_fromUtf8(""))
1719self.UserLen.setProperty("text", "0 mm")
1720self.verticalLayout.addWidget(self.UserLen)
1721
1722#self.CommentLabel = QtGui.QLabel(self.layoutWidget)
1723self.CommentLabel = QtGui.QLabel(ScrewMaker)
1724self.CommentLabel.setObjectName(_fromUtf8("CommentLabel"))
1725self.CommentLabel.setGeometry(QtCore.QRect(10, 184, 411, 21))
1726#self.verticalLayout.addWidget(self.CommentLabel)
1727
1728self.layoutWidget2 = QtGui.QWidget(ScrewMaker)
1729#self.layoutWidget2.setGeometry(QtCore.QRect(10, 200, 321, 83))
1730self.layoutWidget2.setGeometry(QtCore.QRect(3, 200, 321, 120))
1731self.layoutWidget2.setObjectName(_fromUtf8("layoutWidget2"))
1732self.verticalLayout_3 = QtGui.QVBoxLayout(self.layoutWidget2)
1733#self.verticalLayout_3.setMargin(0)
1734self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
1735self.SimpleScrew = QtGui.QRadioButton(self.layoutWidget2)
1736self.SimpleScrew.setChecked(True)
1737self.SimpleScrew.setObjectName(_fromUtf8("SimpleScrew"))
1738self.verticalLayout_3.addWidget(self.SimpleScrew)
1739self.SymbolThread = QtGui.QRadioButton(self.layoutWidget2)
1740self.SymbolThread.setObjectName(_fromUtf8("SymbolThread"))
1741self.verticalLayout_3.addWidget(self.SymbolThread)
1742self.RealThread = QtGui.QRadioButton(self.layoutWidget2)
1743self.RealThread.setObjectName(_fromUtf8("RealThread"))
1744self.verticalLayout_3.addWidget(self.RealThread)
1745self.MessageLabel = QtGui.QLabel(ScrewMaker)
1746self.MessageLabel.setGeometry(QtCore.QRect(10, 10, 411, 21))
1747self.MessageLabel.setProperty("Empty_text", _fromUtf8(""))
1748self.MessageLabel.setObjectName(_fromUtf8("MessageLabel"))
1749self.CreateButton = QtGui.QToolButton(ScrewMaker)
1750self.CreateButton.setGeometry(QtCore.QRect(180, 320, 111, 26))
1751self.CreateButton.setObjectName(_fromUtf8("CreateButton"))
1752self.ScrewAvailable = True
1753
1754self.simpThread = self.SimpleScrew.isChecked()
1755self.symThread = self.SymbolThread.isChecked()
1756self.rThread = self.RealThread.isChecked()
1757
1758self.theScrew = Screw()
1759
1760self.retranslateUi(ScrewMaker)
1761self.NominalDiameter.setCurrentIndex(5)
1762self.NominalLength.setCurrentIndex(9)
1763QtCore.QObject.connect(self.ScrewType, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")), self.guiCheck_Data)
1764QtCore.QObject.connect(self.CreateButton, QtCore.SIGNAL(_fromUtf8("pressed()")), self.guiCreateScrew)
1765QtCore.QObject.connect(self.NominalDiameter, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")), self.guiCheck_Data)
1766QtCore.QObject.connect(self.NominalLength, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")), self.guiCheck_Data)
1767QtCore.QMetaObject.connectSlotsByName(ScrewMaker)
1768
1769def retranslateUi(self, ScrewMaker):
1770ScrewMaker.setWindowTitle(tr('ScrewMaker', 'Screw-Maker 2.2'))
1771self.ScrewTypeLabel.setText(tr('ScrewMaker', 'Type of Screw'))
1772self.NomDiaLabel.setText(tr('ScrewMaker', 'Nomimal\nDiameter'))
1773self.NomLenLabel.setText(tr('ScrewMaker', 'Nominal\nLength'))
1774self.UserLenLabel.setText(tr('ScrewMaker', 'User length \nfor screw-tap'))
1775self.CommentLabel.setText(tr('ScrewMaker', 'Values in brackets are not recommended!'))
1776self.ScrewType.setItemText(0, tr('ScrewMaker', 'ISO4017: Hexagon head screws'))
1777self.ScrewType.setItemText(1, tr('ScrewMaker', 'ISO4014: Hexagon head bolts'))
1778self.ScrewType.setItemText(2, tr('ScrewMaker', 'EN1662: Hexagon bolts with flange, small\n series'))
1779self.ScrewType.setItemText(3, tr('ScrewMaker', 'EN1665: Hexagon bolts with flange, heavy\n series'))
1780self.ScrewType.setItemText(4, tr('ScrewMaker', 'ISO8676: Hexagon head screw with\n metric fine pitch thread'))
1781self.ScrewType.setItemText(5, tr('ScrewMaker', 'ISO4762: Hexagon socket head cap screws'))
1782self.ScrewType.setItemText(6, tr('ScrewMaker', 'ISO7380-1: Hexagon socket button head\n screws'))
1783self.ScrewType.setItemText(7, tr('ScrewMaker', 'ISO7380-2: Hexagon socket button head\n screws with collar'))
1784self.ScrewType.setItemText(8, tr('ScrewMaker', 'DIN967: Cross recessed pan head screws\n with collar'))
1785self.ScrewType.setItemText(9, tr('ScrewMaker', 'ISO10642: Hexagon socket countersunk \n head screws'))
1786self.ScrewType.setItemText(10, tr('ScrewMaker', 'ISO2009: Slotted countersunk flat head\n screws'))
1787self.ScrewType.setItemText(11, tr('ScrewMaker', 'ISO2010: Slotted raised countersunk head\n screws'))
1788self.ScrewType.setItemText(12, tr('ScrewMaker', 'ISO1207: Slotted cheese head screws'))
1789self.ScrewType.setItemText(13, tr('ScrewMaker', 'ISO1580: Slotted pan head screws'))
1790self.ScrewType.setItemText(14, tr('ScrewMaker', 'ISO7045: Pan head screws, type H cross recess'))
1791self.ScrewType.setItemText(15, tr('ScrewMaker', 'ISO7046: Countersunk flat head screws\n H cross recess'))
1792self.ScrewType.setItemText(16, tr('ScrewMaker', 'ISO7047: Raised countersunk head screws\n H cross recess'))
1793self.ScrewType.setItemText(17, tr('ScrewMaker', 'ISO7048: Cheese head screws type H cross recess'))
1794self.ScrewType.setItemText(18, tr('ScrewMaker', 'ISO14579: Hexalobular socket head cap screws'))
1795self.ScrewType.setItemText(19, tr('ScrewMaker', 'ISO14580: Hexalobular socket cheese head\n screws'))
1796self.ScrewType.setItemText(20, tr('ScrewMaker', 'ISO14583: Hexalobular socket pan head screws'))
1797self.ScrewType.setItemText(21, tr('ScrewMaker', 'ISO14582: Hexalobular socket countersunk\n head screws, high head'))
1798self.ScrewType.setItemText(22, tr('ScrewMaker', 'ISO14584: Hexalobular socket raised\n countersunk head screws'))
1799self.ScrewType.setItemText(23, tr('ScrewMaker', 'ISO7089: Plain washers - Normal series'))
1800self.ScrewType.setItemText(24, tr('ScrewMaker', 'ISO7090: Plain washers, chamfered - Normal series'))
1801self.ScrewType.setItemText(25, tr('ScrewMaker', 'ISO7092: Plain washers - Small series'))
1802self.ScrewType.setItemText(26, tr('ScrewMaker', 'ISO7093-1: Plain washer - Large series'))
1803self.ScrewType.setItemText(27, tr('ScrewMaker', 'ISO7094: Plain washers - Extra large series'))
1804self.ScrewType.setItemText(28, tr('ScrewMaker', 'ISO4032: Hexagon nuts, Style 1'))
1805self.ScrewType.setItemText(29, tr('ScrewMaker', 'ISO4033: Hexagon nuts, Style 2'))
1806self.ScrewType.setItemText(30, tr('ScrewMaker', 'ISO4035: Hexagon thin nuts, chamfered'))
1807self.ScrewType.setItemText(31, tr('ScrewMaker', 'EN1661: Hexagon nuts with flange'))
1808self.ScrewType.setItemText(32, tr('ScrewMaker', 'ScrewTap: ISO Screw-Tap'))
1809
1810self.NominalDiameter.setItemText(0, tr('ScrewMaker', 'M1.6'))
1811self.NominalDiameter.setItemText(1, tr('ScrewMaker', 'M2'))
1812self.NominalDiameter.setItemText(2, tr('ScrewMaker', 'M2.5'))
1813self.NominalDiameter.setItemText(3, tr('ScrewMaker', 'M3'))
1814self.NominalDiameter.setItemText(4, tr('ScrewMaker', '(M3.5)'))
1815self.NominalDiameter.setItemText(5, tr('ScrewMaker', 'M4'))
1816self.NominalDiameter.setItemText(6, tr('ScrewMaker', 'M5'))
1817self.NominalDiameter.setItemText(7, tr('ScrewMaker', 'M6'))
1818self.NominalDiameter.setItemText(8, tr('ScrewMaker', 'M8'))
1819self.NominalDiameter.setItemText(9, tr('ScrewMaker', 'M10'))
1820self.NominalDiameter.setItemText(10, tr('ScrewMaker', 'M12'))
1821self.NominalDiameter.setItemText(11, tr('ScrewMaker', '(M14)'))
1822self.NominalDiameter.setItemText(12, tr('ScrewMaker', 'M16'))
1823self.NominalDiameter.setItemText(13, tr('ScrewMaker', '(M18)'))
1824self.NominalDiameter.setItemText(14, tr('ScrewMaker', 'M20'))
1825self.NominalDiameter.setItemText(15, tr('ScrewMaker', '(M22)'))
1826self.NominalDiameter.setItemText(16, tr('ScrewMaker', 'M24'))
1827self.NominalDiameter.setItemText(17, tr('ScrewMaker', '(M27)'))
1828self.NominalDiameter.setItemText(18, tr('ScrewMaker', 'M30'))
1829self.NominalDiameter.setItemText(19, tr('ScrewMaker', 'M36'))
1830self.NominalDiameter.setItemText(20, tr('ScrewMaker', '(M33)'))
1831self.NominalDiameter.setItemText(21, tr('ScrewMaker', 'M42'))
1832self.NominalDiameter.setItemText(22, tr('ScrewMaker', '(M45)'))
1833self.NominalDiameter.setItemText(23, tr('ScrewMaker', 'M48'))
1834self.NominalDiameter.setItemText(24, tr('ScrewMaker', '(M52)'))
1835self.NominalDiameter.setItemText(25, tr('ScrewMaker', 'M54'))
1836self.NominalDiameter.setItemText(26, tr('ScrewMaker', '(M60)'))
1837self.NominalDiameter.setItemText(27, tr('ScrewMaker', 'M64'))
1838
1839self.NominalDiameter.setItemText(28, tr('ScrewMaker', 'M8x1'))
1840self.NominalDiameter.setItemText(29, tr('ScrewMaker', 'M10x1'))
1841self.NominalDiameter.setItemText(30, tr('ScrewMaker', '(M10x1.25)'))
1842self.NominalDiameter.setItemText(31, tr('ScrewMaker', 'M12x1.5'))
1843self.NominalDiameter.setItemText(32, tr('ScrewMaker', '(M12x1.25)'))
1844self.NominalDiameter.setItemText(33, tr('ScrewMaker', '(M14x1.5)'))
1845self.NominalDiameter.setItemText(34, tr('ScrewMaker', 'M16x1.5'))
1846self.NominalDiameter.setItemText(35, tr('ScrewMaker', '(M18x1.5)'))
1847self.NominalDiameter.setItemText(36, tr('ScrewMaker', 'M20x1.5'))
1848self.NominalDiameter.setItemText(37, tr('ScrewMaker', '(M20x2)'))
1849self.NominalDiameter.setItemText(38, tr('ScrewMaker', '(M22x1.5)'))
1850self.NominalDiameter.setItemText(39, tr('ScrewMaker', 'M24x2'))
1851self.NominalDiameter.setItemText(40, tr('ScrewMaker', '(M27x2)'))
1852self.NominalDiameter.setItemText(41, tr('ScrewMaker', 'M30x2'))
1853self.NominalDiameter.setItemText(42, tr('ScrewMaker', '(M33x2)'))
1854self.NominalDiameter.setItemText(43, tr('ScrewMaker', 'M36x3'))
1855self.NominalDiameter.setItemText(44, tr('ScrewMaker', '(M39x3)'))
1856self.NominalDiameter.setItemText(45, tr('ScrewMaker', 'M42x3'))
1857self.NominalDiameter.setItemText(46, tr('ScrewMaker', '(M45x3)'))
1858self.NominalDiameter.setItemText(47, tr('ScrewMaker', 'M48x3'))
1859self.NominalDiameter.setItemText(48, tr('ScrewMaker', '(M52x4)'))
1860self.NominalDiameter.setItemText(49, tr('ScrewMaker', 'M56x4'))
1861self.NominalDiameter.setItemText(50, tr('ScrewMaker', '(M60x4)'))
1862self.NominalDiameter.setItemText(51, tr('ScrewMaker', 'M64x4'))
1863
1864self.NominalLength.setItemText(0, tr('ScrewMaker', '2'))
1865self.NominalLength.setItemText(1, tr('ScrewMaker', '2.5'))
1866self.NominalLength.setItemText(2, tr('ScrewMaker', '3'))
1867self.NominalLength.setItemText(3, tr('ScrewMaker', '4'))
1868self.NominalLength.setItemText(4, tr('ScrewMaker', '5'))
1869self.NominalLength.setItemText(5, tr('ScrewMaker', '6'))
1870self.NominalLength.setItemText(6, tr('ScrewMaker', '8'))
1871self.NominalLength.setItemText(7, tr('ScrewMaker', '10'))
1872self.NominalLength.setItemText(8, tr('ScrewMaker', '12'))
1873self.NominalLength.setItemText(9, tr('ScrewMaker', '16'))
1874self.NominalLength.setItemText(10, tr('ScrewMaker', '20'))
1875self.NominalLength.setItemText(11, tr('ScrewMaker', '25'))
1876self.NominalLength.setItemText(12, tr('ScrewMaker', '30'))
1877self.NominalLength.setItemText(13, tr('ScrewMaker', '35'))
1878self.NominalLength.setItemText(14, tr('ScrewMaker', '40'))
1879self.NominalLength.setItemText(15, tr('ScrewMaker', '45'))
1880self.NominalLength.setItemText(16, tr('ScrewMaker', '50'))
1881self.NominalLength.setItemText(17, tr('ScrewMaker', '55'))
1882self.NominalLength.setItemText(18, tr('ScrewMaker', '60'))
1883self.NominalLength.setItemText(19, tr('ScrewMaker', '65'))
1884self.NominalLength.setItemText(20, tr('ScrewMaker', '70'))
1885self.NominalLength.setItemText(21, tr('ScrewMaker', '80'))
1886self.NominalLength.setItemText(22, tr('ScrewMaker', '90'))
1887self.NominalLength.setItemText(23, tr('ScrewMaker', '100'))
1888self.NominalLength.setItemText(24, tr('ScrewMaker', '110'))
1889self.NominalLength.setItemText(25, tr('ScrewMaker', '120'))
1890self.NominalLength.setItemText(26, tr('ScrewMaker', '130'))
1891self.NominalLength.setItemText(27, tr('ScrewMaker', '140'))
1892self.NominalLength.setItemText(28, tr('ScrewMaker', '150'))
1893self.NominalLength.setItemText(29, tr('ScrewMaker', '160'))
1894self.NominalLength.setItemText(30, tr('ScrewMaker', '180'))
1895self.NominalLength.setItemText(31, tr('ScrewMaker', '200'))
1896self.NominalLength.setItemText(32, tr('ScrewMaker', '220'))
1897self.NominalLength.setItemText(33, tr('ScrewMaker', '240'))
1898self.NominalLength.setItemText(34, tr('ScrewMaker', '260'))
1899self.NominalLength.setItemText(35, tr('ScrewMaker', '280'))
1900self.NominalLength.setItemText(36, tr('ScrewMaker', '300'))
1901self.NominalLength.setItemText(37, tr('ScrewMaker', '320'))
1902self.NominalLength.setItemText(38, tr('ScrewMaker', '340'))
1903self.NominalLength.setItemText(39, tr('ScrewMaker', '360'))
1904self.NominalLength.setItemText(40, tr('ScrewMaker', '380'))
1905self.NominalLength.setItemText(41, tr('ScrewMaker', '400'))
1906self.NominalLength.setItemText(42, tr('ScrewMaker', '420'))
1907self.NominalLength.setItemText(43, tr('ScrewMaker', '440'))
1908self.NominalLength.setItemText(44, tr('ScrewMaker', '460'))
1909self.NominalLength.setItemText(45, tr('ScrewMaker', '480'))
1910self.NominalLength.setItemText(46, tr('ScrewMaker', '500'))
1911self.NominalLength.setItemText(47, tr('ScrewMaker', 'User'))
1912#self.UserLen.setItemText(0, tr('ScrewMaker', 'regular pitch'))
1913self.SimpleScrew.setText(tr('ScrewMaker', 'Simple Screw (no thread at all!)'))
1914self.SymbolThread.setText(tr('ScrewMaker', 'Symbol Thread (not implemented yet)'))
1915self.RealThread.setText(tr('ScrewMaker', 'Real Thread (takes time, memory intensive)\nMay not work for all screws!'))
1916self.MessageLabel.setText(tr('ScrewMaker', 'Select your screw type'))
1917self.MessageLabel.setProperty('Errortext', tr('ScrewMaker', 'Combination not implemented'))
1918self.MessageLabel.setProperty('OK_text', tr('ScrewMaker', 'Screw is made'))
1919self.CreateButton.setText(tr('ScrewMaker', 'create'))
1920
1921def guiCheck_Data(self):
1922ST_text = str(self.ScrewType.currentText())
1923ST_text = ST_text.split(':')[0]
1924ND_text = str(self.NominalDiameter.currentText())
1925NL_text = str(self.NominalLength.currentText())
1926M_text, self.ScrewAvailable = self.theScrew.check_Data(ST_text, ND_text, NL_text)
1927self.MessageLabel.setText(tr('ScrewMaker', M_text))
1928
1929def guiCreateScrew(self):
1930#self.simpThread = self.SimpleScrew.isChecked()
1931#self.symThread = self.SymbolThread.isChecked()
1932#self.rThread = self.RealThread.isChecked()
1933if self.SimpleScrew.isChecked():
1934threadType = 'simple'
1935if self.SymbolThread.isChecked():
1936threadType = 'symbol'
1937if self.RealThread.isChecked():
1938threadType = 'real'
1939
1940ND_text = str(self.NominalDiameter.currentText())
1941NL_text = str(self.NominalLength.currentText())
1942ST_text = str(self.ScrewType.currentText())
1943ST_text = ST_text.split(':')[0]
1944
1945if (ST_text == 'ScrewTap') or (ST_text == 'ISO8676'):
1946if NL_text == 'User':
1947textValue = self.UserLen.property("text")
1948stLength = FreeCAD.Units.parseQuantity(textValue).Value
1949NL_text = str(stLength)
1950
1951myObj = self.theScrew.createScrew(ST_text, ND_text, NL_text, threadType)
1952
1953
1954def get_diameter(thread_type):
1955"""Return the screw diameter as float
1956
1957Accepted input format are e.g. 'M5', 'M8x1', '(M3.5)', '(M10x1.25)'.
1958"""
1959thread_string = thread_type.lstrip('(M').rstrip(')')
1960dia = float(thread_string.split('x')[0])
1961return dia
1962
1963
1964class Screw(object):
1965def __init__(self):
1966self.objAvailable = True
1967self.Tuner = 510
1968testCirc=Part.makeCircle(2.0,Base.Vector(0.0,0.0,-0.0),Base.Vector(0.0,0.0,-1.0))
1969testDisk = Part.Face(Part.Wire(testCirc))
1970z = testDisk.Surface.Axis.z
1971if z > 0:
1972self.circleAxis = Base.Vector(0.0,0.0,1.0)
1973else:
1974self.circleAxis = Base.Vector(0.0,0.0,-1.0)
1975
1976def check_Data(self, ST_text, ND_text, NL_text):
1977#FreeCAD.Console.PrintMessage("Data checking" + NL_text + "\n")
1978#set screw not ok
1979self.objAvailable = False
1980M_text = "Select your screw type"
1981Type_text = ''
1982if ST_text == 'ISO4017':
1983table = iso4017head
1984tab_len = iso4017length
1985tab_range = iso4017range
1986Type_text = 'Screw'
1987
1988if ST_text == 'EN1662':
1989table = en1662def
1990tab_len = en1662length
1991tab_range = en1662range
1992Type_text = 'Screw'
1993
1994if ST_text == 'EN1665':
1995table = en1665def
1996tab_len = en1665length
1997tab_range = en1665range
1998Type_text = 'Screw'
1999
2000if ST_text == 'ISO8676':
2001table = iso8676def
2002tab_len = iso8676length
2003tab_range = iso8676range
2004Type_text = 'Screw'
2005
2006if ST_text == 'ISO2009':
2007table = iso2009def
2008tab_len = iso2009length
2009tab_range = iso2009range
2010Type_text = 'Screw'
2011if ST_text == 'ISO2010':
2012table = iso2009def
2013tab_len = iso2009length
2014tab_range = iso2009range
2015Type_text = 'Screw'
2016if ST_text == 'ISO4762':
2017table = iso4762def
2018tab_len = iso4762length
2019tab_range = iso4762range
2020Type_text = 'Screw'
2021
2022if ST_text == 'ISO10642':
2023table = iso10642def
2024tab_len = iso10642length
2025tab_range = iso10642range
2026Type_text = 'Screw'
2027
2028if ST_text == 'ISO4014':
2029table = iso4014head
2030tab_len = iso4014length
2031tab_range = iso4014range
2032Type_text = 'Screw'
2033
2034if ST_text == 'ISO1207':
2035table = iso1207def
2036tab_len = iso1207length
2037tab_range = iso1207range
2038Type_text = 'Screw'
2039if ST_text == 'ISO1580':
2040table = iso1580def
2041tab_len = iso2009length
2042tab_range = iso2009range
2043Type_text = 'Screw'
2044
2045if ST_text == 'ISO7045':
2046table = iso7045def
2047tab_len = iso7045length
2048tab_range = iso7045range
2049Type_text = 'Screw'
2050
2051if ST_text == 'ISO7046':
2052table = iso7046def # contains only cross recess data
2053tab_len = iso7045length
2054tab_range = iso7046range
2055Type_text = 'Screw'
2056
2057if ST_text == 'ISO7047':
2058table = iso2009def
2059tab_len = iso7045length
2060tab_range = iso7046range
2061Type_text = 'Screw'
2062
2063if ST_text == 'ISO7048':
2064table = iso7048def
2065tab_len = iso7048length
2066tab_range = iso7048range
2067Type_text = 'Screw'
2068
2069if ST_text == 'ISO7380-1':
2070table = iso7380def
2071tab_len = iso7380length
2072tab_range = iso7380range
2073Type_text = 'Screw'
2074
2075if ST_text == 'ISO7380-2':
2076table = iso7380_2def
2077tab_len = iso7380length
2078tab_range = iso7380range
2079Type_text = 'Screw'
2080
2081if ST_text == 'DIN967':
2082table = din967def
2083tab_len = din967length
2084tab_range = din967range
2085Type_text = 'Screw'
2086
2087if ST_text == 'ISO14579':
2088table = iso14579def
2089tab_len = iso14579length
2090tab_range = iso14579range
2091Type_text = 'Screw'
2092
2093if ST_text == 'ISO14580':
2094table = iso14580def
2095tab_len = iso14580length
2096tab_range = iso1207range
2097Type_text = 'Screw'
2098
2099if ST_text == 'ISO14583':
2100table = iso14583def
2101tab_len = iso7045length
2102tab_range = iso7046range
2103Type_text = 'Screw'
2104
2105if ST_text == 'ISO14584':
2106table = iso14584def
2107tab_len = iso7045length
2108tab_range = iso14584range
2109Type_text = 'Screw'
2110
2111if ST_text == 'ISO14582':
2112table = iso14582def
2113tab_len = iso14582length
2114tab_range = iso14582range
2115Type_text = 'Screw'
2116
2117if ST_text == 'ISO7089':
2118table = iso7089def
2119Type_text = 'Washer'
2120
2121if ST_text == 'ISO7090':
2122table = iso7090def
2123Type_text = 'Washer'
2124
2125if ST_text == 'ISO7091':
2126table = iso7091def
2127Type_text = 'Washer'
2128
2129if ST_text == 'ISO7092':
2130table = iso7092def
2131Type_text = 'Washer'
2132
2133if ST_text == 'ISO7093-1':
2134table = iso7093def
2135Type_text = 'Washer'
2136
2137if ST_text == 'ISO7094':
2138table = iso7094def
2139Type_text = 'Washer'
2140
2141if ST_text == 'ISO4032':
2142table = iso4032def
2143Type_text = 'Nut'
2144
2145if ST_text == 'ISO4033':
2146table = iso4033def
2147Type_text = 'Nut'
2148
2149if ST_text == 'ISO4035':
2150table = iso4035def
2151Type_text = 'Nut'
2152
2153if ST_text == 'ISO4036':
2154table = iso4036def
2155Type_text = 'Nut'
2156
2157if ST_text == 'EN1661':
2158table = en1661def
2159Type_text = 'Nut'
2160
2161if ST_text == 'ScrewTap':
2162table = tuningTable
2163Type_text = 'Screw-Tap'
2164
2165if ND_text not in table:
2166ND_min, ND_max = standard_diameters[ST_text]
2167M_text = ST_text+' has diameters from '+ ND_min +' to ' + ND_max + ' and not ' + ND_text +'!'
2168self.objAvailable = False
2169# set scew not ok
2170else:
2171if Type_text == 'Screw':
2172#NL_text = str(self.NominalLength.currentText())
2173NL_min, NL_max = tab_range[ND_text]
2174NL_min_float = float(NL_min)
2175NL_max_float = float(NL_max)
2176if (NL_text == 'User') and (ST_text != 'ISO8676'):
2177M_text = 'User length is only available for the screw-tab and ISO 8676!'
2178self.objAvailable = False
2179else:
2180if NL_text == 'User':
2181M_text = 'ISO 8676 with user length is ok!'
2182self.objAvailable = True
2183else:
2184NL_text_float = float(NL_text)
2185if (NL_text_float<NL_min_float)or(NL_text_float>NL_max_float)or(NL_text not in tab_len):
2186if '(' in ND_text:
2187ND_text = ND_text.lstrip('(').rstrip(')')
2188M_text = ST_text+'-'+ ND_text +' has lengths from '+ NL_min +' to ' + NL_max + ' and not ' + NL_text +'!'
2189self.objAvailable = False
2190# set screw not ok
2191else:
2192if '(' in ND_text:
2193ND_text = ND_text.lstrip('(').rstrip(')')
2194M_text = ST_text+'-'+ ND_text +'x'+ NL_text +' is in library available! '
2195self.objAvailable = True
2196#set screw ok
2197else: # Washers and Nuts
2198if Type_text != 'Screw-Tap':
2199if '(' in ND_text:
2200ND_text = ND_text.lstrip('(').rstrip(')')
2201M_text = ST_text+'-'+ ND_text +' is available in library!'
2202self.objAvailable = True
2203#set washer/nut ok
2204else:
2205if NL_text == 'User':
2206M_text = 'Screw-tab with user length is ok!'
2207self.objAvailable = True
2208else:
2209#NL_text = str(self.NominalLength.currentText())
2210if '(' in ND_text:
2211ND_text = ND_text.lstrip('(').rstrip(')')
2212M_text = ST_text+'-'+ ND_text +' with '+ NL_text +'mm length is available in library!'
2213self.objAvailable = True
2214#set screwTap ok
2215
2216#print "Data checking: ", self.NominalLength.currentText(), "\n"
2217#FreeCAD.Console.PrintMessage("Set Check_result into text " + str(self.objAvailable) + M_text + "\n")
2218return M_text, self.objAvailable
2219
2220
2221def createScrew(self, ST_text, ND_text, NL_text, threadType):
2222#self.simpThread = self.SimpleScrew.isChecked()
2223#self.symThread = self.SymbolThread.isChecked()
2224#self.rThread = self.RealThread.isChecked()
2225if threadType == 'real':
2226self.rThread = True
2227else:
2228self.rThread = False
2229
2230if self.objAvailable:
2231try:
2232# first we check if valid numbers have been entered
2233#FreeCAD.Console.PrintMessage("NominalLength: " + self.NominalLength.currentText() + "\n")
2234#FreeCAD.Console.PrintMessage("NominalDiameter: " + self.NominalDiameter.currentText() + "\n")
2235#FreeCAD.Console.PrintMessage("SimpleThread: " + str(self.SimpleScrew.isChecked()) + "\n")
2236#FreeCAD.Console.PrintMessage("SymbolThread: " + str(self.SymbolThread.isChecked()) + "\n")
2237#FreeCAD.Console.PrintMessage("RealThread: " + str(self.RealThread.isChecked()) + "\n")
2238
2239#ND_text = str(self.NominalDiameter.currentText())
2240#NL_text = str(self.NominalLength.currentText())
2241#ST_text = str(self.ScrewType.currentText())
2242#ST_text = ST_text.split(':')[0]
2243#dia = float(ND_text.lstrip('M'))
2244l = float(NL_text)
2245if ST_text == 'ISO4017':
2246table = iso4017head
2247if ST_text == 'ISO4014':
2248table = iso4014head
2249if ST_text == 'EN1662':
2250table = en1662def
2251if ST_text == 'EN1665':
2252table = en1665def
2253if ST_text == 'ISO8676':
2254table = iso8676def
2255if ST_text == 'ISO2009':
2256table = iso2009def
2257if ST_text == 'ISO2010':
2258table = iso2009def
2259if ST_text == 'ISO4762':
2260table = iso4762def
2261if ST_text == 'ISO10642':
2262table = iso10642def
2263if ST_text == 'ISO1207':
2264table = iso1207def
2265if ST_text == 'ISO1580':
2266table = iso1580def
2267if ST_text == 'ISO7045':
2268table = iso7045def
2269if ST_text == 'ISO7046':
2270table = iso7045def
2271if ST_text == 'ISO7047':
2272table = iso7045def
2273if ST_text == 'ISO7048':
2274table = iso7048def
2275if ST_text == 'ISO7380-1':
2276table = iso7380def
2277if ST_text == 'ISO7380-2':
2278table = iso7380_2def
2279if ST_text == 'DIN967':
2280table = din967def
2281if ST_text == 'ISO14579':
2282table = iso14579def
2283if ST_text == 'ISO14580':
2284table = iso14580def
2285if ST_text == 'ISO14582':
2286table = iso14582def
2287if ST_text == 'ISO14583':
2288table = iso14583def
2289if ST_text == 'ISO14584':
2290table = iso14584def
2291if ST_text == 'ISO7089':
2292table = iso7089def
2293if ST_text == 'ISO7090':
2294table = iso7090def
2295if ST_text == 'ISO7091':
2296table = iso7091def
2297if ST_text == 'ISO7092':
2298table = iso7092def
2299if ST_text == 'ISO7093-1':
2300table = iso7093def
2301if ST_text == 'ISO7094':
2302table = iso7094def
2303if ST_text == 'ISO4032':
2304table = iso4032def
2305if ST_text == 'ISO4033':
2306table = iso4033def
2307if ST_text == 'ISO4035':
2308table = iso4035def
2309if ST_text == 'ISO4036':
2310table = iso4036def
2311if ST_text == 'EN1661':
2312table = en1661def
2313if ST_text == 'ScrewTap':
2314table = tuningTable
2315if ND_text not in table:
2316FreeCAD.Console.PrintMessage("Combination of type "+ST_text \
2317+ " and diameter " + ND_text +" not available!" + "\n")
2318#self.MessageLabel.setText(tr('ScrewMaker', 'not implemented'))
2319
2320except ValueError:
2321#print "Error! nom_dia and length values must be valid numbers!"
2322FreeCAD.Console.PrintMessage("Error! nom_dia and length values must be valid numbers!\n")
2323else:
2324doc=FreeCAD.activeDocument()
2325done = False
2326if (ST_text == 'ISO4014') or (ST_text == 'ISO4017') or (ST_text == 'ISO8676'):
2327screw = self.makeIso4017_2(ST_text, ND_text,l)
2328Type_text = 'Screw'
2329done = True
2330if (ST_text == 'EN1662') or (ST_text == 'EN1665'):
2331screw = self.makeEN1662_2(ST_text, ND_text,l)
2332Type_text = 'Screw'
2333done = True
2334if (ST_text == 'ISO2009') or (ST_text == 'ISO2010') or (ST_text == 'ISO1580'):
2335screw = self.makeSlottedScrew(ST_text, ND_text,l)
2336Type_text = 'Screw'
2337done = True
2338if (ST_text == 'ISO4762') or (ST_text == 'ISO14579'):
2339screw = self.makeIso4762(ST_text, ND_text,l)
2340Type_text = 'Screw'
2341done = True
2342if (ST_text == 'ISO1207') or (ST_text == 'ISO14580') or (ST_text == 'ISO7048'):
2343screw = self.makeIso1207(ST_text, ND_text,l)
2344Type_text = 'Screw'
2345done = True
2346if (ST_text == 'ISO7045') or (ST_text == 'ISO14583'):
2347screw = self.makeIso7045(ST_text, ND_text,l)
2348Type_text = 'Screw'
2349done = True
2350if (ST_text == 'ISO7046') or (ST_text == 'ISO7047') or \
2351(ST_text == 'ISO14582') or (ST_text == 'ISO14584') or (ST_text == 'ISO10642'):
2352screw = self.makeIso7046(ST_text, ND_text,l)
2353Type_text = 'Screw'
2354done = True
2355if (ST_text == 'ISO7380-1') or (ST_text == 'ISO7380-2') or (ST_text == 'DIN967'):
2356screw = self.makeIso7380(ST_text, ND_text,l)
2357Type_text = 'Screw'
2358done = True
2359if (ST_text == 'ISO7089') or (ST_text == 'ISO7090') or (ST_text == 'ISO7093-1') or \
2360(ST_text == 'ISO7091') or (ST_text == 'ISO7092') or (ST_text == 'ISO7094'):
2361screw = self.makeIso7089(ST_text, ND_text)
2362Type_text = 'Washer'
2363done = True
2364if (ST_text == 'ISO4032') or (ST_text == 'ISO4033') or (ST_text == 'ISO4035'):
2365screw = self.makeIso4032(ST_text, ND_text)
2366Type_text = 'Nut'
2367done = True
2368if ST_text == 'EN1661':
2369screw = self.makeEN1661(ND_text)
2370Type_text = 'Nut'
2371done = True
2372if ST_text == 'ScrewTap':
2373screw = self.makeScrewTap(ND_text,l)
2374Type_text = 'Screw-Tap'
2375done = True
2376if not done:
2377FreeCAD.Console.PrintMessage("No valid Screw Type!" + "\n")
2378if '(' in ND_text:
2379ND_text = ND_text.lstrip('(').rstrip(')')
2380
2381if Type_text == 'Screw':
2382label = ST_text + "-" + ND_text +"x"+ NL_text +"_"
2383else:
2384if (Type_text == 'Nut'):
2385label = ST_text + '-' + ND_text +'_'
2386else:
2387if Type_text == 'Screw-Tap':
2388label = ST_text + '-' + ND_text +'x'+ NL_text +'_'
2389else: # washer
2390label = ST_text + '-' + ND_text.lstrip('M') +'_'
2391ScrewObj = doc.addObject("Part::Feature")
2392ScrewObj.Label=label
2393ScrewObj.Shape=screw
2394#FreeCAD.Console.PrintMessage("Placement: "+ str(ScrewObj.Placement) +"\n")
2395#FreeCAD.Console.PrintMessage("The label: "+ label +"\n")
2396self.moveScrew(ScrewObj)
2397#ScrewObj.Label = label
2398if self.gotPart:
2399self.thePart.addObject(ScrewObj)
2400doc.recompute()
2401# Part.show(screw)
2402return ScrewObj
2403
2404def getFaceAxis(self, sp, c):
2405fList = []
2406fAxis = None
2407if len(c.Vertexes) ==1:
2408theVert = c.Vertexes[0]
2409# search for faces which have a vertex equal to theVert.
2410for f in sp.Faces:
2411for v in f.Vertexes:
2412if equal_vertex(v, theVert):
2413fList.append(f)
2414print (str(fList))
2415# search for a plane face
2416for f in fList:
2417if hasattr(f,'Surface'):
2418FreeCAD.Console.PrintMessage('type of surface: ', str(f.Surface))
2419if f.Surface.isPlanar():
2420fAxis = f.Surface.normal(0,0)
2421print ('got planar Face with normal: ', str(f.Surface.normal(0,0)))
2422print ('Orientation: ', str(f.Orientation))
2423if f.Orientation == 'Reversed':
2424fAxis = fAxis.multiply(-1.0)
2425return fAxis
2426
2427def moveScrew(self, ScrewObj_m):
2428#FreeCAD.Console.PrintMessage("In Move Screw: " + str(ScrewObj_m) + "\n")
2429self.gotBody = False
2430self.gotPart = False
2431
2432mylist = FreeCAD.Gui.Selection.getSelectionEx()
2433if (mylist.__len__() == 1):
2434# check selection
2435#FreeCAD.Console.PrintMessage("Selektionen: " + str(mylist.__len__()) + "\n")
2436Pnt1 = None
2437Axis1 = None
2438Axis2 = None
2439theSelection = mylist[0]
2440#FreeCAD.Console.PrintMessage( "ObjectName: " + str(theSelection.ObjectName) + "\n")
2441if hasattr(theSelection, 'Object'):
2442if hasattr(theSelection.Object, 'InList'):
2443inLength = len(theSelection.Object.InList)
2444#FreeCAD.Console.PrintMessage( "InList: " + str(theSelection.Object.InList) + "\n")
2445for b in theSelection.Object.InList:
2446#FreeCAD.Console.PrintMessage( "OType: " + str(b.TypeId) + "\n")
2447if b.TypeId == 'PartDesign::Body':
2448self.gotBody = True
2449self.bPlacement = b.Placement
2450for par in b.InList:
2451if par.TypeId == 'App::Part':
2452self.gotPart = True
2453self.thePart = par
2454
2455break
2456
2457for o in FreeCADGui.Selection.getSelectionEx():
2458#FreeCAD.Console.PrintMessage( "name: " + str(o) + "\n")
2459#FreeCAD.Console.PrintMessage( "Properties: " + str(o.PropertiesList) + "\n")
2460
2461#for s in o.SubElementNames:
2462#FreeCAD.Console.PrintMessage( "name: " + str(s) + "\n")
2463for s in o.SubObjects:
2464#FreeCAD.Console.PrintMessage( "object: "+ str(s) + "\n")
2465#FreeCAD.Console.PrintMessage( "Properties: " + str(s.PropertiesList) + "\n")
2466if hasattr(s,"Curve"):
2467#FreeCAD.Console.PrintMessage( "The Object is a Curve!\n")
2468if hasattr(s.Curve,"Center"):
2469"""
2470FreeCAD.Console.PrintMessage( "The object has a Center!\n")
2471FreeCAD.Console.PrintMessage( "Curve attribute. "+ str(s.__getattribute__('Curve')) + "\n")
2472FreeCAD.Console.PrintMessage( "Center: "+ str(s.Curve.Center) + "\n")
2473FreeCAD.Console.PrintMessage( "Axis: "+ str(s.Curve.Axis) + "\n")
2474"""
2475Pnt1 = s.Curve.Center
2476Axis1 = s.Curve.Axis
2477fAxis = self.getFaceAxis(o.Object.Shape, s)
2478if fAxis:
2479Axis1 = fAxis
2480if hasattr(s,'Surface'):
2481#print 'the object is a face!'
2482if hasattr(s.Surface,'Axis'):
2483Axis1 = s.Surface.Axis
2484
2485if hasattr(s,'Point'):
2486#FreeCAD.Console.PrintMessage( "the object seems to be a vertex! "+ str(s.Point) + "\n")
2487Pnt1 = s.Point
2488
2489if (Axis1 != None):
2490#FreeCAD.Console.PrintMessage( "Got Axis1: " + str(Axis1) + "\n")
2491Axis2 = Base.Vector(0.0,0.0,1.0)
2492Axis2_minus = Base.Vector(0.0,0.0,-1.0)
2493
2494# Calculate angle
2495if Axis1 == Axis2:
2496normvec = Base.Vector(1.0,0.0,0.0)
2497result = 0.0
2498else:
2499if Axis1 == Axis2_minus:
2500normvec = Base.Vector(1.0,0.0,0.0)
2501result = math.pi
2502else:
2503normvec = Axis1.cross(Axis2) # Berechne Achse der Drehung = normvec
2504normvec.normalize() # Normalisieren fuer Quaternionenrechnung
2505#normvec_rot = normvec
2506result = DraftVecUtils.angle(Axis1, Axis2, normvec) # Winkelberechnung
2507sin_res = math.sin(result/2.0)
2508cos_res = math.cos(result/2.0)
2509normvec.multiply(-sin_res) # Berechnung der Quaternionen-Elemente
2510#FreeCAD.Console.PrintMessage( "Winkel = "+ str(math.degrees(result)) + "\n")
2511#FreeCAD.Console.PrintMessage("Normalvektor: "+ str(normvec) + "\n")
2512
2513pl = FreeCAD.Placement()
2514pl.Rotation = (normvec.x,normvec.y,normvec.z,cos_res) #Drehungs-Quaternion
2515
2516#FreeCAD.Console.PrintMessage("pl mit Rot: "+ str(pl) + "\n")
2517#neuPlatz = Part2.Object.Placement.multiply(pl)
2518neuPlatz = ScrewObj_m.Placement
2519FreeCAD.Console.PrintMessage("The Position "+ str(neuPlatz) + "\n")
2520neuPlatz.Rotation = pl.Rotation.multiply(ScrewObj_m.Placement.Rotation)
2521# neuPlatz.move(Pnt1)
2522FreeCAD.Console.PrintMessage("The Position in Body "+ str(neuPlatz) + "\n")
2523if self.gotBody:
2524FreeCAD.Console.PrintMessage("got Placement: "+ str(self.bPlacement) + "\n")
2525#neuPlatz.Rotation = neuPlatz.Rotation.multiply(self.bPlacement.Rotation)
2526neuPlatz.Rotation = neuPlatz.Rotation.multiply(self.bPlacement.Rotation)
2527Pnt1 = self.bPlacement.multVec(Pnt1)
2528neuPlatz.move(Pnt1)
2529#if self.gotBody:
2530#neuPlatz.move(self.bPlacement.Base)
2531
2532# Python is not phytonic in FreeCAD 0.17, need to add allocation.
2533ScrewObj_m.Placement = neuPlatz
2534#FreeCAD.Console.PrintMessage("die rot. Position: "+ str(neuPlatz) + "\n")
2535
2536
2537
2538# make Washer
2539def makeIso7089(self,SType ='ISO7089', ThreadType ='M6'):
2540dia = get_diameter(ThreadType)
2541#FreeCAD.Console.PrintMessage("die Scheibe mit dia: " + str(dia) + "\n")
2542if SType == 'ISO7089':
2543d1_min, d2_max, h, h_max = iso7089def[ThreadType]
2544if SType == 'ISO7090':
2545d1_min, d2_max, h, h_max = iso7090def[ThreadType]
2546if SType == 'ISO7091':
2547d1_min, d2_max, h, h_max = iso7091def[ThreadType]
2548if SType == 'ISO7092':
2549d1_min, d2_max, h, h_max = iso7092def[ThreadType]
2550if SType == 'ISO7093-1':
2551d1_min, d2_max, h, h_max = iso7093def[ThreadType]
2552if SType == 'ISO7094':
2553d1_min, d2_max, h, h_max = iso7094def[ThreadType]
2554#FreeCAD.Console.PrintMessage("got: " + SType + "\n")
2555
2556#FreeCAD.Console.PrintMessage("die Scheibe mit d1_min: " + str(d1_min) + "\n")
2557
2558#Washer Points
2559Pnt0 = Base.Vector(d1_min/2.0,0.0,h_max)
2560Pnt2 = Base.Vector(d2_max/2.0,0.0,h_max)
2561Pnt3 = Base.Vector(d2_max/2.0,0.0,0.0)
2562Pnt4 = Base.Vector(d1_min/2.0,0.0,0.0)
2563if SType == 'ISO7090':
2564Pnt1 = Base.Vector(d2_max/2.0-h_max/4.0,0.0,h_max)
2565Pnt2 = Base.Vector(d2_max/2.0,0.0,h_max*0.75)
2566edge1 = Part.makeLine(Pnt0,Pnt1)
2567edgeCham = Part.makeLine(Pnt1,Pnt2)
2568edge1 = Part.Wire([edge1, edgeCham])
2569else:
2570edge1 = Part.makeLine(Pnt0,Pnt2)
2571
2572edge2 = Part.makeLine(Pnt2,Pnt3)
2573edge3 = Part.makeLine(Pnt3,Pnt4)
2574edge4 = Part.makeLine(Pnt4,Pnt0)
2575#FreeCAD.Console.PrintMessage("Edges made Pnt2: " + str(Pnt2) + "\n")
2576
2577aWire=Part.Wire([edge1,edge2,edge3,edge4])
2578#Part.show(aWire)
2579aFace =Part.Face(aWire)
2580head = aFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
2581#FreeCAD.Console.PrintMessage("Washer revolved: " + str(dia) + "\n")
2582
2583return head
2584
2585
2586# make ISO 2009 Slotted countersunk flat head screws
2587# make ISO 2010 Slotted raised countersunk head screws
2588# make ISO 1580 Pan head slotted screw (Code is nearly identical to iso1207)
2589def makeSlottedScrew(self,SType ='ISO1580', ThreadType ='M6',l=25.0):
2590dia = get_diameter(ThreadType)
2591if SType == 'ISO1580':
2592#FreeCAD.Console.PrintMessage("der Kopf mit l: " + str(l) + "\n")
2593#P, a, b, dk, dk_mean, da, k, n_min, r, t_min, x = iso1580def[ThreadType]
2594P, a, b, dk_max, da, k, n_min, r, rf, t_min, x = iso1580def[ThreadType]
2595#FreeCAD.Console.PrintMessage("der Kopf mit iso: " + str(dk_max) + "\n")
2596ht = k
2597headEnd = r
2598
2599#Length for calculation of head fillet
2600sqrt2_ = 1.0/math.sqrt(2.0)
2601r_fil = rf
2602beta = math.radians(5.0) # angle of pan head edge
2603alpha = math.radians(90.0 - (90.0+5.0)/2.0)
2604tan_beta = math.tan(beta)
2605# top head diameter without fillet
2606rK_top = dk_max/2.0 - k * tan_beta
2607fillet_center_x = rK_top - r_fil + r_fil * tan_beta
2608fillet_center_z = k - r_fil
2609fillet_arc_x = fillet_center_x + r_fil * math.sin(alpha)
2610fillet_arc_z = fillet_center_z + r_fil * math.cos(alpha)
2611#FreeCAD.Console.PrintMessage("rK_top: " + str(rK_top) + "\n")
2612if (b > (l - 1.0*P)):
2613bmax = l- 1.0*P
2614else:
2615bmax = b
2616
2617#Head Points
2618Pnt0 = Base.Vector(0.0,0.0,k)
2619Pnt2 = Base.Vector(fillet_center_x,0.0,k)
2620Pnt3 = Base.Vector(fillet_arc_x,0.0,fillet_arc_z)
2621Pnt4 = Base.Vector(fillet_center_x + r_fil*math.cos(beta),0.0,fillet_center_z+ r_fil * math.sin(beta))
2622Pnt5 = Base.Vector(dk_max/2.0,0.0,0.0)
2623Pnt6 = Base.Vector(dia/2.0+r,0.0,0.0) #start of fillet between head and shank
2624Pnt7 = Base.Vector(dia/2.0+r-r*sqrt2_,0.0,-r+r*sqrt2_) #arc-point of fillet
2625#Pnt8 = Base.Vector(dia/2.0,0.0,-r) # end of fillet
2626PntR = Base.Vector(dia/2.0,0.0,-r) # end of fillet
2627PntT0 = Base.Vector(0.0,0.0,-r) # helper point for real thread
2628
2629edge1 = Part.makeLine(Pnt0,Pnt2)
2630edge2 = Part.Arc(Pnt2,Pnt3,Pnt4).toShape()
2631edge3 = Part.makeLine(Pnt4,Pnt5)
2632edge4 = Part.makeLine(Pnt5,Pnt6)
2633edge5 = Part.Arc(Pnt6,Pnt7,PntR).toShape()
2634headWire=Part.Wire([edge1,edge2,edge3,edge4,edge5])
2635
2636if (SType == 'ISO2009') or (SType == 'ISO2010'):
2637P, a, b, dk_theo, dk_mean, k, n_min, r, t_mean, x = iso2009def[ThreadType]
2638dk_max = dk_theo
2639t_min = t_mean
2640ht = 0.0 # Head height of flat head
2641if (SType == 'ISO2010'):
2642rf, t_mean, cT, mH, mZ = Raised_countersunk_def[ThreadType]
2643#Lengths and angles for calculation of head rounding
2644beta = math.asin(dk_mean /2.0 / rf) # angle of head edge
2645tan_beta = math.tan(beta)
2646alpha = beta/2.0 # half angle
2647# height of raised head top
2648ht = rf - (dk_mean/2.0) / tan_beta
2649h_arc_x = rf * math.sin(alpha)
2650h_arc_z = ht - rf + rf * math.cos(alpha)
2651
2652cham = (dk_theo - dk_mean)/2.0
2653rad225 = math.radians(22.5)
2654rad45 = math.radians(45.0)
2655rtan = r*math.tan(rad225)
2656headEnd = k + rtan
2657
2658if (b > l - k - rtan/2.0 - 1.0*P):
2659bmax = l-k-rtan/2.0 - 1.0*P
2660else:
2661bmax = b
2662
2663#Head Points
2664Pnt0 = Base.Vector(0.0,0.0,ht)
2665Pnt1 = Base.Vector(dk_mean/2.0,0.0,0.0)
2666Pnt2 = Base.Vector(dk_mean/2.0,0.0,-cham)
2667Pnt3 = Base.Vector(dia/2.0+r-r*math.cos(rad45),0.0,-k-rtan+r*math.sin(rad45))
2668# Arc-points
2669Pnt4 = Base.Vector(dia/2.0+r-r*(math.cos(rad225)),0.0,-k-rtan+r*math.sin(rad225))
2670PntR = Base.Vector(dia/2.0,0.0,-k-rtan)
2671#PntA = Base.Vector(dia/2.0,0.0,-a_point)
2672PntT0 = Base.Vector(0.0,0.0,-k-rtan) # helper point for real thread
2673
2674if (SType == 'ISO2010'): # make raised head rounding
2675Pnt0arc = Base.Vector(h_arc_x,0.0,h_arc_z)
2676edge1 = Part.Arc(Pnt0,Pnt0arc,Pnt1).toShape()
2677else:
2678edge1 = Part.makeLine(Pnt0,Pnt1) # make flat head
2679
2680edge2 = Part.makeLine(Pnt1,Pnt2)
2681edge3 = Part.makeLine(Pnt2,Pnt3)
2682edgeArc = Part.Arc(Pnt3,Pnt4,PntR).toShape()
2683headWire=Part.Wire([edge1,edge2,edge3,edgeArc])
2684
2685
2686### make the new code with math.modf(l)
2687residue, turns = math.modf((bmax)/P)
2688halfturns = 2*int(turns)
2689if residue < 0.5:
2690a_point = l - (turns+1.0) * P
2691halfturns = halfturns +1
2692else:
2693halfturns = halfturns + 2
2694a_point = l - (turns+2.0) * P
2695#halfturns = halfturns + 2
2696offSet = headEnd - a_point
2697PntA = Base.Vector(dia/2.0,0.0,-a_point) # Start of thread
2698
2699
2700if self.rThread:
2701edgeZ1 = Part.makeLine(PntR,PntT0)
2702edgeZ0 = Part.makeLine(PntT0,Pnt0)
2703aWire=Part.Wire([headWire, edgeZ1, edgeZ0])
2704
2705else:
2706# bolt points
2707PntB1 = Base.Vector(dia/2.0,0.0,-l)
2708PntB2 = Base.Vector(0.0,0.0,-l)
2709
2710edgeB2 = Part.makeLine(PntB1,PntB2)
2711edgeZ0 = Part.makeLine(PntB2,Pnt0)
2712
2713if a_point <= r:
2714edgeB1 = Part.makeLine(PntR,PntB1)
2715aWire=Part.Wire([headWire, edgeB1, edgeB2, edgeZ0])
2716else:
2717edgeRA = Part.makeLine(PntR,PntA)
2718edgeB1 = Part.makeLine(PntA,PntB1)
2719aWire=Part.Wire([headWire, edgeRA, edgeB1, edgeB2, edgeZ0])
2720
2721aFace =Part.Face(aWire)
2722head = aFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
2723#FreeCAD.Console.PrintMessage("der Kopf mit revolve: " + str(dia) + "\n")
2724
2725#Parameter for slot-recess: dk_max, n_min, k, t_min
2726slot = Part.makePlane(dk_max, n_min, \
2727Base.Vector(dk_max/2.0,-n_min/2.0,ht+1.0),Base.Vector(0.0,0.0,-1.0))
2728slot = slot.extrude(Base.Vector(0.0,0.0,-t_min-1.0))
2729#Part.show(slot)
2730head = head.cut(slot)
2731#FreeCAD.Console.PrintMessage("der Kopf geschnitten: " + str(dia) + "\n")
2732#Part.show(head)
2733
2734if self.rThread:
2735rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
2736rthread.translate(Base.Vector(0.0, 0.0,-a_point -2.0*P))
2737#Part.show(rthread)
2738headFaces = []
2739if (SType == 'ISO2009'):
2740for i in range(0,len(head.Faces)-2):
2741headFaces.append(head.Faces[i])
2742headFaces.append(head.Faces[len(head.Faces)-1])
2743
2744if (SType == 'ISO1580') or (SType == 'ISO2010'):
2745for i in range(0,len(head.Faces)-1):
2746headFaces.append(head.Faces[i])
2747
2748for threadFace in rthread.Faces:
2749headFaces.append(threadFace)
2750
2751newHeadShell = Part.Shell(headFaces)
2752#Part.show(newHeadShell)
2753head = Part.Solid(newHeadShell)
2754
2755return head
2756
2757
2758
2759
2760
2761
2762# ISO 7045 Pan head screws with type H or type Z cross recess
2763# ISO 14583 Hexalobular socket pan head screws
2764def makeIso7045(self, SType ='ISO7045', ThreadType ='M6',l=25.0):
2765dia = get_diameter(ThreadType)
2766#FreeCAD.Console.PrintMessage("der Kopf mit l: " + str(l) + "\n")
2767P, a, b, dk_max,da, k, r, rf, x, cT, mH, mZ = iso7045def[ThreadType]
2768#FreeCAD.Console.PrintMessage("der Kopf mit iso: " + str(dk_max) + "\n")
2769
2770#Lengths and angles for calculation of head rounding
2771beta = math.asin(dk_max /2.0 / rf) # angle of head edge
2772#print 'beta: ', math.degrees(beta)
2773tan_beta = math.tan(beta)
2774
2775
2776if SType == 'ISO14583':
2777tt, A, t_mean = iso14583def[ThreadType]
2778beta_A = math.asin(A/2.0 / rf) # angle of recess edge
2779tan_beta_A = math.tan(beta_A)
2780
2781alpha = (beta_A + beta)/2.0 # half angle
2782#print 'alpha: ', math.degrees(alpha)
2783# height of head edge
2784he = k - A/2.0/tan_beta_A + (dk_max/2.0) / tan_beta
2785#print 'he: ', he
2786h_arc_x = rf * math.sin(alpha)
2787h_arc_z = k - A/2.0/tan_beta_A + rf * math.cos(alpha)
2788#FreeCAD.Console.PrintMessage("h_arc_z: " + str(h_arc_z) + "\n")
2789else:
2790alpha = beta/2.0 # half angle
2791#print 'alpha: ', math.degrees(alpha)
2792# height of head edge
2793he = k - rf + (dk_max/2.0) / tan_beta
2794#print 'he: ', he
2795h_arc_x = rf * math.sin(alpha)
2796h_arc_z = k - rf + rf * math.cos(alpha)
2797#FreeCAD.Console.PrintMessage("h_arc_z: " + str(h_arc_z) + "\n")
2798
2799if (b > (l - 1.0*P)):
2800bmax = l- 1.0*P
2801else:
2802bmax = b
2803
2804### make the new code with math.modf(l)
2805residue, turns = math.modf((bmax)/P)
2806halfturns = 2*int(turns)
2807if residue < 0.5:
2808a_point = l - (turns+1.0) * P
2809halfturns = halfturns +1
2810else:
2811halfturns = halfturns + 2
2812a_point = l - (turns+2.0) * P
2813#halfturns = halfturns + 2
2814offSet = r - a_point
2815#FreeCAD.Console.PrintMessage("The transition at a: " + str(a) + " turns " + str(turns) + "\n")
2816
2817sqrt2_ = 1.0/math.sqrt(2.0)
2818
2819#Head Points
2820Pnt1 = Base.Vector(h_arc_x,0.0,h_arc_z)
2821Pnt2 = Base.Vector(dk_max/2.0,0.0,he)
2822Pnt3 = Base.Vector(dk_max/2.0,0.0,0.0)
2823Pnt4 = Base.Vector(dia/2.0+r,0.0,0.0) #start of fillet between head and shank
2824Pnt5 = Base.Vector(dia/2.0+r-r*sqrt2_,0.0,-r+r*sqrt2_) #arc-point of fillet
2825Pnt6 = Base.Vector(dia/2.0,0.0,-r) # end of fillet
2826Pnt7 = Base.Vector(dia/2.0,0.0,-a_point) # Start of thread
2827#FreeCAD.Console.PrintMessage("Points defined a_point: " + str(a_point) + "\n")
2828
2829
2830if (SType == 'ISO14583'):
2831#Pnt0 = Base.Vector(0.0,0.0,k-A/4.0)
2832Pnt0 = Base.Vector(0.0,0.0,k-A/8.0)
2833PntFlat = Base.Vector(A/8.0,0.0,k-A/8.0)
2834PntCham = Base.Vector(A/1.99,0.0,k)
2835edgeCham0 = Part.makeLine(Pnt0,PntFlat)
2836edgeCham1 = Part.makeLine(PntFlat,PntCham)
2837edgeCham2 = Part.Arc(PntCham,Pnt1,Pnt2).toShape()
2838#edge1 = Part.Wire([edgeCham0,edgeCham1,edgeCham2])
2839edge1 = Part.Wire([edgeCham0,edgeCham1])
2840edge2 = Part.makeLine(Pnt2,Pnt3)
2841edge2 = Part.Wire([edgeCham2, edge2])
2842# Part.show(edge2)
2843
2844# Here is the next approach to shorten the head building time
2845# Make two helper points to create a cutting tool for the
2846# recess and recess shell.
2847PntH1 = Base.Vector(A/1.99,0.0, 2.0*k)
2848PntH2 = Base.Vector(0.0,0.0, 2.0*k)
2849edgeH1 = Part.makeLine(PntCham,PntH1)
2850edgeH2 = Part.makeLine(PntH1,PntH2)
2851edgeH3 = Part.makeLine(PntH2,Pnt0)
2852
2853else:
2854Pnt0 = Base.Vector(0.0,0.0,k)
2855edge1 = Part.Arc(Pnt0,Pnt1,Pnt2).toShape() # make round head
2856edge2 = Part.makeLine(Pnt2,Pnt3)
2857
2858# Here is the next approach to shorten the head building time
2859# Make two helper points to create a cutting tool for the
2860# recess and recess shell.
2861PntH1 = Base.Vector(dk_max/2.0,0.0, 2.0*k)
2862PntH2 = Base.Vector(0.0,0.0, 2.0*k)
2863edgeH1 = Part.makeLine(Pnt2,PntH1)
2864edgeH2 = Part.makeLine(PntH1,PntH2)
2865edgeH3 = Part.makeLine(PntH2,Pnt0)
2866
2867edge3 = Part.makeLine(Pnt3,Pnt4)
2868edge4 = Part.Arc(Pnt4,Pnt5,Pnt6).toShape()
2869#FreeCAD.Console.PrintMessage("Edges made h_arc_z: " + str(h_arc_z) + "\n")
2870
2871#if self.RealThread.isChecked():
2872if self.rThread:
2873aWire=Part.Wire([edge2,edge3,edge4])
2874else:
2875# bolt points
2876PntB1 = Base.Vector(dia/2.0,0.0,-l)
2877PntB2 = Base.Vector(0.0,0.0,-l)
2878edgeB2 = Part.makeLine(PntB1,PntB2)
2879if a_point <= r:
2880edgeB1 = Part.makeLine(Pnt6,PntB1)
2881aWire=Part.Wire([edge2, edge3, edge4, edgeB1, edgeB2])
2882else:
2883edge5 = Part.makeLine(Pnt6,Pnt7)
2884edgeB1 = Part.makeLine(Pnt7,PntB1)
2885aWire=Part.Wire([edge2, edge3, edge4, edge5, edgeB1, edgeB2])
2886
2887
2888
2889hWire = Part.Wire([edge1,edgeH1,edgeH2,edgeH3]) # Cutter for recess-Shell
2890hFace = Part.Face(hWire)
2891hCut = hFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
2892#Part.show(hWire)
2893
2894headShell = aWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
2895#head = Part.Solid(headShell)
2896#Part.show(aWire)
2897#FreeCAD.Console.PrintMessage("der Kopf mit revolve: " + str(dia) + "\n")
2898headFaces = headShell.Faces
2899
2900if (SType == 'ISO14583'):
2901recess, recessShell = self.makeIso10664_3(tt, t_mean, k)
2902recessShell = recessShell.cut(hCut)
2903topFace = hCut.Faces[1]
2904topFace = topFace.cut(recess)
2905#Part.show(topFace)
2906#Part.show(recessShell)
2907#Part.show(headShell)
2908headFaces.append(topFace.Faces[0])
2909#headFaces.append(hCut.Faces[2])
2910
2911else:
2912#Lengths and angles for calculation of recess positioning
2913beta_cr = math.asin(mH /2.0 / rf) # angle of recess edge
2914tan_beta_cr = math.tan(beta_cr)
2915# height of cross recess cutting
2916hcr = k - rf + (mH/2.0) / tan_beta_cr
2917#print 'hcr: ', hcr
2918
2919#Parameter for cross-recess type H: cT, mH
2920recess, recessShell = self.makeCross_H3(cT, mH, hcr)
2921recessShell = recessShell.cut(hCut)
2922topFace = hCut.Faces[0]
2923topFace = topFace.cut(recess)
2924#Part.show(topFace)
2925#Part.show(recessShell)
2926#Part.show(headShell)
2927headFaces.append(topFace.Faces[0])
2928
2929#Part.show(hCut)
2930headFaces.extend(recessShell.Faces)
2931
2932
2933#if self.RealThread.isChecked():
2934if self.rThread:
2935#head = self.cutIsoThread(head, dia, P, turns, l)
2936rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
2937rthread.translate(Base.Vector(0.0, 0.0,-a_point -2.0*P))
2938#head = head.fuse(rthread)
2939#Part.show(rthread)
2940for threadFace in rthread.Faces:
2941headFaces.append(threadFace)
2942
2943newHeadShell = Part.Shell(headFaces)
2944#Part.show(newHeadShell)
2945head = Part.Solid(newHeadShell)
2946
2947return head
2948
2949
2950# make Cheese head screw
2951# ISO 1207 slotted screw
2952# ISO 7048 cross recessed screw
2953# ISO 14580 Hexalobular socket cheese head screws
2954def makeIso1207(self,SType ='ISO1207', ThreadType ='M6',l=25.0):
2955dia = get_diameter(ThreadType)
2956'''
2957if '(' in TreadType:
2958threadString = ThreadType.lstrip('(M')
2959dia = float(ThreadType.rstrip(')'))
2960else:
2961dia=float(ThreadType.lstrip('M'))
2962'''
2963#FreeCAD.Console.PrintMessage("der Kopf mit l: " + str(l) + "\n")
2964if (SType == 'ISO1207') or (SType == 'ISO14580'):
2965P, a, b, dk, dk_mean, da, k, n_min, r, t_min, x = iso1207def[ThreadType]
2966if SType == 'ISO7048':
2967P, a, b, dk, dk_mean, da, k, r, x, cT, mH, mZ = iso7048def[ThreadType]
2968if (SType == 'ISO14580'):
2969tt, k, A, t_min = iso14580def[ThreadType]
2970
2971#FreeCAD.Console.PrintMessage("der Kopf mit iso: " + str(dk) + "\n")
2972
2973#Length for calculation of head fillet
2974r_fil = r*2.0
2975beta = math.radians(5.0) # angle of cheese head edge
2976alpha = math.radians(90.0 - (90.0+5.0)/2.0)
2977tan_beta = math.tan(beta)
2978# top head diameter without fillet
2979rK_top = dk/2.0 - k * tan_beta
2980fillet_center_x = rK_top - r_fil + r_fil * tan_beta
2981fillet_center_z = k - r_fil
2982fillet_arc_x = fillet_center_x + r_fil * math.sin(alpha)
2983fillet_arc_z = fillet_center_z + r_fil * math.cos(alpha)
2984#FreeCAD.Console.PrintMessage("rK_top: " + str(rK_top) + "\n")
2985
2986if (b > (l - 1.0*P)):
2987bmax = l- 1.0*P
2988else:
2989bmax = b
2990
2991### make the new code with math.modf(l)
2992residue, turns = math.modf((bmax)/P)
2993halfturns = 2*int(turns)
2994if residue < 0.5:
2995a_point = l - (turns+1.0) * P
2996halfturns = halfturns +1
2997else:
2998halfturns = halfturns + 2
2999a_point = l - (turns+2.0) * P
3000#halfturns = halfturns + 2
3001offSet = r - a_point
3002
3003sqrt2_ = 1.0/math.sqrt(2.0)
3004
3005#Head Points
3006Pnt2 = Base.Vector(fillet_center_x,0.0,k)
3007Pnt3 = Base.Vector(fillet_arc_x,0.0,fillet_arc_z)
3008Pnt4 = Base.Vector(fillet_center_x + r_fil*math.cos(beta),0.0,fillet_center_z+ r_fil * math.sin(beta))
3009Pnt5 = Base.Vector(dk/2.0,0.0,0.0)
3010Pnt6 = Base.Vector(dia/2.0+r,0.0,0.0) #start of fillet between head and shank
3011Pnt7 = Base.Vector(dia/2.0+r-r*sqrt2_,0.0,-r+r*sqrt2_) #arc-point of fillet
3012Pnt8 = Base.Vector(dia/2.0,0.0,-r) # end of fillet
3013Pnt9 = Base.Vector(dia/2.0,0.0,-a_point) # Start of thread
3014#FreeCAD.Console.PrintMessage("Points defined fillet_center_x: " + str(fillet_center_x) + "\n")
3015
3016if (SType == 'ISO14580'):
3017# Pnt0 = Base.Vector(0.0,0.0,k-A/4.0) #Center Point for countersunk
3018Pnt0 = Base.Vector(0.0,0.0,k-A/8.0) #Center Point for flat countersunk
3019PntFlat = Base.Vector(A/8.0,0.0,k-A/8.0) # End of flat part
3020Pnt1 = Base.Vector(A/1.99,0.0,k) #countersunk edge at head
3021edgeCham0 = Part.makeLine(Pnt0,PntFlat)
3022edgeCham1 = Part.makeLine(PntFlat,Pnt1)
3023edgeCham2 = Part.makeLine(Pnt1,Pnt2)
3024edge1 = Part.Wire([edgeCham1,edgeCham2]) # make head with countersunk
3025PntH1 = Base.Vector(A/1.99,0.0, 2.0*k)
3026
3027else:
3028Pnt0 = Base.Vector(0.0,0.0,k)
3029edge1 = Part.makeLine(Pnt0,Pnt2) # make flat head
3030
3031
3032edge2 = Part.Arc(Pnt2,Pnt3,Pnt4).toShape()
3033edge3 = Part.makeLine(Pnt4,Pnt5)
3034edge4 = Part.makeLine(Pnt5,Pnt6)
3035edge5 = Part.Arc(Pnt6,Pnt7,Pnt8).toShape()
3036#FreeCAD.Console.PrintMessage("Edges made fillet_center_z: " + str(fillet_center_z) + "\n")
3037
3038if SType == 'ISO1207':
3039#Parameter for slot-recess: dk, n_min, k, t_min
3040recess = Part.makePlane(dk, n_min, \
3041Base.Vector(dk/2.0,-n_min/2.0,k+1.0),Base.Vector(0.0,0.0,-1.0))
3042recess = recess.extrude(Base.Vector(0.0,0.0,-t_min-1.0))
3043
3044if self.rThread:
3045Pnt11 = Base.Vector(0.0,0.0,-r) # helper point for real thread
3046edgeZ1 = Part.makeLine(Pnt8,Pnt11)
3047edgeZ0 = Part.makeLine(Pnt11,Pnt0)
3048aWire=Part.Wire([edge1,edge2,edge3,edge4,edge5, \
3049edgeZ1, edgeZ0])
3050else:
3051# bolt points
3052PntB1 = Base.Vector(dia/2.0,0.0,-l)
3053PntB2 = Base.Vector(0.0,0.0,-l)
3054
3055edgeB2 = Part.makeLine(PntB1,PntB2)
3056
3057if a_point <= r:
3058edgeB1 = Part.makeLine(Pnt8,PntB1)
3059aWire=Part.Wire([edge1,edge2,edge3,edge4,edge5, \
3060edgeB1, edgeB2])
3061else:
3062edge6 = Part.makeLine(Pnt8,Pnt9)
3063edgeB1 = Part.makeLine(Pnt9,PntB1)
3064aWire=Part.Wire([edge1,edge2,edge3,edge4,edge5,edge6, \
3065edgeB1, edgeB2])
3066
3067aFace =Part.Face(aWire)
3068head = aFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360.0)
3069head = head.cut(recess)
3070# FreeCAD.Console.PrintMessage("der Kopf geschnitten: " + str(dia) + "\n")
3071#Part.show(head)
3072if self.rThread:
3073screwFaces = []
3074for i in range(0, len(head.Faces)-1):
3075screwFaces.append(head.Faces[i])
3076rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
3077rthread.translate(Base.Vector(0.0, 0.0,-a_point -2.0*P))
3078for threadFace in rthread.Faces:
3079screwFaces.append(threadFace)
3080
3081screwShell = Part.Shell(screwFaces)
3082head = Part.Solid(screwShell)
3083
3084
3085
3086else:
3087if self.rThread:
3088aWire=Part.Wire([edge1,edge2,edge3,edge4,edge5 ])
3089else:
3090# bolt points
3091PntB1 = Base.Vector(dia/2.0,0.0,-l)
3092PntB2 = Base.Vector(0.0,0.0,-l)
3093
3094edgeB2 = Part.makeLine(PntB1,PntB2)
3095
3096if a_point <= r:
3097edgeB1 = Part.makeLine(Pnt8,PntB1)
3098aWire=Part.Wire([edge1,edge2,edge3,edge4,edge5, \
3099edgeB1, edgeB2])
3100else:
3101edge6 = Part.makeLine(Pnt8,Pnt9)
3102edgeB1 = Part.makeLine(Pnt9,PntB1)
3103aWire=Part.Wire([edge1,edge2,edge3,edge4,edge5,edge6, \
3104edgeB1, edgeB2])
3105
3106#aFace =Part.Face(aWire)
3107headShell = aWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360.0)
3108#FreeCAD.Console.PrintMessage("der Kopf mit revolve: " + str(dia) + "\n")
3109
3110if SType == 'ISO7048':
3111# hCut should be just a cylinder
3112hCut = Part.makeCylinder(fillet_center_x,k,Pnt0)
3113recess, recessShell = self.makeCross_H3(cT, mH, k)
3114recessShell = recessShell.cut(hCut)
3115topFace = headShell.Faces[0].cut(recess)
3116screwFaces = [topFace.Faces[0]]
3117screwFaces.extend(recessShell.Faces)
3118if (SType == 'ISO14580'):
3119# Ring-cutter for recess shell
3120PntH2 = Base.Vector(A/8.0,0.0, 2.0*k)
3121edgeH1 = Part.makeLine(Pnt1,PntH1)
3122edgeH2 = Part.makeLine(PntH1,PntH2)
3123edgeH3 = Part.makeLine(PntH2,PntFlat)
3124hWire = Part.Wire([edgeCham1,edgeH1,edgeH2,edgeH3]) # Cutter for recess-Shell
3125hFace = Part.Face(hWire)
3126hCut = hFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
3127#Part.show(hWire)
3128
3129recess, recessShell = self.makeIso10664_3(tt, t_min, k)
3130recessShell = recessShell.cut(hCut)
3131topFace = headShell.Faces[0].cut(recess)
3132screwFaces = [topFace.Faces[0]]
3133screwFaces.extend(recessShell.Faces)
3134
3135for i in range(1, len(headShell.Faces)):
3136screwFaces.append(headShell.Faces[i])
3137
3138if self.rThread:
3139#head = self.cutIsoThread(head, dia, P, turns, l)
3140rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
3141rthread.translate(Base.Vector(0.0, 0.0,-a_point -2.0*P))
3142#head = head.fuse(rthread)
3143#Part.show(rthread)
3144for threadFace in rthread.Faces:
3145screwFaces.append(threadFace)
3146
3147screwShell = Part.Shell(screwFaces)
3148head = Part.Solid(screwShell)
3149
3150return head
3151
3152
3153
3154# make the ISO 4017 Hex-head-screw
3155# make the ISO 4014 Hex-head-bolt
3156def makeIso4017_2(self,SType ='ISO4017', ThreadType ='M6',l=40.0):
3157dia = get_diameter(ThreadType)
3158#FreeCAD.Console.PrintMessage("der Kopf mit l: " + str(l) + "\n")
3159if SType == 'ISO4017':
3160P, c, dw, e,k,r,s = iso4017head[ThreadType]
3161residue, turns = math.modf((l-1*P)/P)
3162halfturns = 2*int(turns)
3163
3164if SType == 'ISO8676':
3165P, c, dw, e,k,r,s = iso8676def[ThreadType]
3166residue, turns = math.modf((l-r-1*P)/P)
3167halfturns = 2*int(turns)
3168
3169if SType == 'ISO4014':
3170P, b1, b2, b3, c, dw, e, k, r, s = iso4014head[ThreadType]
3171if l<= 125.0:
3172b = b1
3173else:
3174if l<= 200.0:
3175b = b2
3176else:
3177b = b3
3178residue, turns = math.modf((b)/P)
3179halfturns = 2*int(turns)
3180
3181if residue < 0.5:
3182a = l - (turns+1.0) * P
3183halfturns = halfturns +1
3184else:
3185halfturns = halfturns + 2
3186a = l - (turns+2.0) * P
3187#halfturns = halfturns + 2
3188offSet = r - a
3189
3190sqrt2_ = 1.0/math.sqrt(2.0)
3191cham = (e-s)*math.sin(math.radians(15)) # needed for chamfer at head top
3192
3193#Head Points Usage of k, s, cham, c, dw, dia, r, a
3194#FreeCAD.Console.PrintMessage("der Kopf mit halfturns: " + str(halfturns) + "\n")
3195Pnt0 = Base.Vector(0.0,0.0,k)
3196Pnt2 = Base.Vector(s/2.0,0.0,k)
3197Pnt3 = Base.Vector(s/math.sqrt(3.0),0.0,k-cham)
3198Pnt4 = Base.Vector(s/math.sqrt(3.0),0.0,c)
3199Pnt5 = Base.Vector(dw/2.0,0.0,c)
3200Pnt6 = Base.Vector(dw/2.0,0.0,0.0)
3201Pnt7 = Base.Vector(dia/2.0+r,0.0,0.0) #start of fillet between head and shank
3202Pnt8 = Base.Vector(dia/2.0+r-r*sqrt2_,0.0,-r+r*sqrt2_) #arc-point of fillet
3203Pnt9 = Base.Vector(dia/2.0,0.0,-r) # end of fillet
3204Pnt10 = Base.Vector(dia/2.0,0.0,-a) # Start of thread
3205
3206edge1 = Part.makeLine(Pnt0,Pnt2)
3207edge2 = Part.makeLine(Pnt2,Pnt3)
3208edge3 = Part.makeLine(Pnt3,Pnt4)
3209edge4 = Part.makeLine(Pnt4,Pnt5)
3210edge5 = Part.makeLine(Pnt5,Pnt6)
3211edge6 = Part.makeLine(Pnt6,Pnt7)
3212edge7 = Part.Arc(Pnt7,Pnt8,Pnt9).toShape()
3213
3214# create cutting tool for hexagon head
3215# Parameters s, k, outer circle diameter = e/2.0+10.0
3216extrude = self.makeHextool(s, k, s*2.0)
3217
3218#if self.RealThread.isChecked():
3219if self.rThread:
3220Pnt11 = Base.Vector(0.0,0.0,-r) # helper point for real thread
3221edgeZ1 = Part.makeLine(Pnt9,Pnt11)
3222edgeZ0 = Part.makeLine(Pnt11,Pnt0)
3223aWire=Part.Wire([edge1,edge2,edge3,edge4,edge5,edge6,edge7, \
3224edgeZ1, edgeZ0])
3225
3226aFace =Part.Face(aWire)
3227head = aFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360.0)
3228#FreeCAD.Console.PrintMessage("der Kopf mit revolve: " + str(dia) + "\n")
3229
3230# Part.show(extrude)
3231head = head.cut(extrude)
3232#FreeCAD.Console.PrintMessage("der Kopf geschnitten: " + str(dia) + "\n")
3233#Part.show(head)
3234
3235headFaces = []
3236for i in range(18):
3237headFaces.append(head.Faces[i])
3238
3239if (dia < 3.0) or (dia > 5.0):
3240rthread = self.makeShellthread(dia, P, halfturns, True, offSet)
3241rthread.translate(Base.Vector(0.0, 0.0,-a-2.0*P))
3242#rthread.translate(Base.Vector(0.0, 0.0,-2.0*P))
3243#Part.show(rthread)
3244for tFace in rthread.Faces:
3245headFaces.append(tFace)
3246headShell = Part.Shell(headFaces)
3247head = Part.Solid(headShell)
3248else:
3249rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
3250rthread.translate(Base.Vector(0.0, 0.0,-a-2.0*P))
3251#rthread.translate(Base.Vector(0.0, 0.0,-2.0*P))
3252#Part.show(rthread)
3253for tFace in rthread.Faces:
3254headFaces.append(tFace)
3255headShell = Part.Shell(headFaces)
3256head = Part.Solid(headShell)
3257cyl = self.cutChamfer(dia, P, l)
3258#FreeCAD.Console.PrintMessage("vor Schnitt Ende: " + str(dia) + "\n")
3259head = head.cut(cyl)
3260
3261else:
3262# bolt points
3263cham_t = P*math.sqrt(3.0)/2.0*17.0/24.0
3264
3265PntB0 = Base.Vector(0.0,0.0,-a)
3266PntB1 = Base.Vector(dia/2.0,0.0,-l+cham_t)
3267PntB2 = Base.Vector(dia/2.0-cham_t,0.0,-l)
3268PntB3 = Base.Vector(0.0,0.0,-l)
3269
3270edgeB1 = Part.makeLine(Pnt10,PntB1)
3271edgeB2 = Part.makeLine(PntB1,PntB2)
3272edgeB3 = Part.makeLine(PntB2,PntB3)
3273
3274edgeZ0 = Part.makeLine(PntB3,Pnt0)
3275if a <= r:
3276edgeB1 = Part.makeLine(Pnt9,PntB1)
3277aWire=Part.Wire([edge1,edge2,edge3,edge4,edge5,edge6,edge7, \
3278edgeB1, edgeB2, edgeB3, edgeZ0])
3279
3280else:
3281edge8 = Part.makeLine(Pnt9,Pnt10)
3282edgeB1 = Part.makeLine(Pnt10,PntB1)
3283aWire=Part.Wire([edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8, \
3284edgeB1, edgeB2, edgeB3, edgeZ0])
3285
3286aFace =Part.Face(aWire)
3287head = aFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360.0)
3288#FreeCAD.Console.PrintMessage("der Kopf mit revolve: " + str(dia) + "\n")
3289
3290# Part.show(extrude)
3291head = head.cut(extrude)
3292#FreeCAD.Console.PrintMessage("der Kopf geschnitten: " + str(dia) + "\n")
3293
3294return head
3295
3296
3297# EN 1662 Hex-head-bolt with flange - small series
3298# EN 1665 Hexagon bolts with flange, heavy series
3299def makeEN1662_2(self,SType ='EN1662', ThreadType ='M8',l=25.0):
3300dia = get_diameter(ThreadType)
3301#FreeCAD.Console.PrintMessage("der Kopf mit l: " + str(l) + "\n")
3302if SType == 'EN1662':
3303P, b0, b1, b2, b3, c, dc, dw, e, k, kw,f, r1, s = en1662def[ThreadType]
3304else:
3305P, b0, b1, b2, b3, c, dc, dw, e, k, kw,f, r1, s = en1665def[ThreadType]
3306if l< b0:
3307b = l - 2*P
3308else:
3309if l<= 125.0:
3310b = b1
3311else:
3312if l<= 200.0:
3313b = b2
3314else:
3315b = b3
3316
3317#FreeCAD.Console.PrintMessage("der Kopf mit isoEN1662: " + str(c) + "\n")
3318cham = s*(2.0/math.sqrt(3.0)-1.0)*math.sin(math.radians(25)) # needed for chamfer at head top
3319
3320### make the new code with math.modf(l)
3321residue, turns = math.modf((b)/P)
3322halfturns = 2*int(turns)
3323if residue < 0.5:
3324a_point = l - (turns+1.0) * P
3325halfturns = halfturns +1
3326else:
3327halfturns = halfturns + 2
3328a_point = l - (turns+2.0) * P
3329#halfturns = halfturns + 2
3330offSet = r1 - a_point
3331
3332sqrt2_ = 1.0/math.sqrt(2.0)
3333
3334# Flange is made with a radius of c
3335beta = math.radians(25.0)
3336tan_beta = math.tan(beta)
3337
3338# Calculation of Arc points of flange edge using dc and c
3339arc1_x = dc/2.0 - c/2.0 + (c/2.0)*math.sin(beta)
3340arc1_z = c/2.0 + (c/2.0)*math.cos(beta)
3341
3342hF = arc1_z + (arc1_x -s/2.0) * tan_beta # height of flange at center
3343
3344kmean = arc1_z + (arc1_x - s/math.sqrt(3.0)) * tan_beta + kw * 1.1 + cham
3345#kmean = k * 0.95
3346
3347
3348#Hex-Head Points
3349#FreeCAD.Console.PrintMessage("der Kopf mit math a: " + str(a_point) + "\n")
3350PntH0 = Base.Vector(0.0,0.0,kmean*0.9)
3351PntH1 = Base.Vector(s/2.0*0.8 - r1/2.0,0.0,kmean*0.9)
3352PntH1a = Base.Vector(s/2.0*0.8-r1/2.0+r1/2.0*sqrt2_,0.0,kmean*0.9 +r1/2.0 -r1/2.0*sqrt2_)
3353PntH1b = Base.Vector(s/2.0*0.8,0.0,kmean*0.9 +r1/2.0)
3354PntH2 = Base.Vector(s/2.0*0.8,0.0,kmean -r1)
3355PntH2a = Base.Vector(s/2.0*0.8+r1-r1*sqrt2_,0.0,kmean -r1 +r1*sqrt2_)
3356PntH2b = Base.Vector(s/2.0*0.8 + r1 ,0.0,kmean)
3357PntH3 = Base.Vector(s/2.0,0.0,kmean)
3358#PntH4 = Base.Vector(s/math.sqrt(3.0),0.0,kmean-cham) #s/math.sqrt(3.0)
3359#PntH5 = Base.Vector(s/math.sqrt(3.0),0.0,c)
3360#PntH6 = Base.Vector(0.0,0.0,c)
3361
3362edgeH1 = Part.makeLine(PntH0,PntH1)
3363edgeH2 = Part.Arc(PntH1,PntH1a,PntH1b).toShape()
3364edgeH3 = Part.makeLine(PntH1b,PntH2)
3365edgeH3a = Part.Arc(PntH2,PntH2a,PntH2b).toShape()
3366edgeH3b = Part.makeLine(PntH2b,PntH3)
3367
3368hWire=Part.Wire([edgeH1,edgeH2,edgeH3,edgeH3a,edgeH3b])
3369topShell = hWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
3370#Part.show(hWire)
3371#Part.show(topShell)
3372
3373# create a cutter ring to generate the chamfer at the top of the hex
3374chamHori = s/math.sqrt(3.0) - s/2.0
3375PntC1 = Base.Vector(s/2.0-chamHori,0.0,kmean+kmean)
3376PntC2 = Base.Vector(s/math.sqrt(3.0)+chamHori,0.0,kmean+kmean)
3377PntC3 = Base.Vector(s/2.0-chamHori,0.0,kmean+cham)
3378PntC4 = Base.Vector(s/math.sqrt(3.0)+chamHori,0.0,kmean-cham-cham) #s/math.sqrt(3.0)
3379edgeC1 = Part.makeLine(PntC3, PntC1)
3380edgeC2 = Part.makeLine(PntC1, PntC2)
3381edgeC3 = Part.makeLine(PntC2, PntC4)
3382edgeC4 = Part.makeLine(PntC4, PntC3)
3383cWire = Part.Wire([edgeC4, edgeC1, edgeC2, edgeC3])
3384cFace = Part.Face(cWire)
3385chamCut = cFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
3386#Part.show(cWire)
3387#Part.show(chamCut)
3388
3389
3390# create hexagon
3391mhex=Base.Matrix()
3392mhex.rotateZ(math.radians(60.0))
3393polygon = []
3394vhex=Base.Vector(s/math.sqrt(3.0),0.0,kmean)
3395for i in range(6):
3396polygon.append(vhex)
3397vhex = mhex.multiply(vhex)
3398polygon.append(vhex)
3399hexagon = Part.makePolygon(polygon)
3400hexFace = Part.Face(hexagon)
3401solidHex = hexFace.extrude(Base.Vector(0.0,0.0,c-kmean))
3402#Part.show(solidHex)
3403hexCham = solidHex.cut(chamCut)
3404#Part.show(hexCham)
3405
3406topFaces = topShell.Faces
3407
3408topFaces.append(hexCham.Faces[6])
3409topFaces.append(hexCham.Faces[12])
3410topFaces.append(hexCham.Faces[14])
3411topFaces.append(hexCham.Faces[13])
3412topFaces.append(hexCham.Faces[8])
3413topFaces.append(hexCham.Faces[2])
3414topFaces.append(hexCham.Faces[1])
3415
3416hexFaces = [hexCham.Faces[5], hexCham.Faces[11], hexCham.Faces[10]]
3417hexFaces.extend([hexCham.Faces[9], hexCham.Faces[3], hexCham.Faces[0]])
3418hexShell = Part.Shell(hexFaces)
3419
3420# Center of flange:
3421Pnt0 = Base.Vector(0.0,0.0,hF)
3422Pnt1 = Base.Vector(s/2.0,0.0,hF)
3423
3424# arc edge of flange:
3425Pnt2 = Base.Vector(arc1_x,0.0,arc1_z)
3426Pnt3 = Base.Vector(dc/2.0,0.0,c/2.0)
3427Pnt4 = Base.Vector((dc-c)/2.0,0.0,0.0)
3428
3429Pnt5 = Base.Vector(dia/2.0+r1,0.0,0.0) #start of fillet between head and shank
3430Pnt6 = Base.Vector(dia/2.0+r1-r1*sqrt2_,0.0,-r1+r1*sqrt2_) #arc-point of fillet
3431Pnt7 = Base.Vector(dia/2.0,0.0,-r1) # end of fillet
3432Pnt8 = Base.Vector(dia/2.0,0.0,-a_point) # Start of thread
3433
3434edge1 = Part.makeLine(Pnt0,Pnt1)
3435edge2 = Part.makeLine(Pnt1,Pnt2)
3436edge3 = Part.Arc(Pnt2,Pnt3,Pnt4).toShape()
3437edge4 = Part.makeLine(Pnt4,Pnt5)
3438edge5 = Part.Arc(Pnt5,Pnt6,Pnt7).toShape()
3439
3440# make a cutter for the hexShell
3441PntHC1 = Base.Vector(0.0,0.0,arc1_z)
3442PntHC2 = Base.Vector(0.0,0.0,0.0)
3443
3444edgeHC1 = Part.makeLine(Pnt2,PntHC1)
3445edgeHC2 = Part.makeLine(PntHC1,PntHC2)
3446edgeHC3 = Part.makeLine(PntHC2,Pnt0)
3447
3448HCWire = Part.Wire([edge2, edgeHC1, edgeHC2, edgeHC3, edge1])
3449HCFace = Part.Face(HCWire)
3450hex2Cut = HCFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
3451
3452hexShell = hexShell.cut(hex2Cut)
3453#Part.show(hexShell)
3454
3455topFaces.extend(hexShell.Faces)
3456
3457# bolt points
3458cham_t = P*math.sqrt(3.0)/2.0*17.0/24.0
3459
3460PntB0 = Base.Vector(0.0,0.0,-a_point)
3461PntB1 = Base.Vector(dia/2.0,0.0,-l+cham_t)
3462PntB2 = Base.Vector(dia/2.0-cham_t,0.0,-l)
3463PntB3 = Base.Vector(0.0,0.0,-l)
3464
3465edgeB2 = Part.makeLine(PntB1,PntB2)
3466edgeB3 = Part.makeLine(PntB2,PntB3)
3467
3468#if self.RealThread.isChecked():
3469if self.rThread:
3470aWire=Part.Wire([edge2,edge3,edge4,edge5])
3471boltIndex = 4
3472
3473else:
3474if a_point <=r1:
3475edgeB1 = Part.makeLine(Pnt7,PntB1)
3476aWire=Part.Wire([edge2,edge3,edge4,edge5, edgeB1, edgeB2, edgeB3])
3477boltIndex = 7
3478else:
3479edgeB1 = Part.makeLine(Pnt8,PntB1)
3480edge6 = Part.makeLine(Pnt7,Pnt8)
3481aWire=Part.Wire([edge2,edge3,edge4,edge5,edge6, \
3482edgeB1, edgeB2, edgeB3])
3483boltIndex = 8
3484
3485
3486#aFace =Part.Face(aWire)
3487#Part.show(aWire)
3488headShell = aWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
3489#FreeCAD.Console.PrintMessage("der Kopf mit revolve: " + str(dia) + "\n")
3490#Part.show(headShell)
3491chamFace = headShell.Faces[0].cut(solidHex)
3492#Part.show(chamFace)
3493
3494topFaces.append(chamFace.Faces[0])
3495for i in range(1,boltIndex):
3496topFaces.append(headShell.Faces[i])
3497
3498
3499if self.rThread:
3500if (dia < 3.0) or (dia > 5.0):
3501rthread = self.makeShellthread(dia, P, halfturns, True, offSet)
3502rthread.translate(Base.Vector(0.0, 0.0,-a_point-2.0*P))
3503for tFace in rthread.Faces:
3504topFaces.append(tFace)
3505headShell = Part.Shell(topFaces)
3506screw = Part.Solid(headShell)
3507else:
3508rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
3509rthread.translate(Base.Vector(0.0, 0.0,-a_point-2.0*P))
3510for tFace in rthread.Faces:
3511topFaces.append(tFace)
3512headShell = Part.Shell(topFaces)
3513head = Part.Solid(headShell)
3514cyl = self.cutChamfer(dia, P, l)
3515#FreeCAD.Console.PrintMessage("vor Schnitt Ende: " + str(dia) + "\n")
3516screw = head.cut(cyl)
3517else:
3518screwShell = Part.Shell(topFaces)
3519screw = Part.Solid(screwShell)
3520
3521return screw
3522
3523def makeIso7046(self, SType ='ISO7046', ThreadType ='M6', l=25.0):
3524"""ISO 7046, ISO 7047, ISO 10642, ISO 14582, ISO 14584
3525
3526Used for ISO 7046 countersunk flat head screws with H cross recess
3527Used for ISO 7047 raised countersunk head screws with H cross recess
3528Used for ISO 10642 Hexagon socket countersunk head screws
3529Used for ISO 14582 Hexalobular socket countersunk head screws, high head
3530Used for ISO 14584 Hexalobular socket raised countersunk head screws
3531"""
3532dia = get_diameter(ThreadType)
3533#FreeCAD.Console.PrintMessage("The 2009 head with l: " + str(l) + "\n")
3534if (SType == 'ISO10642'):
3535P,b,dk_theo,dk_mean,da, ds_min, e, k, r, s_mean, t, w =iso10642def[ThreadType]
3536ePrax = s_mean / math.sqrt(3.0) / 0.99
3537ht = 0.0
3538a = 2*P
3539t_mean = t
3540else: #still need the data from iso2009def, but this screw can not created here
3541P, a, b, dk_theo, dk_mean, k, n_min, r, t_mean, x = iso2009def[ThreadType]
3542ht = 0.0 # Head height of flat head
3543if SType == 'ISO7046':
3544cT, mH, mZ = iso7046def[ThreadType]
3545if (SType == 'ISO7047'):
3546rf, t_mean, cT, mH, mZ = Raised_countersunk_def[ThreadType]
3547#Lengths and angles for calculation of head rounding
3548beta = math.asin(dk_mean /2.0 / rf) # angle of head edge
3549tan_beta = math.tan(beta)
3550alpha = beta/2.0 # half angle
3551# height of raised head top
3552ht = rf - (dk_mean/2.0) / tan_beta
3553#print 'he: ', he
3554h_arc_x = rf * math.sin(alpha)
3555h_arc_z = ht - rf + rf * math.cos(alpha)
3556#FreeCAD.Console.PrintMessage("h_arc_z: " + str(h_arc_z) + "\n")
3557
3558if (SType == 'ISO14582'):
3559P, a, b, dk_theo, dk_mean, k, r, tt, A, t_mean = iso14582def[ThreadType]
3560ePrax = A / 2.0 / 0.99
3561
3562if (SType == 'ISO14584'):
3563P, b, dk_theo, dk_mean, f, k, r, rf, x, tt, A, t_mean = iso14584def[ThreadType]
3564ePrax = A / 2.0 / 0.99
3565#Lengths and angles for calculation of head rounding
3566beta = math.asin(dk_mean /2.0 / rf) # angle of head edge
3567tan_beta = math.tan(beta)
3568ctp = - (dk_mean/2.0) / tan_beta # Center Top Edge = center for rf
3569betaA = math.asin(ePrax / rf) # angle of head edge at start of recess
3570ht = ctp + ePrax / math.tan(betaA)
3571alpha = betaA + (beta - betaA)/2.0 # half angle of top Arc
3572h_arc_x = rf * math.sin(alpha)
3573h_arc_z = ctp + rf * math.cos(alpha)
3574
3575
3576FreeCAD.Console.PrintMessage("The head with iso r: " + str(r) + "\n")
3577cham = (dk_theo - dk_mean)/2.0
3578rad225 = math.radians(22.5)
3579rad45 = math.radians(45.0)
3580rtan = r*math.tan(rad225)
3581#FreeCAD.Console.PrintMessage("Checking rtan: " + str(rtan) + "\n")
3582
3583if (b > (l - k - rtan/2.0 - 1.0*P)):
3584bmax = l - k - rtan/2.0 - 1.0*P
3585else:
3586bmax = b
3587
3588### make the new code with math.modf(l)
3589residue, turns = math.modf((bmax)/P)
3590halfturns = 2*int(turns)
3591if residue < 0.5:
3592a_point = l - (turns+1.0) * P
3593halfturns = halfturns +1
3594else:
3595halfturns = halfturns + 2
3596a_point = l - (turns+2.0) * P
3597#halfturns = halfturns + 2
3598offSet = k + rtan - a_point
3599
3600#Head Points
3601Pnt1 = Base.Vector(dk_mean/2.0,0.0,0.0)
3602Pnt2 = Base.Vector(dk_mean/2.0,0.0,-cham)
3603Pnt3 = Base.Vector(dia/2.0+r-r*math.cos(rad45),0.0,-k-rtan+r*math.sin(rad45))
3604
3605# Arc-points
3606Pnt4 = Base.Vector(dia/2.0+r-r*(math.cos(rad225)),0.0,-k-rtan+r*math.sin(rad225))
3607Pnt5 = Base.Vector(dia/2.0,0.0,-k-rtan)
3608Pnt6 = Base.Vector(dia/2.0,0.0,-a_point)
3609
3610if (SType == 'ISO10642') or (SType == 'ISO14582'):
3611if (SType == 'ISO10642'):
3612recess, recessShell = self.makeAllen2(s_mean, t_mean, 0.0 )
3613Pnt0 = Base.Vector(ePrax/2.0,0.0,-ePrax/2.0)
3614PntCham = Base.Vector(ePrax,0.0,0.0)
3615edge1 = Part.makeLine(Pnt0,PntCham)
3616edgeCham2 = Part.makeLine(PntCham,Pnt1)
3617edge2 = Part.makeLine(Pnt1,Pnt2)
3618edge2 = Part.Wire([edgeCham2,edge2])
3619PntH0 = Base.Vector(ePrax/2.0,0.0, ht + k)
3620PntH1 = Base.Vector(ePrax,0.0, ht + k)
3621if (SType == 'ISO14582'):
3622recess, recessShell = self.makeIso10664_3(tt, t_mean, 0.0) # hexalobular recess
3623Pnt0 = Base.Vector(0.0,0.0,0.0)
3624edge1 = Part.makeLine(Pnt0,Pnt1)
3625edge2 = Part.makeLine(Pnt1,Pnt2)
3626
3627
3628# bolt points with bolt chamfer
3629cham_b = P*math.sqrt(3.0)/2.0*17.0/24.0
3630
3631PntB1 = Base.Vector(dia/2.0,0.0,-l+cham_b)
3632PntB2 = Base.Vector(dia/2.0-cham_b,0.0,-l)
3633PntB3 = Base.Vector(0.0,0.0,-l)
3634if a_point <= (k + rtan):
3635edgeB0 = Part.makeLine(Pnt5,PntB1)
3636else:
3637edgeB0 = Part.makeLine(Pnt6,PntB1)
3638edgeB2 = Part.makeLine(PntB1,PntB2)
3639edgeB3 = Part.makeLine(PntB2,PntB3)
3640edgeB1 = Part.Wire([edgeB2,edgeB3])
3641
3642else:
3643# bolt points
3644PntB1 = Base.Vector(dia/2.0,0.0,-l)
3645PntB2 = Base.Vector(0.0,0.0,-l)
3646if a_point <= (k + rtan):
3647edgeB0 = Part.makeLine(Pnt5,PntB1)
3648else:
3649edgeB0 = Part.makeLine(Pnt6,PntB1)
3650edgeB1 = Part.makeLine(PntB1,PntB2)
3651
3652if (SType == 'ISO7047'): # make raised head rounding
3653Pnt0 = Base.Vector(0.0,0.0,ht)
3654Pnt0arc = Base.Vector(h_arc_x,0.0,h_arc_z)
3655edge1 = Part.Arc(Pnt0,Pnt0arc,Pnt1).toShape()
3656edge2 = Part.makeLine(Pnt1,Pnt2)
3657PntH0 = Base.Vector(0.0,0.0, ht + k)
3658PntH1 = Base.Vector(dk_mean/2.0,0.0, ht + k)
3659recess, recessShell = self.makeCross_H3(cT, mH, ht)
3660if (SType == 'ISO7046'):
3661# ISO7046
3662FreeCAD.Console.PrintMessage("ISO7046: " + str(ht) + "\n")
3663Pnt0 = Base.Vector(0.0,0.0,ht)
3664edge1 = Part.makeLine(Pnt0,Pnt1) # make flat head
3665edge2 = Part.makeLine(Pnt1,Pnt2)
3666recess, recessShell = self.makeCross_H3(cT, mH, ht)
3667
3668if (SType == 'ISO14584'): # make raised head rounding with chamfer
3669Pnt0 = Base.Vector(ePrax/2.0,0.0,ht-ePrax/4.0)
3670PntCham = Base.Vector(ePrax,0.0,ht)
3671PntArc = Base.Vector(h_arc_x,0.0,h_arc_z)
3672edge1 = Part.makeLine(Pnt0,PntCham)
3673edgeArc = Part.Arc(PntCham,PntArc,Pnt1).toShape()
3674edge2 = Part.makeLine(Pnt1,Pnt2)
3675edge2 = Part.Wire([edgeArc,edge2])
3676PntH0 = Base.Vector(ePrax/2.0,0.0, ht + k)
3677PntH1 = Base.Vector(ePrax,0.0, ht + k)
3678recess, recessShell = self.makeIso10664_3(tt, t_mean, ht) # hexalobular recess
3679
3680edge3 = Part.makeLine(Pnt2,Pnt3)
3681edgeArc = Part.Arc(Pnt3,Pnt4,Pnt5).toShape()
3682edgeArc1 = Part.makeLine(Pnt3,Pnt4)
3683edgeArc2 = Part.makeLine(Pnt4,Pnt5)
3684edge6 = Part.makeLine(Pnt5,Pnt6)
3685
3686if self.rThread:
3687#aWire=Part.Wire([edge1,edge2,edge3,edgeArc])
3688aWire=Part.Wire([edge2,edge3,edgeArc])
3689else:
3690if a_point <= (k + rtan):
3691aWire=Part.Wire([edge2,edge3,edgeArc, edgeB0, edgeB1])
3692else:
3693aWire=Part.Wire([edge2,edge3,edgeArc,edge6, edgeB0, edgeB1])
3694
3695#Part.show(aWire)
3696headShell = aWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
3697headFaces = headShell.Faces
3698#Part.show(headShell)
3699
3700if (SType == 'ISO7046') or (SType == 'ISO14582'):
3701# hCut is just a cylinder for ISO7046
3702hCut = Part.makeCylinder(dk_mean/2.0,k,Pnt0)
3703#Part.show(hCut)
3704topFace = hCut.Faces[2]
3705else:
3706if (SType == 'ISO7047'):
3707edgeH1 = Part.makeLine(Pnt1,PntH1)
3708else:
3709edgeH1 = Part.makeLine(PntCham,PntH1)
3710edgeH2 = Part.makeLine(PntH1,PntH0)
3711edgeH3 = Part.makeLine(PntH0,Pnt0)
3712hWire = Part.Wire([edge1,edgeH1,edgeH2,edgeH3]) # Cutter for recess-Shell
3713hFace = Part.Face(hWire)
3714hCut = hFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
3715Part.show(hWire)
3716#Part.show(hCut)
3717topFace = hCut.Faces[0]
3718
3719recessShell = recessShell.cut(hCut)
3720topFace = topFace.cut(recess)
3721#Part.show(topFace)
3722#Part.show(recessShell)
3723#Part.show(headShell)
3724headFaces.append(topFace.Faces[0])
3725headFaces.extend(recessShell.Faces)
3726
3727
3728if (SType == 'ISO10642') or (SType == 'ISO14582'):
3729if self.rThread:
3730if (dia < 3.0) or (dia > 5.0):
3731#if True:
3732rthread = self.makeShellthread(dia, P, halfturns, True, offSet)
3733rthread.translate(Base.Vector(0.0, 0.0,-a_point -2.0*P))
3734#head = head.fuse(rthread)
3735#Part.show(rthread)
3736for threadFace in rthread.Faces:
3737headFaces.append(threadFace)
3738
3739screwShell = Part.Shell(headFaces)
3740screw = Part.Solid(screwShell)
3741else:
3742'''
3743# head = self.cutIsoThread(head, dia, P, turns, l)
3744rthread = self.makeShellthread(dia, P, halfturns, False)
3745rthread.translate(Base.Vector(0.0, 0.0,-a_point-2.0*P))
3746head = head.fuse(rthread)
3747head = head.removeSplitter()
3748cyl = self.cutChamfer(dia, P, l)
3749#FreeCAD.Console.PrintMessage("vor Schnitt Ende: " + str(dia) + "\n")
3750head = head.cut(cyl)
3751'''
3752
3753rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
3754rthread.translate(Base.Vector(0.0, 0.0,-a_point -2.0*P))
3755#head = head.fuse(rthread)
3756#Part.show(rthread)
3757for threadFace in rthread.Faces:
3758headFaces.append(threadFace)
3759
3760screwShell = Part.Shell(headFaces)
3761screw = Part.Solid(screwShell)
3762cyl = self.cutChamfer(dia, P, l)
3763screw = screw.cut(cyl)
3764else:
3765screwShell = Part.Shell(headFaces)
3766screw = Part.Solid(screwShell)
3767
3768else:
3769if self.rThread:
3770rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
3771rthread.translate(Base.Vector(0.0, 0.0,-a_point -2.0*P))
3772#head = head.fuse(rthread)
3773#Part.show(rthread)
3774for threadFace in rthread.Faces:
3775headFaces.append(threadFace)
3776
3777screwShell = Part.Shell(headFaces)
3778screw = Part.Solid(screwShell)
3779
3780return screw
3781
3782def makeIso4762(self, SType ='ISO4762', ThreadType ='M6',l=25.0):
3783"""ISO 4762 Allen Screw head and ISO 14579 Hexalobular socket head cap
3784"""
3785dia = get_diameter(ThreadType)
3786#FreeCAD.Console.PrintMessage("der 4762Kopf mit l: " + str(l) + "\n")
3787P, b, dk_max, da, ds_mean, e, lf, k, r, s_mean, t, v, dw, w = iso4762def[ThreadType]
3788#FreeCAD.Console.PrintMessage("der Kopf mit iso r: " + str(r) + "\n")
3789if SType == 'ISO14579':
3790tt, A, t = iso14579def[ThreadType]
3791#Head Points 30° countersunk
3792# Pnt0 = Base.Vector(0.0,0.0,k-A/4.0) #Center Point for countersunk
3793Pnt0 = Base.Vector(0.0,0.0,k-A/8.0) #Center Point for flat countersunk
3794PntFlat = Base.Vector(A/8.0,0.0,k-A/8.0) # End of flat part
3795Pnt1 = Base.Vector(A/1.99,0.0,k) #countersunk edge at head
3796edgeCham0 = Part.makeLine(Pnt0,PntFlat)
3797edgeCham1 = Part.makeLine(PntFlat,Pnt1)
3798edge1 = Part.Wire([edgeCham0,edgeCham1])
3799
3800# Here is the next approach to shorten the head building time
3801# Make two helper points to create a cutting tool for the
3802# recess and recess shell.
3803PntH1 = Base.Vector(A/1.99,0.0, 2.0*k)
3804
3805else:
3806e_cham = 2.0 * s_mean / math.sqrt(3.0)
3807#Head Points 45° countersunk
3808Pnt0 = Base.Vector(0.0,0.0,k-e_cham/1.99/2.0) #Center Point for countersunk
3809PntFlat = Base.Vector(e_cham/1.99/2.0,0.0,k-e_cham/1.99/2.0) # End of flat part
3810Pnt1 = Base.Vector(e_cham/1.99,0.0,k) #countersunk edge at head
3811edgeCham0 = Part.makeLine(Pnt0,PntFlat)
3812edgeCham1 = Part.makeLine(PntFlat,Pnt1)
3813edge1 = Part.Wire([edgeCham0,edgeCham1])
3814PntH1 = Base.Vector(e_cham/1.99,0.0, 2.0*k)
3815
3816
3817PntH2 = Base.Vector(0.0,0.0, 2.0*k)
3818edgeH1 = Part.makeLine(Pnt1,PntH1)
3819edgeH2 = Part.makeLine(PntH1,PntH2)
3820edgeH3 = Part.makeLine(PntH2,Pnt0)
3821hWire = Part.Wire([edge1,edgeH1,edgeH2,edgeH3]) # Cutter for recess-Shell
3822hFace = Part.Face(hWire)
3823hCut = hFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
3824#Part.show(hWire)
3825'''
3826
3827
3828PntH2 = Base.Vector(A/8.0,0.0, 2.0*k)
3829edgeH1 = Part.makeLine(Pnt1,PntH1)
3830edgeH2 = Part.makeLine(PntH1,PntH2)
3831edgeH3 = Part.makeLine(PntH2,PntFlat)
3832hWire = Part.Wire([edgeCham1,edgeH1,edgeH2,edgeH3]) # Cutter for recess-Shell
3833hFace = Part.Face(hWire)
3834hCut = hFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
3835#Part.show(hWire)
3836'''
3837
3838
3839sqrt2_ = 1.0/math.sqrt(2.0)
3840#depth = s_mean / 3.0
3841
3842'''
3843if (b > l - 2*P):
3844bmax = l-2*P
3845else:
3846bmax = b
3847halfturns = round(2.0*(bmax+P)/P) # number of thread turns
3848if self.RealThread.isChecked():
3849a_real = l-(halfturns+2)*P/2.0 # point to fuse real thread
3850else:
3851a_real = l-halfturns*P/2.0 # starting point of thread
3852if a_real < r:
3853a_point = r*1.3
3854else:
3855a_point = a_real
3856'''
3857
3858
3859if (b > (l - 1.0*P)):
3860bmax = l- 1.0*P
3861else:
3862bmax = b
3863
3864### make the new code with math.modf(l)
3865residue, turns = math.modf((bmax)/P)
3866halfturns = 2*int(turns)
3867if residue < 0.5:
3868a_point = l - (turns+1.0) * P
3869halfturns = halfturns +1
3870else:
3871halfturns = halfturns + 2
3872a_point = l - (turns+2.0) * P
3873#halfturns = halfturns + 2
3874offSet = r - a_point
3875#FreeCAD.Console.PrintMessage("The transition at a: " + str(a) + " turns " + str(turns) + "\n")
3876
3877
3878
3879
3880#rad30 = math.radians(30.0)
3881#Head Points
3882Pnt2 = Base.Vector(dk_max/2.0-v,0.0,k) #start of fillet
3883Pnt3 = Base.Vector(dk_max/2.0-v+v*sqrt2_,0.0,k-v+v*sqrt2_) #arc-point of fillet
3884Pnt4 = Base.Vector(dk_max/2.0,0.0,k-v) #end of fillet
3885Pnt5 = Base.Vector(dk_max/2.0,0.0,(dk_max-dw)/2.0) #we have a chamfer here
3886Pnt6 = Base.Vector(dw/2.0,0.0,0.0) #end of chamfer
3887Pnt7 = Base.Vector(dia/2.0+r,0.0,0.0) #start of fillet between head and shank
3888Pnt8 = Base.Vector(dia/2.0+r-r*sqrt2_,0.0,-r+r*sqrt2_) #arc-point of fillet
3889Pnt9 = Base.Vector(dia/2.0,0.0,-r) # end of fillet
3890Pnt10 = Base.Vector(dia/2.0,0.0,-a_point) # start of thread
3891
3892edge1 = Part.makeLine(Pnt0,Pnt1)
3893edge2 = Part.makeLine(Pnt1,Pnt2)
3894edge3 = Part.Arc(Pnt2,Pnt3,Pnt4).toShape()
3895edge4 = Part.makeLine(Pnt4,Pnt5)
3896edge5 = Part.makeLine(Pnt5,Pnt6)
3897edge6 = Part.makeLine(Pnt6,Pnt7)
3898edge7 = Part.Arc(Pnt7,Pnt8,Pnt9).toShape()
3899
3900'''
3901# bolt points
3902PntB1 = Base.Vector(dia/2.0,0.0,-l-P) # Chamfer is made with a cut later
3903PntB2 = Base.Vector(0.0,0.0,-l-P)
3904#PntB3 = Base.Vector(0.0,0.0,-l)
3905
3906edgeB0 = Part.makeLine(Pnt10,PntB1)
3907edgeB1 = Part.makeLine(PntB1,PntB2)
3908#edgeB2 = Part.makeLine(PntB2,PntB3)
3909edgeZ0 = Part.makeLine(PntB2,Pnt0)
3910
3911
3912aWire=Part.Wire([edge1,edge2,edge3,edge4,edge5,edge6,edge7,edge8, \
3913edgeB0, edgeB1, edgeZ0])
3914'''
3915
3916
3917
3918if self.rThread:
3919aWire=Part.Wire([edge2,edge3,edge4,edge5,edge6,edge7])
3920
3921else:
3922# bolt points
3923cham_t = P*math.sqrt(3.0)/2.0*17.0/24.0
3924
3925PntB1 = Base.Vector(dia/2.0,0.0,-l+cham_t)
3926PntB2 = Base.Vector(dia/2.0-cham_t,0.0,-l)
3927PntB3 = Base.Vector(0.0,0.0,-l)
3928
3929#edgeB1 = Part.makeLine(Pnt10,PntB1)
3930edgeB2 = Part.makeLine(PntB1,PntB2)
3931edgeB3 = Part.makeLine(PntB2,PntB3)
3932
3933if a_point <= r:
3934edgeB1 = Part.makeLine(Pnt9,PntB1)
3935aWire=Part.Wire([edge2,edge3,edge4,edge5,edge6,edge7, \
3936edgeB1, edgeB2, edgeB3])
3937else:
3938edge8 = Part.makeLine(Pnt9,Pnt10)
3939edgeB1 = Part.makeLine(Pnt10,PntB1)
3940aWire=Part.Wire([edge2,edge3,edge4,edge5,edge6,edge7,edge8, \
3941edgeB1, edgeB2, edgeB3])
3942#Part.show(aWire)
3943
3944headShell = aWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
3945#head = Part.Solid(headShell)
3946#Part.show(aWire)
3947#FreeCAD.Console.PrintMessage("der Kopf mit revolve: " + str(dia) + "\n")
3948headFaces = headShell.Faces
3949
3950
3951if SType == 'ISO14579':
3952#recess = self.makeIso10664(tt, t, k) # hexalobular recess
3953recess, recessShell = self.makeIso10664_3(tt, t, k) # hexalobular recess
3954else:
3955recess, recessShell = self.makeAllen2(s_mean, t, k )
3956
3957recessShell = recessShell.cut(hCut)
3958topFace = hCut.Faces[1]
3959#topFace = hCut.Faces[0]
3960topFace = topFace.cut(recess)
3961#Part.show(topFace)
3962#Part.show(recessShell)
3963#Part.show(headShell)
3964headFaces.append(topFace.Faces[0])
3965#headFaces.append(hCut.Faces[2])
3966
3967#allenscrew = head.cut(recess)
3968#Part.show(hCut)
3969headFaces.extend(recessShell.Faces)
3970
3971#if self.RealThread.isChecked():
3972if self.rThread:
3973#if (dia < 3.0) or (dia > 5.0):
3974if True:
3975# head = self.cutIsoThread(head, dia, P, turns, l)
3976rthread = self.makeShellthread(dia, P, halfturns, True, offSet)
3977rthread.translate(Base.Vector(0.0, 0.0,-a_point-2.0*P))
3978#Part.show(rthread)
3979for tFace in rthread.Faces:
3980headFaces.append(tFace)
3981headShell = Part.Shell(headFaces)
3982allenscrew = Part.Solid(headShell)
3983
3984else:
3985# head = self.cutIsoThread(head, dia, P, turns, l)
3986rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
3987rthread.translate(Base.Vector(0.0, 0.0,-a_point-2.0*P))
3988for tFace in rthread.Faces:
3989headFaces.append(tFace)
3990headShell = Part.Shell(headFaces)
3991allenscrew = Part.Solid(headShell)
3992cyl = self.cutChamfer(dia, P, l)
3993# FreeCAD.Console.PrintMessage("vor Schnitt Ende: " + str(dia) + "\n")
3994allenscrew = allenscrew.cut(cyl)
3995else:
3996headShell = Part.Shell(headFaces)
3997allenscrew = Part.Solid(headShell)
3998
3999
4000return allenscrew
4001
4002
4003
4004
4005# make ISO 7380-1 Button head Screw
4006# make ISO 7380-2 Button head Screw with collar
4007# make DIN 967 cross recessed pan head Screw with collar
4008def makeIso7380(self, SType ='ISO7380-1', ThreadType ='M6',l=25.0):
4009dia = get_diameter(ThreadType)
4010#todo: different radii for screws with thread to head or with shaft?
4011sqrt2_ = 1.0/math.sqrt(2.0)
4012
4013if (SType =='DIN967'):
4014P, b, c, da, dk, r, k, rf, x, cT, mH, mZ = din967def[ThreadType]
4015
4016rH = rf # radius of button arc
4017alpha = math.acos((rf-k+c)/rf)
4018
4019#Head Points
4020Pnt0 = Base.Vector(0.0,0.0,k)
4021PntArc = Base.Vector(rf*math.sin(alpha/2.0),0.0,k-rf + rf*math.cos(alpha/2.0)) #arc-point of button
4022Pnt1 = Base.Vector(rf*math.sin(alpha),0.0,c) #end of button arc
4023PntC0 = Base.Vector((dk)/2.0,0.0,c) #collar points
4024PntC2 = Base.Vector((dk)/2.0,0.0,0.0) #collar points
4025Pnt4 = Base.Vector(dia/2.0+r,0.0,0.0) #start of fillet between head and shank
4026
4027edge1 = Part.Arc(Pnt0,PntArc,Pnt1).toShape()
4028edgeC0 = Part.makeLine(Pnt1,PntC0)
4029edgeC1 = Part.makeLine(PntC0,PntC2)
4030edge2 = Part.Wire([edgeC0, edgeC1])
4031edge3 = Part.makeLine(PntC2,Pnt4)
4032#Points for recessShell cutter
4033PntH0 = Base.Vector(0.0,0.0,2.0*k)
4034PntH1 = Base.Vector(rf*math.sin(alpha),0.0,2.0*k)
4035recess, recessShell = self.makeCross_H3(cT, mH, k)
4036
4037else:
4038if (SType =='ISO7380-1'):
4039P, b, a, da, dk, dk_mean,s_mean, t_min, r, k, e, w = iso7380def[ThreadType]
4040
4041# Bottom of recess
4042e_cham = 2.0 * s_mean / math.sqrt(3.0) / 0.99
4043#depth = s_mean / 3.0
4044
4045ak = -(4*k**2 + e_cham**2 - dk**2)/(8*k) # helper value for button arc
4046rH = math.sqrt((dk/2.0)**2 + ak**2) # radius of button arc
4047alpha = (math.atan(2*(k + ak)/e_cham) + math.atan((2*ak)/dk))/2
4048
4049Pnt2 = Base.Vector(rH*math.cos(alpha),0.0,-ak + rH*math.sin(alpha)) #arc-point of button
4050Pnt3 = Base.Vector(dk/2.0,0.0,0.0) #end of fillet
4051Pnt4 = Base.Vector(dia/2.0+r,0.0,0.0) #start of fillet between head and shank
4052edge3 = Part.makeLine(Pnt3,Pnt4)
4053
4054if (SType =='ISO7380-2'):
4055P, b, c, da, dk, dk_c,s_mean,t_min, r, k, e, w = iso7380_2def[ThreadType]
4056
4057# Bottom of recess
4058e_cham = 2.0 * s_mean / math.sqrt(3.0) / 0.99
4059#depth = s_mean / 3.0
4060
4061ak = -(4*(k-c)**2 + e_cham**2 - dk**2)/(8*(k-c)) # helper value for button arc
4062rH = math.sqrt((dk/2.0)**2 + ak**2) # radius of button arc
4063alpha = (math.atan(2*(k -c + ak)/e_cham) + math.atan((2*ak)/dk))/2
4064
4065Pnt2 = Base.Vector(rH*math.cos(alpha),0.0,c -ak + rH*math.sin(alpha)) #arc-point of button
4066Pnt3 = Base.Vector(dk/2.0,0.0,c) #end of fillet
4067Pnt4 = Base.Vector(dia/2.0+r,0.0,0.0) #start of fillet between head and shank
4068PntC0 = Base.Vector((dk_c-c)/2.0,0.0,c) #collar points
4069PntC1 = Base.Vector(dk_c/2.0,0.0,c/2.0) #collar points
4070PntC2 = Base.Vector((dk_c-c)/2.0,0.0,0.0) #collar points
4071
4072edgeC0 = Part.makeLine(Pnt3,PntC0)
4073edgeC1 = Part.Arc(PntC0,PntC1,PntC2).toShape()
4074edge3 = Part.makeLine(PntC2,Pnt4)
4075edge3 = Part.Wire([edgeC0, edgeC1, edge3])
4076
4077#Head Points
4078Pnt0 = Base.Vector(e_cham/4.0,0.0,k-e_cham/4.0) #Center Point for chamfer
4079Pnt1 = Base.Vector(e_cham/2.0,0.0,k) #inner chamfer edge at head
4080#Points for recessShell cutter
4081PntH0 = Base.Vector(e_cham/4.0,0.0,2.0*k)
4082PntH1 = Base.Vector(e_cham/2.0,0.0,2.0*k)
4083
4084edge1 = Part.makeLine(Pnt0,Pnt1)
4085edge2 = Part.Arc(Pnt1,Pnt2,Pnt3).toShape()
4086recess, recessShell = self.makeAllen2(s_mean, t_min, k)
4087
4088if (b > (l - 1.0*P)):
4089bmax = l- 1.0*P
4090else:
4091bmax = b
4092
4093### make the new code with math.modf(l)
4094residue, turns = math.modf((bmax)/P)
4095halfturns = 2*int(turns)
4096if residue < 0.5:
4097a_point = l - (turns+1.0) * P
4098halfturns = halfturns +1
4099else:
4100halfturns = halfturns + 2
4101a_point = l - (turns+2.0) * P
4102offSet = r - a_point
4103
4104
4105Pnt5 = Base.Vector(dia/2.0+r-r*sqrt2_,0.0,-r+r*sqrt2_) #arc-point of fillet
4106Pnt6 = Base.Vector(dia/2.0,0.0,-r) # end of fillet
4107Pnt7 = Base.Vector(dia/2.0,0.0,-a_point) # start of thread
4108
4109edge4 = Part.Arc(Pnt4,Pnt5,Pnt6).toShape()
4110edge5 = Part.makeLine(Pnt6,Pnt7)
4111
4112if (SType =='DIN967'):
4113# bolt points
4114PntB1 = Base.Vector(dia/2.0,0.0,-l)
4115PntB2 = Base.Vector(0.0,0.0,-l)
4116edgeB2 = Part.makeLine(PntB1,PntB2)
4117else:
4118# bolt points
4119cham_b = P*math.sqrt(3.0)/2.0*17.0/24.0
4120
4121PntB1 = Base.Vector(dia/2.0,0.0,-l+cham_b)
4122PntB2 = Base.Vector(dia/2.0-cham_b,0.0,-l)
4123PntB3 = Base.Vector(0.0,0.0,-l)
4124
4125edgeB2 = Part.makeLine(PntB1,PntB2)
4126edgeB3 = Part.makeLine(PntB2,PntB3)
4127edgeB2 = Part.Wire([edgeB2, edgeB3])
4128
4129if self.rThread:
4130aWire=Part.Wire([edge2,edge3,edge4])
4131else:
4132if a_point <= r:
4133edgeB1 = Part.makeLine(Pnt6,PntB1)
4134aWire=Part.Wire([edge2,edge3,edge4, edgeB1, edgeB2])
4135else:
4136edge5 = Part.makeLine(Pnt6,Pnt7)
4137edgeB1 = Part.makeLine(Pnt7,PntB1)
4138aWire=Part.Wire([edge2,edge3,edge4,edge5, edgeB1, edgeB2])
4139
4140#Part.show(aWire)
4141headShell = aWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
4142#Part.show(headShell)
4143headFaces = headShell.Faces
4144
4145edgeH1 = Part.makeLine(Pnt1,PntH1)
4146edgeH2 = Part.makeLine(PntH1,PntH0)
4147edgeH3 = Part.makeLine(PntH0,Pnt0)
4148hWire = Part.Wire([edge1,edgeH1,edgeH2,edgeH3]) # Cutter for recess-Shell
4149hFace = Part.Face(hWire)
4150hCut = hFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
4151#Part.show(hWire)
4152topFace = hCut.Faces[0]
4153
4154recessShell = recessShell.cut(hCut)
4155topFace = topFace.cut(recess)
4156#Part.show(topFace)
4157#Part.show(recessShell)
4158#Part.show(headShell)
4159headFaces.append(topFace.Faces[0])
4160headFaces.extend(recessShell.Faces)
4161
4162
4163if self.rThread:
4164#if (dia < 3.0) or (dia > 5.0):
4165if True:
4166if (SType =='DIN967'):
4167rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
4168else:
4169rthread = self.makeShellthread(dia, P, halfturns, True, offSet)
4170rthread.translate(Base.Vector(0.0, 0.0,-a_point -2.0*P))
4171for threadFace in rthread.Faces:
4172headFaces.append(threadFace)
4173
4174screwShell = Part.Shell(headFaces)
4175screw = Part.Solid(screwShell)
4176else:
4177rthread = self.makeShellthread(dia, P, halfturns, False, offSet)
4178rthread.translate(Base.Vector(0.0, 0.0,-a_point -2.0*P))
4179for threadFace in rthread.Faces:
4180headFaces.append(threadFace)
4181
4182screwShell = Part.Shell(headFaces)
4183screw = Part.Solid(screwShell)
4184cyl = self.cutChamfer(dia, P, l)
4185screw = screw.cut(cyl)
4186else:
4187screwShell = Part.Shell(headFaces)
4188screw = Part.Solid(screwShell)
4189
4190return screw
4191
4192
4193
4194
4195def makeHextool(self,s_hex, k_hex, cir_hex):
4196# makes a cylinder with an inner hex hole, used as cutting tool
4197# create hexagon
4198mhex=Base.Matrix()
4199mhex.rotateZ(math.radians(60.0))
4200polygon = []
4201vhex=Base.Vector(s_hex/math.sqrt(3.0),0.0,-k_hex*0.1)
4202for i in range(6):
4203polygon.append(vhex)
4204vhex = mhex.multiply(vhex)
4205polygon.append(vhex)
4206hexagon = Part.makePolygon(polygon)
4207# create circle
4208circ = Part.makeCircle(cir_hex/2.0, Base.Vector(0.0,0.0,-k_hex*0.1), self.circleAxis)
4209# Create the face with the circle as outline and the hexagon as hole
4210face=Part.Face([Part.Wire(circ),hexagon])
4211
4212# Extrude in z to create the final cutting tool
4213exHex=face.extrude(Base.Vector(0.0,0.0,k_hex*1.2))
4214# Part.show(exHex)
4215return exHex
4216
4217
4218def makeShellthread(self, d, P, halfrots, withcham, offSet):
4219d = float(d)
4220
4221#rotations = int(rots)-1
4222halfrots_int = int(halfrots)
4223rotations = (halfrots_int // 2) - 1
4224if halfrots_int % 2 == 1:
4225#FreeCAD.Console.PrintMessage("got half turn: " + str(halfrots_int) + "\n")
4226halfturn = True
4227# bot_off = - P/2.0 # transition of half a turn
4228bot_off = 0.0 # nominal length
4229else:
4230halfturn = False
4231bot_off = 0.0 # nominal length
4232
4233H=P*math.cos(math.radians(30)) # Gewindetiefe H
4234r=d/2.0
4235
4236# helix = Part.makeHelix(P,P,d*511/1000.0,0) # make just one turn, length is identical to pitch
4237helix = Part.makeHelix(P,P,d*self.Tuner/1000.0,0) # make just one turn, length is identical to pitch
4238helix.translate(FreeCAD.Vector(0.0, 0.0,-P*9.0/16.0))
4239
4240extra_rad = P
4241# points for screw profile
4242ps0 = (r,0.0, 0.0)
4243ps1 = (r-H*5.0/8.0,0.0, -P*5.0/16.0)
4244ps2 = (r-H*17.0/24.0,0.0, -P*7.0/16.0) # Center of Arc
4245ps3 = (r-H*5.0/8.0,0.0, -P*9.0/16.0 )
4246ps4 = (r, 0.0, -P*14.0/16.0)
4247ps5 = (r,0.0, -P)
4248ps6 = (r+extra_rad,0.0, -P)
4249ps7 = (r+extra_rad,0.0, 0.0)
4250
4251edge0 = Part.makeLine(ps0,ps1)
4252edge1 = Part.Arc(FreeCAD.Vector(ps1),FreeCAD.Vector(ps2),FreeCAD.Vector(ps3)).toShape()
4253edge2 = Part.makeLine(ps3,ps4)
4254edge3 = Part.makeLine(ps4,ps5)
4255edge4 = Part.makeLine(ps5,ps6)
4256edge5 = Part.makeLine(ps6,ps7)
4257edge6 = Part.makeLine(ps7,ps0)
4258
4259W0 = Part.Wire([edge0, edge1, edge2, edge3, edge4, edge5, edge6])
4260
4261makeSolid=True
4262isFrenet=True
4263pipe0 = Part.Wire(helix).makePipeShell([W0],makeSolid,isFrenet)
4264# pipe1 = pipe0.copy()
4265
4266TheFaces = []
4267TheFaces.append(pipe0.Faces[0])
4268#Part.show(pipe0.Faces[0])
4269TheFaces.append(pipe0.Faces[1])
4270#Part.show(pipe0.Faces[1])
4271TheFaces.append(pipe0.Faces[2])
4272#Part.show(pipe0.Faces[2])
4273TheFaces.append(pipe0.Faces[3])
4274#Part.show(pipe0.Faces[3])
4275
4276TheShell = Part.Shell(TheFaces)
4277# print "Shellpoints: ", len(TheShell.Vertexes)
4278
4279
4280i = 1
4281for i in range(rotations-2):
4282TheShell.translate(FreeCAD.Vector(0.0, 0.0, -P))
4283
4284for flaeche in TheShell.Faces:
4285TheFaces.append(flaeche)
4286
4287#FreeCAD.Console.PrintMessage("Base-Shell: " + str(i) + "\n")
4288# Make separate faces for the tip of the screw
4289botFaces = []
4290for i in range(rotations-2, rotations, 1):
4291TheShell.translate(FreeCAD.Vector(0.0, 0.0, -P))
4292
4293for flaeche in TheShell.Faces:
4294botFaces.append(flaeche)
4295#FreeCAD.Console.PrintMessage("Bottom-Shell: " + str(i) + "\n")
4296
4297# making additional faces for transition to cylinder
4298
4299pc1 = (r + H/16.0,0.0,P*1/32.0)
4300pc2 = (r-H*5.0/8.0,0.0,-P*5.0/16.0 )
4301pc3 = (r-H*17.0/24.0,0.0, -P*7.0/16.0 ) # Center of Arc
4302pc4 = (r-H*5.0/8.0,0.0, -P*9.0/16.0 )
4303pc5 = (r+ H/16.0, 0.0, -P*29.0/32.0 )
4304
4305edgec0 = Part.makeLine(pc5,pc1)
4306edgec1 = Part.makeLine(pc1,pc2)
4307edgec2 = Part.Arc(FreeCAD.Vector(pc2),FreeCAD.Vector(pc3),FreeCAD.Vector(pc4)).toShape()
4308edgec3 = Part.makeLine(pc4,pc5)
4309
4310cut_profile = Part.Wire([edgec1, edgec2, edgec3, edgec0 ])
4311
4312alpha_rad = math.atan(2*H*17.0/24.0/P)
4313alpha = math.degrees(alpha_rad)
4314Hyp = P/math.cos(alpha_rad)
4315# tuning = 511/1000.0
4316tuning = self.Tuner/1000.0
4317angled_Helix = Part.makeHelix(Hyp,Hyp*1.002/2.0,d*tuning,alpha)
4318
4319SH_faces = []
4320
4321if halfturn:
4322half_Helix = Part.makeHelix(P,P/2.0,d*self.Tuner/1000.0,0) # make just half a turn
4323angled_Helix.rotate(Base.Vector(0,0,0),Base.Vector(0,0,1),180)
4324angled_Helix.translate(FreeCAD.Vector(0.0, 0.0,P/2.0))
4325# Part.show(half_Helix)
4326# Part.show(angled_Helix)
4327pipe_cut = Part.Wire([half_Helix, angled_Helix]).makePipeShell([cut_profile],True,isFrenet)
4328SH_faces.append(pipe_cut.Faces[0])
4329SH_faces.append(pipe_cut.Faces[1])
4330SH_faces.append(pipe_cut.Faces[2])
4331SH_faces.append(pipe_cut.Faces[4])
4332SH_faces.append(pipe_cut.Faces[5])
4333SH_faces.append(pipe_cut.Faces[6])
4334
4335else:
4336pipe_cut = Part.Wire(angled_Helix).makePipeShell([cut_profile],True,isFrenet)
4337SH_faces.append(pipe_cut.Faces[0])
4338SH_faces.append(pipe_cut.Faces[1])
4339SH_faces.append(pipe_cut.Faces[2])
4340
4341# Part.show(pipe_cut)
4342
4343
4344Shell_helix = Part.Shell(SH_faces)
4345
4346# rect_helix_profile, needed for cutting a tube-shell
4347pr1 = (r +H/16.0, 0.0, 0.0)
4348pr2 = (r -H/16.0, 0.0, 0.0)
4349pr3 = (r -H/16.0, 0.0, P)
4350pr4 = (r +H/16.0, 0.0, P)
4351
4352edge_r1 = Part.makeLine(pr1,pr2)
4353edge_r2 = Part.makeLine(pr2,pr3)
4354edge_r3 = Part.makeLine(pr3,pr4)
4355edge_r4 = Part.makeLine(pr4,pr1)
4356rect_profile = Part.Wire([edge_r1, edge_r2, edge_r3, edge_r4 ])
4357rect_helix = Part.Wire(helix).makePipeShell([rect_profile], True, isFrenet)
4358# if halfturn:
4359# rect_helix.rotate(Base.Vector(0,0,0),Base.Vector(0,0,1),180)
4360rect_helix.translate(FreeCAD.Vector(0.0, 0.0,- P))
4361# Part.show(rect_helix)
4362
4363# rect_ring, needed for cutting the Shell_helix
4364pr5 = (r +H*1.1, 0.0, P*1.1)
4365pr6 = (r, 0.0, P*1.1)
4366pr7 = (r, 0.0, -P*1.1)
4367pr8 = (r +H*1.1, 0.0, -P*1.1)
4368
4369edge_r5 = Part.makeLine(pr5,pr6)
4370edge_r6 = Part.makeLine(pr6,pr7)
4371edge_r7 = Part.makeLine(pr7,pr8)
4372edge_r8 = Part.makeLine(pr8,pr5)
4373rect_profile = Part.Wire([edge_r5, edge_r6, edge_r7, edge_r8 ])
4374
4375rect_Face =Part.Face(rect_profile)
4376rect_ring= rect_Face.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
4377#Part.show(rect_ring)
4378
4379Shell_helix = Shell_helix.cut(rect_ring)
4380Shell_helix.translate(FreeCAD.Vector(0.0, 0.0, P))
4381# Part.show(Shell_helix)
4382
4383# shell_ring, the transition to a cylinder
4384pr9 = (r, 0.0, P-offSet)
4385pr10 = (r, 0.0, -P )
4386edge_r9 = Part.makeLine(pr9,pr10)
4387shell_ring= edge_r9.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
4388
4389shell_ring = shell_ring.cut(pipe_cut)
4390#Part.show(shell_ring)
4391shell_ring = shell_ring.cut(rect_helix)
4392shell_ring.translate(FreeCAD.Vector(0.0, 0.0, P))
4393#Part.show(shell_ring)
4394
4395for flaeche in shell_ring.Faces:
4396TheFaces.append(flaeche)
4397
4398for flaeche in Shell_helix.Faces:
4399TheFaces.append(flaeche)
4400
4401if withcham:
4402#FreeCAD.Console.PrintMessage("with chamfer: " + str(i) + "\n")
4403# cutting of the bottom Faces
4404# bot_off = 0.0 # nominal length
4405cham_off = H/8.0
4406cham_t = P*math.sqrt(3.0)/2.0*17.0/24.0
4407
4408# points for chamfer: common-Method
4409pch0 = (0.0, 0.0, -(rotations)*P + bot_off) # bottom center
4410pch1 = (r-cham_t,0.0, -(rotations)*P + bot_off)
4411pch2 = (r+cham_off, 0.0, -(rotations)*P + cham_t +cham_off + bot_off)
4412pch3 = (r+cham_off, 0.0, -(rotations)*P + 3.0*P + bot_off)
4413pch4 = (0.0, 0.0, -(rotations)*P + 3.0*P + bot_off)
4414
4415edgech0 = Part.makeLine(pch0,pch1)
4416edgech1 = Part.makeLine(pch1,pch2)
4417edgech2 = Part.makeLine(pch2,pch3)
4418edgech3 = Part.makeLine(pch3,pch4)
4419edgech4 = Part.makeLine(pch4,pch0)
4420
4421Wch_wire = Part.Wire([edgech0, edgech1, edgech2, edgech3, edgech4])
4422cham_Face =Part.Face(Wch_wire)
4423cham_Solid = cham_Face.revolve(Base.Vector(0.0,0.0,-(rotations-1)*P),Base.Vector(0.0,0.0,1.0),360)
4424# Part.show(cham_Solid)
4425
4426BotShell = Part.Shell(botFaces)
4427BotShell = BotShell.common(cham_Solid)
4428# Part.show(BotShell)
4429
4430cham_faces = []
4431cham_faces.append(cham_Solid.Faces[0])
4432cham_faces.append(cham_Solid.Faces[1])
4433cham_Shell = Part.Shell(cham_faces)
4434# Part.show(cham_Shell)
4435
4436pipe0.translate(FreeCAD.Vector(0.0, 0.0, -(rotations-1)*P))
4437# Part.show(pipe0)
4438
4439# Part.show(Fillet_shell)
4440cham_Shell = cham_Shell.cut(pipe0)
4441pipe0.translate(FreeCAD.Vector(0.0, 0.0, -P))
4442# Part.show(pipe0)
4443cham_Shell = cham_Shell.cut(pipe0)
4444
4445'''
4446botFaces2 = []
4447for flaeche in BotShell.Faces:
4448botFaces2.append(flaeche)
4449for flaeche in cham_Shell.Faces:
4450botFaces2.append(flaeche)
4451'''
4452
4453else: # tip of screw without chamfer
4454#FreeCAD.Console.PrintMessage("without chamfer: " + str(i) + "\n")
4455
4456commonbox = Part.makeBox(d+4.0*P, d+4.0*P, 3.0*P)
4457commonbox.translate(FreeCAD.Vector(-(d+4.0*P)/2.0, -(d+4.0*P)/2.0,-(rotations)*P+bot_off))
4458#commonbox.translate(FreeCAD.Vector(-(d+4.0*P)/2.0, -(d+4.0*P)/2.0,-(rotations+3)*P+bot_off))
4459#Part.show(commonbox)
4460
4461BotShell = Part.Shell(botFaces)
4462#Part.show(BotShell)
4463
4464BotShell = BotShell.common(commonbox)
4465#BotShell = BotShell.cut(commonbox)
4466bot_edges =[]
4467bot_z = 1.0e-5 -(rotations)*P + bot_off
4468
4469for kante in BotShell.Edges:
4470if (kante.Vertexes[0].Point.z<=bot_z) and (kante.Vertexes[1].Point.z<=bot_z):
4471bot_edges.append(kante)
4472# Part.show(kante)
4473bot_wire = Part.Wire(Part.__sortEdges__(bot_edges))
4474
4475#botFaces2 = []
4476#for flaeche in BotShell.Faces:
4477# botFaces2.append(flaeche)
4478
4479bot_face = Part.Face(bot_wire)
4480bot_face.reverse()
4481#botFaces2.append(bot_face)
4482
4483'''
4484
4485BotShell2 = Part.Shell(botFaces2)
4486# Part.show(BotShell2)
4487
4488TheShell2 = Part.Shell(TheFaces)
4489
4490# This gives a shell
4491FaceList = []
4492for flaeche in TheShell2.Faces:
4493FaceList.append(flaeche)
4494for flaeche in BotShell2.Faces:
4495FaceList.append(flaeche)
4496
4497TheShell = Part.Shell(FaceList)
4498# Part.show(TheShell)
4499'''
4500for flaeche in BotShell.Faces:
4501TheFaces.append(flaeche)
4502if withcham:
4503for flaeche in cham_Shell.Faces:
4504TheFaces.append(flaeche)
4505else:
4506TheFaces.append(bot_face)
4507TheShell = Part.Shell(TheFaces)
4508
4509#print self.Tuner, " ", TheShell.ShapeType, " ", TheShell.isValid(), " hrots: ", halfrots_int, " Shellpunkte: ", len(TheShell.Vertexes)
4510
4511return TheShell
4512
4513# if da<>None: make Shell for a nut else: make a screw tap
4514def makeInnerThread_2(self, d, P, rotations, da, l):
4515d = float(d)
4516bot_off = 0.0 # nominal length
4517
4518H=P*math.cos(math.radians(30)) # Gewindetiefe H
4519r=d/2.0
4520
4521helix = Part.makeHelix(P,P,d*self.Tuner/1000.0,0) # make just one turn, length is identical to pitch
4522helix.translate(FreeCAD.Vector(0.0, 0.0,-P*9.0/16.0))
4523
4524extra_rad = P
4525
4526# points for inner thread profile
4527ps0 = (r,0.0, 0.0)
4528ps1 = (r-H*5.0/8.0,0.0, -P*5.0/16.0)
4529ps2 = (r-H*5.0/8.0,0.0, -P*9.0/16.0 )
4530ps3 = (r, 0.0, -P*14.0/16.0)
4531ps4 = (r+H*1/24.0,0.0, -P*31.0/32.0) # Center of Arc
4532ps5 = (r,0.0, -P)
4533ps6 = (r+extra_rad,0.0, -P)
4534ps7 = (r+extra_rad,0.0, 0.0)
4535
4536#ps6 = (r-extra_rad,0.0, -P)
4537#ps7 = (r-extra_rad,0.0, 0.0)
4538
4539edge0 = Part.makeLine(ps0,ps1)
4540edge1 = Part.makeLine(ps1,ps2)
4541edge2 = Part.makeLine(ps2,ps3)
4542edge3 = Part.Arc(FreeCAD.Vector(ps3),FreeCAD.Vector(ps4),FreeCAD.Vector(ps5)).toShape()
4543edge4 = Part.makeLine(ps5,ps6)
4544edge5 = Part.makeLine(ps6,ps7)
4545edge6 = Part.makeLine(ps7,ps0)
4546
4547W0 = Part.Wire([edge0, edge1, edge2, edge3, edge4, edge5, edge6])
4548# Part.show(W0)
4549
4550makeSolid=True
4551isFrenet=True
4552pipe0 = Part.Wire(helix).makePipeShell([W0],makeSolid,isFrenet)
4553# pipe1 = pipe0.copy()
4554
4555TheFaces = []
4556TheFaces.append(pipe0.Faces[0])
4557TheFaces.append(pipe0.Faces[1])
4558TheFaces.append(pipe0.Faces[2])
4559TheFaces.append(pipe0.Faces[3])
4560
4561TheShell = Part.Shell(TheFaces)
4562# print "Shellpoints: ", len(TheShell.Vertexes)
4563
4564# Handling of the top faces
4565if da is not None:
4566TheShell.translate(FreeCAD.Vector(0.0, 0.0, -P))
4567for flaeche in TheShell.Faces:
4568TheFaces.append(flaeche)
4569TheShell.translate(FreeCAD.Vector(0.0, 0.0, -P))
4570for flaeche in TheShell.Faces:
4571TheFaces.append(flaeche)
4572
4573cham_i_delta = da/2.0 - (r-H)
4574cham_i = cham_i_delta * math.tan(math.radians(15.0))
4575
4576offSet = rotations*P - l
4577#FreeCAD.Console.PrintMessage("Der Offset: " + str(offSet/P) + "\n")
4578
4579# points for chamfer: common-Method
4580pch0 = (da/2.0-cham_i_delta, 0.0, -cham_i - offSet) # bottom chamfer
4581pch1 = (da/2.0, 0.0, 0.0 - offSet) #
4582pch2 = (da/2.0, 0.0, -4.0*P - offSet)
4583pch3 = (da/2.0-cham_i_delta, 0.0, -4.0*P - offSet)
4584
4585edgech0 = Part.makeLine(pch0,pch1)
4586edgech1 = Part.makeLine(pch1,pch2)
4587edgech2 = Part.makeLine(pch2,pch3)
4588edgech3 = Part.makeLine(pch3,pch0)
4589
4590Wch_wire = Part.Wire([edgech0, edgech1, edgech2, edgech3])
4591cham_Face =Part.Face(Wch_wire)
4592cham_Solid = cham_Face.revolve(Base.Vector(0.0,0.0,-(rotations-1)*P),Base.Vector(0.0,0.0,1.0),360)
4593#Part.show(cham_Solid)
4594#Part.show(Wch_wire)
4595
4596rawTopShell = Part.Shell(TheFaces)
4597topShell = rawTopShell.common(cham_Solid)
4598
4599# Making a Cutter for the cham face
4600commonbox = Part.makeBox(d+4.0*P, d+4.0*P, 2.0*P)
4601commonbox.translate(FreeCAD.Vector(-(d+4.0*P)/2.0, -(d+4.0*P)/2.0,-2.0*P))
4602#Part.show(commonbox)
4603
4604cutterShell = rawTopShell.common(commonbox)
4605bot_edges =[]
4606bot_z = 1.0e-5 -2.0*P
4607
4608for kante in cutterShell.Edges:
4609if (kante.Vertexes[0].Point.z<=bot_z) and (kante.Vertexes[1].Point.z<=bot_z):
4610bot_edges.append(kante)
4611# Part.show(kante)
4612bot_wire = Part.Wire(Part.__sortEdges__(bot_edges))
4613
4614bot_face = Part.Face(bot_wire)
4615bot_face.reverse()
4616t_face = bot_face.copy()
4617t_face.translate(Base.Vector(0.0, 0.0, 2.0*P))
4618cutterFaces = cutterShell.Faces
4619cutterFaces.append(bot_face.Faces[0])
4620cutterFaces.append(t_face.Faces[0])
4621cutShell = Part.Shell(cutterFaces)
4622chamFcutter = Part.Solid(cutShell)
4623
4624#Part.show(chamFcutter)
4625topCham = cham_Solid.Faces[0]
4626topCham = topCham.cut(chamFcutter)
4627
4628#Part.show(topCham)
4629TheFaces = [topCham.Faces[0]]
4630TheFaces.extend(topShell.Faces)
4631
4632for i in range(rotations-4):
4633TheShell.translate(FreeCAD.Vector(0.0, 0.0,- P))
4634for flaeche in TheShell.Faces:
4635TheFaces.append(flaeche)
4636
4637else:
4638commonbox = Part.makeBox(d+4.0*P, d+4.0*P, 3.0*P)
4639commonbox.translate(FreeCAD.Vector(-(d+4.0*P)/2.0, -(d+4.0*P)/2.0,-(3.0)*P))
4640topShell = TheShell.common(commonbox)
4641top_edges =[]
4642top_z = -1.0e-5
4643
4644for kante in topShell.Edges:
4645if (kante.Vertexes[0].Point.z>=top_z) and (kante.Vertexes[1].Point.z>=top_z):
4646top_edges.append(kante)
4647# Part.show(kante)
4648top_wire = Part.Wire(Part.__sortEdges__(top_edges))
4649top_face = Part.Face(top_wire)
4650
4651TheFaces = [top_face.Faces[0]]
4652TheFaces.extend(topShell.Faces)
4653
4654for i in range(rotations-2):
4655TheShell.translate(FreeCAD.Vector(0.0, 0.0,- P))
4656for flaeche in TheShell.Faces:
4657TheFaces.append(flaeche)
4658
4659#FreeCAD.Console.PrintMessage("Base-Shell: " + str(i) + "\n")
4660# Make separate faces for the tip of the screw
4661botFaces = []
4662for i in range(rotations-2, rotations, 1):
4663TheShell.translate(FreeCAD.Vector(0.0, 0.0,- P))
4664
4665for flaeche in TheShell.Faces:
4666botFaces.append(flaeche)
4667#FreeCAD.Console.PrintMessage("Bottom-Shell: " + str(i) + "\n")
4668
4669if da is not None:
4670# points for chamfer: common-Method
4671pch0 = (da/2-cham_i_delta, 0.0, -(rotations)*P + cham_i) # bottom chamfer
4672pch1 = (da/2, 0.0, -(rotations)*P) #
4673pch2 = (da/2, 0.0, -(rotations)*P + 3.0*P)
4674pch3 = (da/2-cham_i_delta, 0.0, -(rotations)*P + 3.0*P)
4675#pch4 = (r-2.0*cham_i_delta, 0.0, -(rotations)*P + 3.0*P)
4676
4677edgech0 = Part.makeLine(pch0,pch1)
4678edgech1 = Part.makeLine(pch1,pch2)
4679edgech2 = Part.makeLine(pch2,pch3)
4680edgech3 = Part.makeLine(pch3,pch0)
4681
4682Wch_wire = Part.Wire([edgech0, edgech1, edgech2, edgech3])
4683cham_Face =Part.Face(Wch_wire)
4684cham_Solid = cham_Face.revolve(Base.Vector(0.0,0.0,-(rotations-1)*P),Base.Vector(0.0,0.0,1.0),360)
4685#Part.show(cham_Solid)
4686#Part.show(Wch_wire)
4687
4688BotShell = Part.Shell(botFaces)
4689#Part.show(BotShell)
4690chamFcutter.translate(FreeCAD.Vector(0.0, 0.0,-(rotations-1)*P))
4691#Part.show(chamFcutter)
4692
4693
4694BotShell = BotShell.common(cham_Solid)
4695#Part.show(BotShell)
4696
4697cham_face = cham_Solid.Faces[0]
4698cham_face = cham_face.cut(chamFcutter)
4699#Part.show(cham_face)
4700
4701for flaeche in BotShell.Faces:
4702TheFaces.append(flaeche)
4703if da is not None:
4704TheFaces.append(cham_face.Faces[0])
4705else:
4706TheFaces.append(bot_face)
4707TheShell = Part.Shell(TheFaces)
4708
4709#print self.Tuner, " ", TheShell.ShapeType, " ", TheShell.isValid(), " hrots: ", halfrots_int, " Shellpunkte: ", len(TheShell.Vertexes)
4710
4711return TheShell
4712
4713else: # make of screw tap
4714#FreeCAD.Console.PrintMessage("without chamfer: " + str(i) + "\n")
4715
4716commonbox = Part.makeBox(d+4.0*P, d+4.0*P, 3.0*P)
4717commonbox.translate(FreeCAD.Vector(-(d+4.0*P)/2.0, -(d+4.0*P)/2.0,-(rotations)*P+bot_off))
4718#commonbox.translate(FreeCAD.Vector(-(d+4.0*P)/2.0, -(d+4.0*P)/2.0,-(rotations+3)*P+bot_off))
4719#Part.show(commonbox)
4720
4721BotShell = Part.Shell(botFaces)
4722#Part.show(BotShell)
4723
4724BotShell = BotShell.common(commonbox)
4725#BotShell = BotShell.cut(commonbox)
4726bot_edges =[]
4727bot_z = 1.0e-5 -(rotations)*P + bot_off
4728
4729for kante in BotShell.Edges:
4730if (kante.Vertexes[0].Point.z<=bot_z) and (kante.Vertexes[1].Point.z<=bot_z):
4731bot_edges.append(kante)
4732# Part.show(kante)
4733bot_wire = Part.Wire(Part.__sortEdges__(bot_edges))
4734
4735bot_face = Part.Face(bot_wire)
4736bot_face.reverse()
4737
4738for flaeche in BotShell.Faces:
4739TheFaces.append(flaeche)
4740if da is not None:
4741raise NotImplementedError('da must be None')
4742# TODO: Fix cham_Shell undefined.
4743for flaeche in cham_Shell.Faces:
4744TheFaces.append(flaeche)
4745else:
4746TheFaces.append(bot_face)
4747TheShell = Part.Shell(TheFaces)
4748TheSolid = Part.Solid(TheShell)
4749
4750#print self.Tuner, " ", TheShell.ShapeType, " ", TheShell.isValid(), " hrots: ", halfrots_int, " Shellpunkte: ", len(TheShell.Vertexes)
4751
4752return TheSolid
4753
4754def makeIso4032(self, SType='ISO4032', ThreadType='M6'):
4755"""ISO 4032 Hex-nut and 4033 Hex-nut"""
4756dia = get_diameter(ThreadType)
4757if SType == 'ISO4032':
4758# P, c, damax, dw, e, m, mw, s_nom
4759P, c, da, dw, e, m, mw, s = iso4032def[ThreadType]
4760if SType == 'ISO4033':
4761# P, c, damax, dw, e, m, mw, s_nom
4762P, c, da, dw, e, m, mw, s = iso4033def[ThreadType]
4763if SType == 'ISO4035':
4764# P, c, damax, dw, e, m, mw, s_nom
4765P, c, da, dw, e, m, mw, s = iso4035def[ThreadType]
4766
4767residue, turns = math.modf(m/P)
4768#halfturns = 2*int(turns)
4769
4770if residue > 0.0:
4771turns += 1.0
4772#halfturns = halfturns +2
4773#offSet = r - a
4774
4775sqrt2_ = 1.0/math.sqrt(2.0)
4776cham = (e-s)*math.sin(math.radians(15)) # needed for chamfer at nut top
4777H=P*math.cos(math.radians(30)) # Gewindetiefe H
4778cham_i_delta = da/2.0 - (dia/2.0-H*5.0/8.0)
4779cham_i = cham_i_delta * math.tan(math.radians(15.0))
4780
4781
4782if self.rThread:
4783Pnt0 = Base.Vector(da/2.0-2.0*cham_i_delta,0.0,m - 2.0*cham_i)
4784Pnt7 = Base.Vector(da/2.0-2.0*cham_i_delta,0.0,0.0+ 2.0*cham_i)
4785else:
4786Pnt0 = Base.Vector(dia/2.0-H*5.0/8.0,0.0,m - cham_i)
4787Pnt7 = Base.Vector(dia/2.0-H*5.0/8.0,0.0,0.0+ cham_i)
4788
4789Pnt1 = Base.Vector(da/2.0,0.0,m)
4790Pnt2 = Base.Vector(s/2.0,0.0,m)
4791Pnt3 = Base.Vector(s/math.sqrt(3.0),0.0,m-cham)
4792Pnt4 = Base.Vector(s/math.sqrt(3.0),0.0,cham)
4793Pnt5 = Base.Vector(s/2.0,0.0,0.0)
4794Pnt6 = Base.Vector(da/2.0,0.0,0.0)
4795
4796edge0 = Part.makeLine(Pnt0,Pnt1)
4797edge1 = Part.makeLine(Pnt1,Pnt2)
4798edge2 = Part.makeLine(Pnt2,Pnt3)
4799edge3 = Part.makeLine(Pnt3,Pnt4)
4800edge4 = Part.makeLine(Pnt4,Pnt5)
4801edge5 = Part.makeLine(Pnt5,Pnt6)
4802edge6 = Part.makeLine(Pnt6,Pnt7)
4803edge7 = Part.makeLine(Pnt7,Pnt0)
4804
4805# create cutting tool for hexagon head
4806# Parameters s, k, outer circle diameter = e/2.0+10.0
4807extrude = self.makeHextool(s, m, s*2.0)
4808
4809aWire=Part.Wire([edge0,edge1,edge2,edge3,edge4,edge5,edge6,edge7])
4810# Part.show(aWire)
4811aFace =Part.Face(aWire)
4812head = aFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360.0)
4813#Part.show(head)
4814
4815# Part.show(extrude)
4816nut = head.cut(extrude)
4817# Part.show(nut)
4818
4819if self.rThread:
4820'''
4821threadCutter = self.makeInnerThread(dia, P, int(turns), None, m)
4822# Part.show(threadCutter)
4823threadCutter.translate(Base.Vector(0.0, 0.0,turns*P))
4824nut = nut.cut(threadCutter)
4825'''
4826nutFaces = [nut.Faces[2]]
4827for i in range(4,25):
4828nutFaces.append(nut.Faces[i])
4829
4830
4831threadShell = self.makeInnerThread_2(dia, P, int(turns), da, m)
4832threadShell.translate(Base.Vector(0.0, 0.0,turns*P))
4833#Part.show(threadShell)
4834nutFaces.extend(threadShell.Faces)
4835
4836nutShell = Part.Shell(nutFaces)
4837nut = Part.Solid(nutShell)
4838#Part.show(nutShell)
4839
4840return nut
4841
4842def makeEN1661(self, ThreadType='M8'):
4843"""EN 1661 Hexagon nuts with flange
4844
4845chamfer at top of hexagon is wrong = more than 30°
4846"""
4847dia = get_diameter(ThreadType)
4848P, da, c, dc, dw, e, m, mw, r1, s = en1661def[ThreadType]
4849
4850residue, turns = math.modf(m/P)
4851#halfturns = 2*int(turns)
4852
4853if residue > 0.0:
4854turns += 1.0
4855
4856#FreeCAD.Console.PrintMessage("the nut with isoEN1661: " + str(c) + "\n")
4857cham = s*(2.0/math.sqrt(3.0)-1.0)*math.sin(math.radians(25)) # needed for chamfer at head top
4858
4859sqrt2_ = 1.0/math.sqrt(2.0)
4860
4861# Flange is made with a radius of c
4862beta = math.radians(25.0)
4863tan_beta = math.tan(beta)
4864
4865# Calculation of Arc points of flange edge using dc and c
4866arc1_x = dc/2.0 - c/2.0 + (c/2.0)*math.sin(beta)
4867arc1_z = c/2.0 + (c/2.0)*math.cos(beta)
4868
4869hF = arc1_z + (arc1_x -s/2.0) * tan_beta # height of flange at center
4870
4871#kmean = arc1_z + (arc1_x - s/math.sqrt(3.0)) * tan_beta + mw * 1.1 + cham
4872#kmean = k * 0.95
4873
4874
4875#Hex-Head Points
4876#FreeCAD.Console.PrintMessage("the nut with kmean: " + str(m) + "\n")
4877PntH0 = Base.Vector(da/2.0,0.0,m)
4878PntH1 = Base.Vector(s/2.0,0.0,m)
4879edgeH1 = Part.makeLine(PntH0,PntH1)
4880
4881hWire=Part.Wire([edgeH1])
4882topShell = hWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
4883#Part.show(hWire)
4884#Part.show(topShell)
4885
4886# create a cutter ring to generate the chamfer at the top of the hex
4887chamHori = s/math.sqrt(3.0) - s/2.0
4888PntC1 = Base.Vector(s/2.0-chamHori,0.0,m+m)
4889PntC2 = Base.Vector(s/math.sqrt(3.0)+chamHori,0.0,m+m)
4890PntC3 = Base.Vector(s/2.0-chamHori,0.0,m+cham)
4891PntC4 = Base.Vector(s/math.sqrt(3.0)+chamHori,0.0,m-cham-cham) #s/math.sqrt(3.0)
4892edgeC1 = Part.makeLine(PntC3, PntC1)
4893edgeC2 = Part.makeLine(PntC1, PntC2)
4894edgeC3 = Part.makeLine(PntC2, PntC4)
4895edgeC4 = Part.makeLine(PntC4, PntC3)
4896cWire = Part.Wire([edgeC4, edgeC1, edgeC2, edgeC3])
4897cFace = Part.Face(cWire)
4898chamCut = cFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
4899#Part.show(cWire)
4900#Part.show(chamCut)
4901
4902
4903# create hexagon
4904mhex=Base.Matrix()
4905mhex.rotateZ(math.radians(60.0))
4906polygon = []
4907vhex=Base.Vector(s/math.sqrt(3.0),0.0,m)
4908for i in range(6):
4909polygon.append(vhex)
4910vhex = mhex.multiply(vhex)
4911polygon.append(vhex)
4912hexagon = Part.makePolygon(polygon)
4913hexFace = Part.Face(hexagon)
4914solidHex = hexFace.extrude(Base.Vector(0.0,0.0,c-m))
4915#Part.show(solidHex)
4916hexCham = solidHex.cut(chamCut)
4917#Part.show(hexCham)
4918
4919topFaces = topShell.Faces
4920
4921topFaces.append(hexCham.Faces[1])
4922topFaces.append(hexCham.Faces[2])
4923topFaces.append(hexCham.Faces[8])
4924topFaces.append(hexCham.Faces[13])
4925topFaces.append(hexCham.Faces[14])
4926topFaces.append(hexCham.Faces[12])
4927topFaces.append(hexCham.Faces[6])
4928
4929hexFaces = [hexCham.Faces[5], hexCham.Faces[11], hexCham.Faces[10]]
4930hexFaces.extend([hexCham.Faces[9], hexCham.Faces[3], hexCham.Faces[0]])
4931hexShell = Part.Shell(hexFaces)
4932
4933
4934H=P*math.cos(math.radians(30)) # Gewindetiefe H
4935cham_i_delta = da/2.0 - (dia/2.0-H*5.0/8.0)
4936cham_i = cham_i_delta * math.tan(math.radians(15.0))
4937
4938# Center of flange:
4939Pnt0 = Base.Vector(0.0,0.0,hF)
4940Pnt1 = Base.Vector(s/2.0,0.0,hF)
4941
4942# arc edge of flange:
4943Pnt2 = Base.Vector(arc1_x,0.0,arc1_z)
4944Pnt3 = Base.Vector(dc/2.0,0.0,c/2.0)
4945Pnt4 = Base.Vector((dc-c)/2.0,0.0,0.0)
4946Pnt5 = Base.Vector(da/2.0,0.0,0.0) #start of fillet between flat and thread
4947
4948edge1 = Part.makeLine(Pnt0,Pnt1)
4949edge2 = Part.makeLine(Pnt1,Pnt2)
4950edge3 = Part.Arc(Pnt2,Pnt3,Pnt4).toShape()
4951edge4 = Part.makeLine(Pnt4,Pnt5)
4952
4953# make a cutter for the hexShell
4954PntHC1 = Base.Vector(0.0,0.0,arc1_z)
4955PntHC2 = Base.Vector(0.0,0.0,0.0)
4956
4957edgeHC1 = Part.makeLine(Pnt2,PntHC1)
4958edgeHC2 = Part.makeLine(PntHC1,PntHC2)
4959edgeHC3 = Part.makeLine(PntHC2,Pnt0)
4960
4961HCWire = Part.Wire([edge2, edgeHC1, edgeHC2, edgeHC3, edge1])
4962HCFace = Part.Face(HCWire)
4963hex2Cut = HCFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
4964
4965hexShell = hexShell.cut(hex2Cut)
4966#Part.show(hexShell)
4967
4968topFaces.extend(hexShell.Faces)
4969
4970if self.rThread:
4971aWire=Part.Wire([edge2,edge3,edge4])
4972boltIndex = 3
4973
4974else:
4975Pnt7 = Base.Vector(dia/2.0-H*5.0/8.0,0.0,m - cham_i)
4976Pnt6 = Base.Vector(dia/2.0-H*5.0/8.0,0.0,0.0+ cham_i)
4977edge5 = Part.makeLine(Pnt5,Pnt6)
4978edge6 = Part.makeLine(Pnt6,Pnt7)
4979edge7 = Part.makeLine(Pnt7,PntH0)
4980aWire=Part.Wire([edge2,edge3,edge4,edge5,edge6,edge7])
4981boltIndex = 6
4982
4983
4984#aFace =Part.Face(aWire)
4985#Part.show(aWire)
4986headShell = aWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
4987#FreeCAD.Console.PrintMessage("der Kopf mit revolve: " + str(dia) + "\n")
4988#Part.show(headShell)
4989chamFace = headShell.Faces[0].cut(solidHex)
4990#Part.show(chamFace)
4991
4992topFaces.append(chamFace.Faces[0])
4993for i in range(1,boltIndex):
4994topFaces.append(headShell.Faces[i])
4995
4996
4997if self.rThread:
4998#rthread = self.makeShellthread(dia, P, halfturns, True, offSet)
4999#rthread.translate(Base.Vector(0.0, 0.0,-a_point-2.0*P))
5000threadShell = self.makeInnerThread_2(dia, P, int(turns), da, m)
5001threadShell.translate(Base.Vector(0.0, 0.0,turns*P))
5002#Part.show(threadShell)
5003for tFace in threadShell.Faces:
5004topFaces.append(tFace)
5005headShell = Part.Shell(topFaces)
5006screw = Part.Solid(headShell)
5007else:
5008screwShell = Part.Shell(topFaces)
5009screw = Part.Solid(screwShell)
5010
5011return screw
5012
5013def makeScrewTap(self, ThreadType ='M6',l=25.0):
5014"""ISO 7380-1, ISO 7380-2, DIN 967
5015
5016make ISO 7380-1 Button head Screw
5017make ISO 7380-2 Button head Screw with collar
5018make DIN 967 cross recessed pan head Screw with collar
5019"""
5020dia = get_diameter(ThreadType)
5021
5022P, tunIn, tunEx = tuningTable[ThreadType]
5023
5024residue, turns = math.modf((l)/P)
5025turns += 1.0
5026#FreeCAD.Console.PrintMessage("ScrewTap residue: " + str(residue) + " turns: " + str(turns) + "\n")
5027
5028
5029if self.rThread:
5030screwTap = self.makeInnerThread_2(dia, P, int(turns), None, 0.0)
5031screwTap.translate(Base.Vector(0.0, 0.0,(1-residue)*P))
5032else:
5033H=P*math.cos(math.radians(30)) # Gewindetiefe H
5034r=dia/2.0
5035
5036# points for inner thread profile
5037Pnt0 = Base.Vector(0.0,0.0,(1-residue)*P)
5038Pnt1 = Base.Vector(r-H*5.0/8.0,0.0,(1-residue)*P)
5039Pnt2 = Base.Vector(r-H*5.0/8.0,0.0,-l)
5040Pnt3 = Base.Vector(0.0,0.0,-l)
5041
5042edge1 = Part.makeLine(Pnt0,Pnt1)
5043edge2 = Part.makeLine(Pnt1,Pnt2)
5044edge3 = Part.makeLine(Pnt2,Pnt3)
5045aWire=Part.Wire([edge1,edge2,edge3])
5046headShell = aWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360.0)
5047screwTap = Part.Solid(headShell)
5048
5049return screwTap
5050
5051def cutChamfer(self, dia_cC, P_cC, l_cC):
5052cham_t = P_cC*math.sqrt(3.0)/2.0*17.0/24.0
5053PntC0 = Base.Vector(0.0,0.0,-l_cC)
5054PntC1 = Base.Vector(dia_cC/2.0-cham_t,0.0,-l_cC)
5055PntC2 = Base.Vector(dia_cC/2.0+cham_t,0.0,-l_cC+cham_t+cham_t)
5056PntC3 = Base.Vector(dia_cC/2.0+cham_t,0.0,-l_cC-P_cC-cham_t)
5057PntC4 = Base.Vector(0.0,0.0,-l_cC-P_cC-cham_t)
5058
5059edgeC1 = Part.makeLine(PntC0,PntC1)
5060edgeC2 = Part.makeLine(PntC1,PntC2)
5061edgeC3 = Part.makeLine(PntC2,PntC3)
5062edgeC4 = Part.makeLine(PntC3,PntC4)
5063edgeC5 = Part.makeLine(PntC4,PntC0)
5064CWire=Part.Wire([edgeC1,edgeC2,edgeC3,edgeC4,edgeC5])
5065#Part.show(CWire)
5066CFace =Part.Face(CWire)
5067cyl = CFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
5068return cyl
5069
5070def makeCross_H3(self, CrossType = '2', m = 6.9, h = 0.0):
5071"""Cross recess type H
5072
5073m = diameter of cross at top of screw at reference level for penetration depth
5074"""
5075b, e_mean, g, f_mean, r, t1, alpha, beta = iso4757def[CrossType]
5076
5077rad265 = math.radians(26.5)
5078rad28 = math.radians(28.0)
5079tg = (m-g)/2.0/math.tan(rad265) # depth at radius of g
5080t_tot = tg + g/2.0 * math.tan(rad28) # total depth
5081#FreeCAD.Console.PrintMessage("Cross H3: " + str(b) + "\n")
5082
5083# print 'tg: ', tg,' t_tot: ', t_tot
5084hm = m / 4.0
5085hmc = m / 2.0
5086rmax = m / 2.0 + hm*math.tan(rad265)
5087
5088Pnt0 = Base.Vector(0.0,0.0,hm)
5089Pnt1 = Base.Vector(rmax,0.0,hm)
5090Pnt3 = Base.Vector(0.0,0.0,0.0)
5091Pnt4 = Base.Vector(g/2.0,0.0,-tg)
5092Pnt5 = Base.Vector(0.0,0.0,-t_tot)
5093
5094edge1 = Part.makeLine(Pnt0,Pnt1)
5095edge3 = Part.makeLine(Pnt1,Pnt4)
5096edge4 = Part.makeLine(Pnt4,Pnt5)
5097# FreeCAD.Console.PrintMessage("Edges made Pnt1: " + str(Pnt1) + "\n")
5098
5099aWire=Part.Wire([edge1,edge3,edge4])
5100crossShell = aWire.revolve(Pnt3,Base.Vector(0.0,0.0,1.0),360)
5101#FreeCAD.Console.PrintMessage("Peak-wire revolved: " + str(e_mean) + "\n")
5102cross = Part.Solid(crossShell)
5103#Part.show(cross)
5104
5105# the need to cut 4 corners out of the above shape.
5106# Definition of corner
5107# The angles 92 degrees and alpha are defined on a plane which has
5108# an angle of beta against our coordinate system.
5109# The projected angles are needed for easier calculation!
5110rad_alpha = math.radians(alpha/2.0)
5111rad92 = math.radians(92.0/2.0)
5112rad_beta = math.radians(beta)
5113
5114rad_alpha_p = math.atan(math.tan(rad_alpha)/math.cos(rad_beta))
5115rad92_p = math.atan(math.tan(rad92)/math.cos(rad_beta))
5116
5117tb = tg + (g-b)/2.0 * math.tan(rad28) # depth at dimension b
5118rbtop = b/2.0 + (hmc + tb)*math.tan(rad_beta) # radius of b-corner at hm
5119rbtot = b/2.0 - (t_tot - tb)*math.tan(rad_beta) # radius of b-corner at t_tot
5120
5121dre = e_mean/2.0 / math.tan(rad_alpha_p) # delta between corner b and corner e in x direction
5122#FreeCAD.Console.PrintMessage("delta calculated: " + str(dre) + "\n")
5123
5124dx = m/2.0 * math.cos(rad92_p)
5125dy = m/2.0 * math.sin(rad92_p)
5126
5127PntC0 = Base.Vector(rbtop,0.0,hmc)
5128PntC1 = Base.Vector(rbtot,0.0,-t_tot)
5129PntC2 = Base.Vector(rbtop+dre,+e_mean/2.0,hmc)
5130PntC3 = Base.Vector(rbtot+dre,+e_mean/2.0,-t_tot)
5131PntC4 = Base.Vector(rbtop+dre,-e_mean/2.0,hmc)
5132PntC5 = Base.Vector(rbtot+dre,-e_mean/2.0,-t_tot)
5133
5134PntC6 = Base.Vector(rbtop+dre+dx,+e_mean/2.0+dy,hmc)
5135#PntC7 = Base.Vector(rbtot+dre+dx,+e_mean/2.0+dy,-t_tot)
5136PntC7 = Base.Vector(rbtot+dre+2.0*dx,+e_mean+2.0*dy,-t_tot)
5137PntC8 = Base.Vector(rbtop+dre+dx,-e_mean/2.0-dy,hmc)
5138#PntC9 = Base.Vector(rbtot+dre+dx,-e_mean/2.0-dy,-t_tot)
5139PntC9 = Base.Vector(rbtot+dre+2.0*dx,-e_mean-2.0*dy,-t_tot)
5140
5141#wire_hm = Part.makePolygon([PntC0,PntC2,PntC6,PntC8,PntC4,PntC0])
5142#face_hm =Part.Face(wire_hm)
5143#Part.show(face_hm)
5144
5145wire_t_tot = Part.makePolygon([PntC1,PntC3,PntC7,PntC9,PntC5,PntC1])
5146# Part.show(wire_t_tot)
5147edgeC1 = Part.makeLine(PntC0,PntC1)
5148#FreeCAD.Console.PrintMessage("edgeC1 mit PntC9" + str(PntC9) + "\n")
5149
5150makeSolid=True
5151isFrenet=False
5152corner = Part.Wire(edgeC1).makePipeShell([wire_t_tot],makeSolid,isFrenet)
5153#Part.show(corner)
5154
5155rot_axis = Base.Vector(0.,0.,1.0)
5156sin_res = math.sin(math.radians(90)/2.0)
5157cos_res = math.cos(math.radians(90)/2.0)
5158rot_axis.multiply(-sin_res) # Calculation of Quaternion-Elements
5159#FreeCAD.Console.PrintMessage("Quaternion-Elements" + str(cos_res) + "\n")
5160
5161pl_rot = FreeCAD.Placement()
5162pl_rot.Rotation = (rot_axis.x,rot_axis.y,rot_axis.z,cos_res) #Rotation-Quaternion 90° z-Axis
5163
5164crossShell = crossShell.cut(corner)
5165# Part.show(crossShell)
5166cutplace = corner.Placement
5167
5168cornerFaces = []
5169cornerFaces.append(corner.Faces[0])
5170cornerFaces.append(corner.Faces[1])
5171cornerFaces.append(corner.Faces[3])
5172cornerFaces.append(corner.Faces[4])
5173
5174cornerShell = Part.Shell(cornerFaces)
5175cornerShell = cornerShell.common(cross)
5176addPlace = cornerShell.Placement
5177
5178crossFaces = cornerShell.Faces
5179
5180for i in range(3):
5181#cutplace.Rotation = pl_rot.Rotation.multiply(corner.Placement.Rotation)
5182corner.Placement.Rotation = pl_rot.Rotation.multiply(corner.Placement.Rotation)
5183crossShell = crossShell.cut(corner)
5184#addPlace.Rotation = pl_rot.Rotation.multiply(cornerShell.Placement.Rotation)
5185cornerShell.Placement.Rotation = pl_rot.Rotation.multiply(cornerShell.Placement.Rotation)
5186for coFace in cornerShell.Faces:
5187crossFaces.append(coFace)
5188
5189# Part.show(crossShell)
5190for i in range(1,6):
5191crossFaces.append(crossShell.Faces[i])
5192
5193crossShell0 = Part.Shell(crossFaces)
5194
5195crossFaces.append(crossShell.Faces[0])
5196crossShell = Part.Shell(crossFaces)
5197
5198cross = Part.Solid(crossShell)
5199
5200
5201#FreeCAD.Console.PrintMessage("Placement: " + str(pl_rot) + "\n")
5202
5203cross.Placement.Base = Base.Vector(0.0,0.0,h)
5204crossShell0.Placement.Base = Base.Vector(0.0,0.0,h)
5205#Part.show(crossShell0)
5206#Part.show(cross)
5207return cross, crossShell0
5208
5209def makeAllen2(self, s_a=3.0, t_a=1.5, h_a=2.0):
5210"""Allen recess cutting tool
5211
5212Parameters used: s_mean, k, t_min, dk
5213"""
5214# h_a top height location of cutting tool
5215# s_a hex width
5216# t_a dept of the allen
5217# dk_a diameter not needed anymore
5218
5219e_cham = 2.0 * s_a / math.sqrt(3.0)
5220depth = s_a / 3.0
5221#FreeCAD.Console.PrintMessage("allen tool: " + str(s_a) + "\n")
5222
5223# Points for an arc at the peak of the cone
5224rCone = e_cham/4.0
5225hyp = (depth*math.sqrt(e_cham**2/depth**2+1.0)*rCone)/e_cham
5226radAlpha = math.atan(e_cham/depth)
5227radBeta = math.pi/2.0 - radAlpha
5228zrConeCenter=hyp - depth -t_a
5229xArc1=math.sin(radBeta)*rCone
5230zArc1=zrConeCenter - math.cos(radBeta)*rCone
5231xArc2=math.sin(radBeta/2.0)*rCone
5232zArc2=zrConeCenter - math.cos(radBeta/2.0)*rCone
5233zArc3 = zrConeCenter - rCone
5234
5235# The round part of the cutting tool, we need for the allen hex recess
5236PntH1 = Base.Vector(0.0,0.0,-t_a-depth-depth)
5237PntH2 = Base.Vector(e_cham,0.0,-t_a-depth-depth)
5238PntH3 = Base.Vector(e_cham,0.0,-t_a+depth)
5239PntH4 = Base.Vector(0.0,0.0,-t_a-depth)
5240
5241PntA1 = Base.Vector(xArc1,0.0,zArc1)
5242PntA2 = Base.Vector(xArc2,0.0,zArc2)
5243PntA3 = Base.Vector(0.0,0.0,zArc3)
5244
5245edgeA1 = Part.Arc(PntA1,PntA2,PntA3).toShape()
5246
5247edgeH1 = Part.makeLine(PntH1,PntH2)
5248edgeH2 = Part.makeLine(PntH2,PntH3)
5249edgeH3 = Part.makeLine(PntH3,PntA1)
5250edgeH4 = Part.makeLine(PntA3,PntH1)
5251
5252hWire=Part.Wire([edgeH1,edgeH2,edgeH3,edgeA1,edgeH4])
5253# Part.show(hWire)
5254hFace =Part.Face(hWire)
5255roundtool = hFace.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
5256
5257# create hexagon
5258mhex=Base.Matrix()
5259mhex.rotateZ(math.radians(60.0))
5260polygon = []
5261vhex=Base.Vector(s_a/math.sqrt(3.0),0.0,1.0)
5262for i in range(6):
5263polygon.append(vhex)
5264vhex = mhex.multiply(vhex)
5265polygon.append(vhex)
5266hexagon = Part.makePolygon(polygon)
5267hexFace = Part.Face(hexagon)
5268solidHex = hexFace.extrude(Base.Vector(0.0,0.0,-1.0-t_a-depth*1.1))
5269allen = solidHex.cut(roundtool)
5270# Part.show(allen)
5271
5272allenFaces = [allen.Faces[0]]
5273for i in range(2,9):
5274allenFaces.append(allen.Faces[i])
5275allenShell = Part.Shell(allenFaces)
5276solidHex.Placement.Base = Base.Vector(0.0,0.0,h_a)
5277allenShell.Placement.Base = Base.Vector(0.0,0.0,h_a)
5278return solidHex, allenShell
5279
5280def makeIso10664_3(self,RType ='T20',t_hl=3.0, h_hl = 0):
5281"""ISO 10664 Hexalobular internal driving feature for bolts and screws"""
5282# t_hl depth of the recess
5283# h_hl top height location of Cutting tool
5284A, B, Re = iso10664def[RType]
5285sqrt_3 = math.sqrt(3.0)
5286depth=A/4.0
5287offSet = 1.0
5288
5289# Chamfer cutter for the hexalobular recess
5290PntH1 = Base.Vector(0.0,0.0,-t_hl-depth-1.0)
5291#PntH2 = Base.Vector(A/2.0*1.02,0.0,-t_hl-depth-1.0)
5292#PntH3 = Base.Vector(A/2.0*1.02,0.0,-t_hl)
5293PntH2 = Base.Vector(A,0.0,-t_hl-depth-1.0)
5294PntH3 = Base.Vector(A,0.0,-t_hl+depth)
5295PntH4 = Base.Vector(0.0,0.0,-t_hl-depth)
5296
5297# Points for an arc at the peak of the cone
5298rCone = A/4.0
5299hyp = (depth*math.sqrt(A**2/depth**2+1.0)*rCone)/A
5300radAlpha = math.atan(A/depth)
5301radBeta = math.pi/2.0 - radAlpha
5302zrConeCenter=hyp - depth -t_hl
5303xArc1=math.sin(radBeta)*rCone
5304zArc1=zrConeCenter - math.cos(radBeta)*rCone
5305xArc2=math.sin(radBeta/2.0)*rCone
5306zArc2=zrConeCenter - math.cos(radBeta/2.0)*rCone
5307zArc3 = zrConeCenter - rCone
5308
5309PntA1 = Base.Vector(xArc1,0.0,zArc1)
5310PntA2 = Base.Vector(xArc2,0.0,zArc2)
5311PntA3 = Base.Vector(0.0,0.0,zArc3)
5312
5313edgeA1 = Part.Arc(PntA1,PntA2,PntA3).toShape()
5314
5315edgeH1 = Part.makeLine(PntH1,PntH2)
5316edgeH2 = Part.makeLine(PntH2,PntH3)
5317edgeH3 = Part.makeLine(PntH3,PntA1)
5318edgeH4 = Part.makeLine(PntA3,PntH1)
5319
5320hWire=Part.Wire([edgeH1,edgeH2,edgeH3,edgeA1])
5321cutShell = hWire.revolve(Base.Vector(0.0,0.0,0.0),Base.Vector(0.0,0.0,1.0),360)
5322cutTool = Part.Solid(cutShell)
5323
5324
5325Ri = -((B+sqrt_3*(2.*Re-A))*B+(A-4.*Re)*A)/(4.*B-2.*sqrt_3*A+(4.*sqrt_3-8.)*Re)
5326#print '2nd Ri last solution: ', Ri
5327beta=math.acos(A/(4*Ri+4*Re)-(2*Re)/(4*Ri+4*Re))-math.pi/6
5328#print 'beta: ', beta
5329Rh=(sqrt_3*(A/2.0-Re))/2.0
5330Re_x = A/2.0 - Re + Re*math.sin(beta)
5331Re_y = Re*math.cos(beta)
5332Ri_y = B/4.0
5333Ri_x = sqrt_3*B/4.0
5334
5335mhex=Base.Matrix()
5336mhex.rotateZ(math.radians(60.0))
5337hexlobWireList = []
5338
5339PntRe0=Base.Vector(Re_x,-Re_y,offSet)
5340PntRe1=Base.Vector(A/2.0,0.0,offSet)
5341PntRe2=Base.Vector(Re_x,Re_y,offSet)
5342edge0 = Part.Arc(PntRe0,PntRe1,PntRe2).toShape()
5343#Part.show(edge0)
5344hexlobWireList.append(edge0)
5345
5346PntRi = Base.Vector(Ri_x,Ri_y,offSet)
5347PntRi2 = mhex.multiply(PntRe0)
5348edge1 = Part.Arc(PntRe2,PntRi,PntRi2).toShape()
5349#Part.show(edge1)
5350hexlobWireList.append(edge1)
5351
5352for i in range(5):
5353PntRe1 = mhex.multiply(PntRe1)
5354PntRe2 = mhex.multiply(PntRe2)
5355edge0 = Part.Arc(PntRi2,PntRe1,PntRe2).toShape()
5356hexlobWireList.append(edge0)
5357PntRi = mhex.multiply(PntRi)
5358PntRi2 = mhex.multiply(PntRi2)
5359if i == 5:
5360edge1 = Part.Arc(PntRe2,PntRi,PntRe0).toShape()
5361else:
5362edge1 = Part.Arc(PntRe2,PntRi,PntRi2).toShape()
5363hexlobWireList.append(edge1)
5364hexlobWire=Part.Wire(hexlobWireList)
5365#Part.show(hWire)
5366
5367face=Part.Face(hexlobWire)
5368
5369# Extrude in z to create the cutting tool for the screw-head-face
5370Helo=face.extrude(Base.Vector(0.0,0.0,-t_hl-depth-offSet))
5371# Make the recess-shell for the screw-head-shell
5372
5373hexlob = Helo.cut(cutTool)
5374#Part.show(hexlob)
5375hexlobFaces = [hexlob.Faces[0]]
5376for i in range(2,15):
5377hexlobFaces.append(hexlob.Faces[i])
5378
5379hexlobShell = Part.Shell(hexlobFaces)
5380
5381hexlobShell.Placement.Base = Base.Vector(0.0,0.0,h_hl)
5382Helo.Placement.Base = Base.Vector(0.0,0.0,h_hl)
5383
5384return Helo, hexlobShell
5385
5386def setThreadType(self, TType = 'simple'):
5387self.simpThread = False
5388self.symThread = False
5389self.rThread = False
5390if TType == 'simple':
5391self.simpThread = True
5392if TType == 'symbol':
5393self.symThread = True
5394if TType == 'real':
5395self.rThread = True
5396
5397def setTuner(self, myTuner = 511):
5398self.Tuner = myTuner
5399
5400
5401class ScrewMacro(object):
5402d = QtGui.QWidget()
5403d.ui = Ui_ScrewMaker()
5404d.ui.setupUi(d)
5405if __name__ == '__main__':
5406d.show()
5407
5408
5409def main():
5410o = ScrewMacro()
5411
5412if __name__ == '__main__':
5413main()
5414