Outils d'utilisateurs

Outils du Site


animations:ateliers_openscad:exercices:ressort

Ceci est une ancienne révision du document !


Défi OpenSCAD Ressort

Fiche projet

Consigne : Réaliser un ressort ! >Il s'agit du défi de fin de l'atelier Programmer avec OpenSCAD. * méthode A : 1 ligne & 1 fonction différente (Méthode Bully) * méthode B : 15 lignes & 3 fonctions différentes (Méthode Hélène) méthode A <code> nb_sphere=100; nbboucle=0.5;nb_sphere/360 diamsphere=20; $fn=20;

for ( i= [0:nb_sphere] )
    rotate([0,0,i*(nbboucle*360/nb_sphere)]) {
        translate([0,2.5*diamsphere,i]){
            sphere(d=diamsphere);
        }
      translate([0,-2.5*diamsphere,i]){
            sphere(d=diamsphere);
        }
      translate([2.5*diamsphere,0,i]){
          sphere(d=diamsphere);
        }
      translate([-2.5*diamsphere,0,i]){
          sphere(d=diamsphere);
          }         
        }
        difference(){
$fn=60;
union(){
  translate([0,0,-0.25*diamsphere]){
    cylinder(r=3*diamsphere, h=10,center=true);
  }
  translate([0,0,5+nb_sphere]){
    cylinder(r=3*diamsphere, h=10, center=true);
  }
}
translate([0,0,-diamsphere]){
  cylinder(r=2*diamsphere,h=1.5*nb_sphere);
}
}

</code>

méthode B

p=50; //rayon par rapport au centre
ds=10; // diamètre de la sphère
pas=2; // pas
itineration =200; // gère aussi la hauteur de la pièce

for(positionX=[p,-p], positionY=[p,-p],i=[1:itineration]){
rotate([0,0,i*pas])
translate([0,0,i*pas])
translate([positionX,positionY,0]) sphere(ds, $fn=75);
}

difference(){
 union(){
translate([0,0,-ds])cylinder(r=2*(p-ds)+2,h=ds,$fn=100);
translate([0,0,itineration*pas])cylinder(r=2*(p-ds)+2,h=ds,$fn=100);
 }
 translate([0,0,-ds-0.1])cylinder(r=p+ds,h=itineration*pas+2*ds+0.2,$fn=100);
 }
animations/ateliers_openscad/exercices/ressort.1597844413.txt.gz · Dernière modification: 2020/08/19 15:40 par plogingenu