Ball Bearing Script

From Open Source Ecology
Jump to: navigation, search

Explained fully at https://linuxforanengineer.blogspot.com/2013/08/free-cad-bearing-script.html:

import Part
import math

#VALUES#

R1=15.0
R2=25.0
R3=30.0
R4=40.0
TH=15.0
NBall=10
RBall=5.0

#Program#

B1=Part.makeCylinder(R1,TH)
B2=Part.makeCylinder(R2,TH)
IR=B2.cut(B1)


B3=Part.makeCylinder(R3,TH)
B4=Part.makeCylinder(R4,TH)
OR=B4.cut(B3)

Part.show(IR)
Part.show(OR)

CBall=((R3-R2)/2)+R2
PBall=TH/2

for i in range(NBall):
  Ball=Part.makeSphere(RBall) 
  Alpha=(i*2*math.pi)/NBall  
  BV=(CBall*math.cos(Alpha),CBall*math.sin(Alpha),TH/2)
  Ball.translate(BV)
  Part.show(Ball)