Podkładka falista
Wave washer
Działanie tego skryptu:
-
Tworzy okno dialogowe z pytaniami o parametry żądanej podkładki
-
Tworzy nową część
-
Tworzy profil wyciągnięcia po ścieżce oraz operację „Wyciągnięcie po ścieżce” (Sweep Boss)
„Kopiuj” (Copy) kod Python
import mathfrom math import *

# radiusR = 100.0# amplitudeA = 10.0# number of waves (must be a whole number)B = 4
# widthWidth = 10# thicknessThickness = 5
Win = Windows()
Options = []Options.append(['Radius', WindowsInputTypes.Real, R])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[0]A = Values[1]B = Values[2]Width = Values[3]Thickness = Values[4]
# path accuracy = lower number = more points calculatedt_step = 0.1
# complete circle = PI x 2t_max = 3.141592 * 2
# keep track of the total points we have calculatedTotalPoints = 0
# calculate points for 3D sketchPathPoints = []t = 0while 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 pathPathPoints.extend([PathPoints[0], PathPoints[1], PathPoints[2]])
# create part and add 3d sketchP = Part('Wave Washer')Path = P.Add3DSketch('Path')Path.AddBspline(PathPoints)
# calculate normal vector for the plane at the start of the pathnormal_vector = [P2[0] - P1[0], P2[1] - P1[1], P2[2] - P1[2]]
# create plane at the start of the pathPlane = P.AddPlane('Start Plane', normal_vector, P1)
CrossSection = P.AddSketch('Cross Section', Plane)
Origin = CrossSection.GlobaltoPoint(P1[0], P1[1], P1[2])
CrossSection.AddRectangle(Origin[0] - (Thickness / 2.0), Origin[1] - (Width / 2.0), Origin[0] + (Thickness / 2.0), Origin[1] + (Width / 2.0), False)
P.AddSweepBoss('Washer', CrossSection, Path, False, Part.EndCondition.EntirePath, None, 0, 0, False)Oryginał: Wave washer