Notifications
Clear all

OpensCAD rotate screw  

  RSS
Grzegorz Toma
(@grzegorz-toma)
Member
OpensCAD rotate screw

Hello,I would like to rotate the slots for screw. How can I do that? The function 'rotate' doesn't work in this case.

profile_width = 20.0; // [10:0.1:50]
profile_height = 5; // [1:0.1:30]
mount_distance = 2.5; // [2.5:0.1:15]
clip_size = 20; // [5:0.5:30]
arm = 0; // [0.5:0.1:3]

module test()
{
}

profile_h=profile_width;
profile_d=profile_height;;

holder_l=clip_size;;
holder_d=4;
wall=2;
delta=0.05;

screwh=10;
screwh2=7.5;
screwd=1.6;
screwholderw=24;
screwholderd=mount_distance;
swall=1;

difference()
{

rotate ([0,0,90]);
cube([holder_l,profile_d+wall,profile_h+wall*2]);
translate([-delta,-delta,wall]) cube([holder_l+2*delta,profile_d,profile_h]);
}
translate([0,-wall+delta,delta]) cube([holder_l,wall,wall+arm]);
translate([0,-wall+delta,profile_h-delta-arm+wall]) cube([holder_l,wall,wall+arm]);

difference()
{

rotate ([0,0,90]);
translate([0,profile_d+wall-delta,(profile_h+2*wall-screwholderw)/2]) cube([holder_l,screwholderd,screwholderw]);
translate([-delta,profile_d+wall-swall+screwholderd+delta,(profile_h+3*wall-screwh2)/2]) cube([holder_l+2*delta, swall, screwh2-swall]);
translate([-delta,profile_d+screwholderd+wall-screwd-swall+2*delta,(profile_h+3*wall-screwh)/2]) cube([holder_l+2*delta, screwd, screwh-swall]);
}

Posted : 08/01/2024 4:16 pm
blauzahn
(@blauzahn)
Reputable Member
RE: OpensCAD rotate screw

The semicolon immediately after the rotate statement is wrong. It rotates what comes before the semicolon, that is: nothing.

Please write instead something like:

rotate([0, 0, 90]) translate([dx, dy, dz]) cube([10, 20, 30]);

 

With the compound statement {} you can group things that you want to transform together, like:

rotate([0, 0, 90]){
  translate([0, 0, dz]){
     translate([dx0, dy0, 0])  cube([10, 20, 30]);
     translate([dx1, dy1, 0]) cube([40, 50, 60]);
  }
}

 

Posted : 08/01/2024 8:30 pm
Share: