Editing

For this tutorial download the file stks_example.stk: Download. This file is a human readable text file which contains seven stackup calculations. Here is an image of the machine to which this stackup applies: stks_example.png

Start up the program and load the data:

In [3]:
from stackups import *   # start up the stackups program

path = '/home/ken/Dropbox/dbDocuments/python2/stackups/'
file = 'stks_example.stk'

s = load(path + file)

To see a list of editing commands, use the help method as discussed in the getting help tutorial; i.e., s.help()

Editing the stack direction, j()

Every Stackunit within a Stack has a direction associated within that Stack. The variable name j represents the direction. j is either -1 or 1. Here are some example of changing a j value for row 2 of stack 1 to a negative value.

In [4]:
s[1].j(-2)
{0: 1, 1: -1, 2: -1, 3: -1, 4: -1, 5: -1, 6: -1, 7: -1, 8: -1}

[1] PN16/NJ210E - gap between cover and bearing (shaft pushed rt.)
r  su  σ  j     d        dt     pn & n
1  12  6  -  0.3190 ± 0.0050  PN16, Mounting face to rt. end
2   8  6  - 10.4860 ± 0.0100  PN07, Overall width
3  12  6  -  0.3190 ± 0.0050  PN16, Mounting face to rt. end
4   2  6  -  0.9031 ± 0.0024  NJ2210E, Bearing width
5  10  6  -  0.5780 ± 0.0050  PN14, Width
6   9  6  -  1.4070 ± 0.0050  PN12, Width
7  11  6  -  6.0390 ± 0.0050  PN15, Lf brg shldr to gear shldr
8   2  6  -  0.9031 ± 0.0024  NJ2210E, Bearing width
------------------------------------------------------------
-20.9543 ± 0.0397  [-20.9940, -20.9146]  100% possible
-20.9543 ± 0.0154  [-20.9696, -20.9389]  6σ, 99.73% probable
-20.9543 ± 0.0102  [-20.9645, -20.9440]  4σ, 95.46% probable
-20.9543 ± 0.0051  [-20.9594, -20.9492]  2σ, 68.26% probable
  σ = 0.00512

Or if, for Stack 5, the direction row 2 needs to be negitive and 7 positive.

In [5]:
s[5].j(7, -2)   # Order of arguments is not important
{0: 5, 1: 1, 2: -1, 3: -1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1}

[5] P15/PN02, Gear overhang, rt side (idler pushed lf)
r  su  σ  j     d       dt     pn & n
1   3  6  + 0.3730 ± 0.0050  PN01, Thickness
2  13  6  - 1.1764 ± 0.0028  478/473, Bearing pressed width
3   7  6  - 5.9170 ± 0.0150  PN07, Output pocket depth
4  12  6  + 0.3190 ± 0.0050  PN16, Mounting face to rt. end
5   2  6  + 0.9031 ± 0.0024  NJ2210E, Bearing width
6  11  6  + 6.0390 ± 0.0050  PN15, Lf brg shldr to gear shldr
7  18  6  + 5.2950 ± 0.0150  PN15, Lf side of small gear to gear shldr
8  19  6  + 2.4640 ± 0.0150  PN15, Gear width
------------------------------------------------------------
 8.2997 ± 0.0652  [8.2346, 8.3649]  100% possible
 8.2997 ± 0.0276  [8.2721, 8.3273]  6σ, 99.73% probable
 8.2997 ± 0.0184  [8.2813, 8.3181]  4σ, 95.46% probable
 8.2997 ± 0.0092  [8.2905, 8.3089]  2σ, 68.26% probable
  σ = 0.00921

The value for all the j values for a given Stack resides in the header of that Stack. To see the contens of the header of s[1]:

In [6]:
s[1][0]
Out[6]:
{'j': {0: 1, 1: -1, 2: -1, 3: -1, 4: -1, 5: -1, 6: -1, 7: -1, 8: -1},
 'title': 'PN16/NJ210E - gap between cover and bearing (shaft pushed rt.)'}

j is what is called in Python jargon a dictionary. The j dictionary is arranged in "row: value" pairs. So for row 3 of the stackup, the value is -1.

Another method of adjusting the values of j is:

In [7]:
s[1].j({3: 1, 8: 1, 4: -1})  # order of arguments is not important
{0: 1, 1: -1, 2: -1, 3: 1, 4: 1, 5: -1, 6: -1, 7: -1, 8: 1}

[1] PN16/NJ210E - gap between cover and bearing (shaft pushed rt.)
r  su  σ  j     d        dt     pn & n
1  12  6  -  0.3190 ± 0.0050  PN16, Mounting face to rt. end
2   8  6  - 10.4860 ± 0.0100  PN07, Overall width
3  12  6  +  0.3190 ± 0.0050  PN16, Mounting face to rt. end
4   2  6  +  0.9031 ± 0.0024  NJ2210E, Bearing width
5  10  6  -  0.5780 ± 0.0050  PN14, Width
6   9  6  -  1.4070 ± 0.0050  PN12, Width
7  11  6  -  6.0390 ± 0.0050  PN15, Lf brg shldr to gear shldr
8   2  6  +  0.9031 ± 0.0024  NJ2210E, Bearing width
------------------------------------------------------------
-16.7037 ± 0.0397  [-16.7434, -16.6640]  100% possible
-16.7037 ± 0.0154  [-16.7191, -16.6884]  6σ, 99.73% probable
-16.7037 ± 0.0102  [-16.7140, -16.6935]  4σ, 95.46% probable
-16.7037 ± 0.0051  [-16.7088, -16.6986]  2σ, 68.26% probable
  σ = 0.00512

Let's set the values of j back to their correct value.

In [8]:
s[1].j(-1, 2, -3, -4, -5, -6, -7, -8)
{0: 1, 1: -1, 2: 1, 3: -1, 4: -1, 5: -1, 6: -1, 7: -1, 8: -1}

[1] PN16/NJ210E - gap between cover and bearing (shaft pushed rt.)
r  su  σ  j     d        dt     pn & n
1  12  6  -  0.3190 ± 0.0050  PN16, Mounting face to rt. end
2   8  6  + 10.4860 ± 0.0100  PN07, Overall width
3  12  6  -  0.3190 ± 0.0050  PN16, Mounting face to rt. end
4   2  6  -  0.9031 ± 0.0024  NJ2210E, Bearing width
5  10  6  -  0.5780 ± 0.0050  PN14, Width
6   9  6  -  1.4070 ± 0.0050  PN12, Width
7  11  6  -  6.0390 ± 0.0050  PN15, Lf brg shldr to gear shldr
8   2  6  -  0.9031 ± 0.0024  NJ2210E, Bearing width
------------------------------------------------------------
  0.0177 ± 0.0397  [-0.0220, 0.0574]  100% possible
  0.0177 ± 0.0154  [0.0024, 0.0331]  6σ, 99.73% probable
  0.0177 ± 0.0102  [0.0075, 0.0280]  4σ, 95.46% probable
  0.0177 ± 0.0051  [0.0126, 0.0228]  2σ, 68.26% probable
  σ = 0.00512

Deleting stackunits/stacks, del

In [9]:
s[2]  # the 2nd Stack within s
Out[9]:
[2] PN03, required thickness for shim
r  su  σ  j     d       dt     pn & n
1   5  6  + 0.3850 ± 0.0050  PN05, Mounting face to rt. end
2  13  6  + 1.1764 ± 0.0028  478/473, Bearing pressed width
3   6  6  + 0.5360 ± 0.0050  PN06, Shoulder
4   4  6  + 2.3170 ± 0.0100  PN02, Gear width
5   3  6  + 0.3730 ± 0.0050  PN01, Thickness
6  13  6  + 1.1764 ± 0.0028  478/473, Bearing pressed width
7   7  6  - 5.9170 ± 0.0150  PN07, Output pocket depth
------------------------------------------------------------
 0.0468 ± 0.0456  [0.0012, 0.0924]  100% possible
 0.0468 ± 0.0204  [0.0265, 0.0672]  6σ, 99.73% probable
 0.0468 ± 0.0136  [0.0333, 0.0604]  4σ, 95.46% probable
 0.0468 ± 0.0068  [0.0400, 0.0536]  2σ, 68.26% probable
  σ = 0.00680

To delete the row number 6 within s[2]:

In [10]:
del s[2][6]   # this deletes row 6.
s[2]   # show s[2] again
Out[10]:
[2] PN03, required thickness for shim
r  su  σ  j     d       dt     pn & n
1   5  6  + 0.3850 ± 0.0050  PN05, Mounting face to rt. end
2  13  6  + 1.1764 ± 0.0028  478/473, Bearing pressed width
3   6  6  + 0.5360 ± 0.0050  PN06, Shoulder
4   4  6  + 2.3170 ± 0.0100  PN02, Gear width
5   3  6  + 0.3730 ± 0.0050  PN01, Thickness
6   7  6  + 5.9170 ± 0.0150  PN07, Output pocket depth
------------------------------------------------------------
10.7044 ± 0.0428  [10.6616, 10.7472]  100% possible
10.7044 ± 0.0202  [10.6842, 10.7246]  6σ, 99.73% probable
10.7044 ± 0.0135  [10.6910, 10.7179]  4σ, 95.46% probable
10.7044 ± 0.0067  [10.6977, 10.7112]  2σ, 68.26% probable
  σ = 0.00673

