# Wave washer What this script does:

• Creates a dialog that asks you information about the desired washer
• Creates a new part
• Creates a sweep profile and a Sweep Boss

```import math
from math import *

R = 100.0
# amplitude
A = 10.0
# number of waves (must be a whole number)
B = 4

# width
Width = 10
# thickness
Thickness = 5

Win = Windows()

Options = []
Options.append(['Amplitude', WindowsInputTypes.Real, A])
Options.append(['Number of Waves', WindowsInputTypes.Integer, B])
Options.append(['Width', WindowsInputTypes.Real, Width])
Options.append(['Thickness', WindowsInputTypes.Real, Thickness])

Values = Win.OptionsDialog('Wave Washer Generator', Options)
if Values == None:
sys.exit()

R = Values
A = Values
B = Values
Width = Values
Thickness = Values

# path accuracy = lower number = more points calculated
t_step = 0.1

# complete circle = PI x 2
t_max = 3.141592 * 2

# keep track of the total points we have calculated
TotalPoints = 0

# calculate points for 3D sketch
PathPoints = []
t = 0
while True:
X = R * sin(t)
Y = R * cos(t)
Z = A * sin(B * t)
PathPoints.extend([X, Y, Z])

if TotalPoints == 0:
P1 = [X, Y, Z]
elif TotalPoints == 1:
P2 = [X, Y, Z]

t = t + t_step
TotalPoints = TotalPoints + 1
if t >= t_max:
break

# close path
PathPoints.extend([PathPoints, PathPoints, PathPoints])

# create part and add 3d sketch
P = Part('Wave Washer')

# calculate normal vector for the plane at the start of the path
normal_vector = [P2 - P1, P2 - P1, P2 - P1]

# create plane at the start of the path
Plane = P.AddPlane('Start Plane', normal_vector, P1)

Origin = CrossSection.GlobaltoPoint(P1, P1, P1)

CrossSection.AddRectangle(Origin - (Thickness / 2.0), Origin - (Width / 2.0), Origin + (Thickness / 2.0), Origin + (Width / 2.0), False)

P.AddSweepBoss('Washer', CrossSection, Path, False, Part.EndCondition.EntirePath, None, 0, 0, False)```

Did you find it helpful? Yes No

Send feedback 