functionbb_colour(type)=type[4];//! Shield colour, "silver" for metal
functionbb_rim(type)=bb_diameter(type)/10;//! Inner and outer rim thickness
moduleball_bearing(type){//! Draw a ball bearing
shield=bb_colour(type);
suffix=shield=="silver"?"ZZ ":"-2RS ";
vitamin(str("ball_bearing(BB",bb_name(type),"): Ball bearing ",bb_name(type),suffix,bb_bore(type),"mm x ",bb_diameter(type),"mm x ",bb_width(type),"mm"));
rim=bb_rim(type);
h=bb_width(type);
od=bb_diameter(type);
id=bb_bore(type);
moduletube(od,id,h)
linear_extrude(height=h,center=true,convexity=5)
difference(){
circle(d=od);
circle(d=id);
}
color("silver"){
tube(od,od-rim,h);
tube(id+rim,id,h);
}
color(shield)tube(od-rim,id+rim,h-1);
if($children)
translate_z(bb_width(type)/2)
children();
}
modulebearing_ball(dia){//! Draw a steel bearing ball