Delete an entire Stack. This will delete all of s[2]. After the delete, stacks are renumbered. s[3] becomes s[2], s[4] becomes s[3], and so forth.

In [11]:
del s[2]  # s[2] gets deleted
s[2]  # show what is now s[2]
Out[11]:
[2] PN09, required thickness for shim
r  su  σ  j     d       dt     pn & n
1  15  6  - 4.0670 ± 0.0100  PN07, Input pocket depth
2  14  6  + 0.8804 ± 0.0047  24780/24720, Bearing pressed width
3  16  6  + 2.1450 ± 0.0050  PN11, Shoulder to shoulder
4  14  6  + 0.8804 ± 0.0047  24780/24720, Bearing pressed width
5  17  6  + 0.2000 ± 0.0050  PN10, Mounting face to brg stop
------------------------------------------------------------
 0.0387 ± 0.0294  [0.0093, 0.0681]  100% possible
 0.0387 ± 0.0139  [0.0248, 0.0526]  6σ, 99.73% probable
 0.0387 ± 0.0093  [0.0294, 0.0480]  4σ, 95.46% probable
 0.0387 ± 0.0046  [0.0341, 0.0433]  2σ, 68.26% probable
  σ = 0.00465

Search, o()

o() is a method to search all stacks withing s. When searching for a part number or dimension's description, surround the method's argument with single (') or double (") quote marks. Use of the asterisk (*) character as a wildcard is acceptable.

In [12]:
s.o('bearing')
su σ    d       dt     pn & n
14 6 0.8804 ± 0.0047 24780/24720, Bearing pressed width
13 6 1.1764 ± 0.0028 478/473, Bearing pressed width
 2 6 0.9031 ± 0.0024 NJ2210E, Bearing width

In [13]:
s.o(2.14)  # search for a dimension or tolerance.m
su σ    d       dt     pn & n
16 6 2.1450 ± 0.0050 PN11, Shoulder to shoulder

Appending Stackunits via su values

Suppose we want to use one or more of these already established Stackunit values in a new stackup. It's burdonsome to have to retype the dimension, tolerance, pn, and description. There is a shortcut. Instead use su (stack unit) value of a Stack Unit. Let's create a new Stack and add some fictitios data to it as an example.

In [14]:
settings(silent=True, autoprint=False)  # suppress output (makes for a cleaner html page)
s.a(Stack(title='new stack for experimenting'))  # new stack, s[7] started
settings(silent=True, autoprint=True)

To see all the su values use the search method (shortcut: o).

In [15]:
s.o()
su σ    d        dt     pn & n
14 6  0.8804 ± 0.0047 24780/24720, Bearing pressed width
13 6  1.1764 ± 0.0028 478/473, Bearing pressed width
 2 6  0.9031 ± 0.0024 NJ2210E, Bearing width
 3 6  0.3730 ± 0.0050 PN01, Thickness
 4 6  2.3170 ± 0.0100 PN02, Gear width
 7 6  5.9170 ± 0.0150 PN07, Output pocket depth
 8 6 10.4860 ± 0.0100 PN07, Overall width
15 6  4.0670 ± 0.0100 PN07, Input pocket depth
22 6  0.2150 ± 0.0150 PN07, Input cap to idler cap
17 6  0.2000 ± 0.0050 PN10, Mounting face to brg stop
16 6  2.1450 ± 0.0050 PN11, Shoulder to shoulder
20 6  1.5720 ± 0.0150 PN11, Gear width
21 6  0.4470 ± 0.0150 PN11, Lf brg shldr to gear
 9 6  1.4070 ± 0.0050 PN12, Width
10 6  0.5780 ± 0.0050 PN14, Width
11 6  6.0390 ± 0.0050 PN15, Lf brg shldr to gear shldr
18 6  5.2950 ± 0.0150 PN15, Lf side of small gear to gear shldr
19 6  2.4640 ± 0.0150 PN15, Gear width
12 6  0.3190 ± 0.0050 PN16, Mounting face to rt. end

We'll use the extend method (append works for appending one value at a time).

In [16]:
s[7].extend(-20, 2, (1.234, .008, 'pn1234', 'decrip for dim'),  -3, (2.456, .010, 'pn4321', 'another descrip'), -11)
[7] new stack for experimenting
r  su  σ  j     d       dt     pn & n
1  20  6  - 1.5720 ± 0.0150  PN11, Gear width
2   2  6  + 0.9031 ± 0.0024  NJ2210E, Bearing width
3  23  6  + 1.2340 ± 0.0080  pn1234, decrip for dim
4   3  6  - 0.3730 ± 0.0050  PN01, Thickness
5  24  6  + 2.4560 ± 0.0100  pn4321, another descrip
6  11  6  - 6.0390 ± 0.0050  PN15, Lf brg shldr to gear shldr
------------------------------------------------------------
-3.3909 ± 0.0454  [-3.4362, -3.3455]  100% possible
-3.3909 ± 0.0211  [-3.4119, -3.3698]  6σ, 99.73% probable
-3.3909 ± 0.0141  [-3.4049, -3.3768]  4σ, 95.46% probable
-3.3909 ± 0.0070  [-3.3979, -3.3838]  2σ, 68.26% probable
  σ = 0.00703

Integer values (-20, 2, -3, -11) are su values. Applying a negative value makes the jog (j) value negative. The values in parenthesis are newly established stackunits.

Mixing units, mm, inch

The numbers used in this program are unitless. This means that if your dimensions are in inches, ALL the dimensions and tolerances must be in inches. And if in millimeters, all must be in millimeters. But sometimes you may be dealing with some drawings of parts with metric units, and others drawings with english units. Presented here is an easy way of dealing with this.

Let's assume we're working with inches, and we have a bearing width of some part that is 20mm ± .5mm. Knowing that 25.4mm = 1 inch:

In [17]:
s[7].append(20/25.4, .5/25.4, 'pnABCD', 'a descrip')
[7] new stack for experimenting
r  su  σ  j     d       dt     pn & n
1  20  6  - 1.5720 ± 0.0150  PN11, Gear width
2   2  6  + 0.9031 ± 0.0024  NJ2210E, Bearing width
3  23  6  + 1.2340 ± 0.0080  pn1234, decrip for dim
4   3  6  - 0.3730 ± 0.0050  PN01, Thickness
5  24  6  + 2.4560 ± 0.0100  pn4321, another descrip
6  11  6  - 6.0390 ± 0.0050  PN15, Lf brg shldr to gear shldr
7  25  6  + 0.7874 ± 0.0197  pnABCD, a descrip
------------------------------------------------------------
-2.6035 ± 0.0650  [-2.6685, -2.5384]  100% possible
-2.6035 ± 0.0288  [-2.6323, -2.5746]  6σ, 99.73% probable
-2.6035 ± 0.0192  [-2.6227, -2.5842]  4σ, 95.46% probable
-2.6035 ± 0.0096  [-2.6131, -2.5938]  2σ, 68.26% probable
  σ = 0.00962

Updating dimensions/tolerances in a Stackunit, u()

With the update() method (or simply u()), one can easily change a value within a Stackunit. Here are some examples to show how to use this method:

In [18]:
settings(silent=True, autoprint=False)  # suppress output (to make this webpage cleaner)

s.u(1.572, .007, su=20)  # Change Stackunit no. 20.  (d=1.572 didn't change.  d is a placeholder)

s.u(sigma=3.5, su=3)  # change the sigma value of Stackunit no. 3

s.u(n='Lf brg shldr to gear shldr', su=11)  # description change

s.u('PN0012', 'gearbox width', su=8)  # change the pt. no. and descrip. of su #8.

# s.u(n='width', 3.420, .015, su=8)  # this will throw an error.  Variable assignments (n) must be last.
# s.u(3.420, .015, n='width', su=8)  # this will work.  Variable assignments n and su) are last.

settings(silent=True, autoprint=True)  # return "silent" and "autoprint" back to defaults.

To have a look at the variables and their names within a Stackunit, look within any Stackunit like this:

In [19]:
s[5][2]   # Look at Stackunit at row 2 within Stack #5
Out[19]:
{'dt': 0.015, 'd': 0.447, 'n': 'Lf brg shldr to gear', 'pn': 'PN11', 'su': 21, 'sigma': 6}

More

There are other methods available for editing (insert, move, renamepn, etc.). Use the help method to get information on these methods.

< Previous | Next >