In that last difference, the translate should be outside the last rotate:
difference()
{
translate([21,0,127])
sphere(d=14);
translate([12,0,127])
rotate([0,90,0])
cylinder(h=20,d=11.1);
}
that is: make a cylinder, then rotate it, then translate it - we say:
translate()rotate()cylinder().
This falls out of the language grammar: clearly
cylinder()rotate()translate() would be nonsense. But these built-ins
implicitly take their list of children as a last argument. If OpenSCAD were
C, you'd say: translate(rotate(cylinder())) - that is, to evaluate a
function, you apply the function to the evaluation of its arguments.
On Mon, Apr 22, 2024 at 10:29 PM Robbie Sandberg via Discuss <
discuss@lists.openscad.org> wrote:
Hi!
In the following 2 sketches I’m trying to create a hole in the middle of a
sphere by subtracting a cylinder.
While the sphere comes out in the correct place, There is no hole.
I should mention that I’m blind and can’t check my design in the app.
Obviously there is something I’m not getting about transformation. I’d be
really glad if someone could enlighten me as to the actual positions of the
cylinders.
Sketch 1:
difference()
{
cylinder(h=10,d=39);
cylinder(h=10,d=35);
}
difference()
{
translate([0,0,5])
cylinder(h=50,r1=23,r2=5);
cylinder(h=50,r1=19,r2=4);
}
difference()
{
translate([0,0,50])
sphere(d=10);
translate([0,0,50])
cylinder(h=10,d=3, center=true);
}
Sketch 2:
difference()
{
cylinder(h=140,r1=33,r2=23);
cylinder(h=140,r1=30.5,r2=20.5);
}
difference()
{
translate([0,0,7])
cylinder(h=3,d=65);
translate([0,0,7])
cylinder(h=3,d=54);
}
difference()
{
translate([21,0,127])
sphere(d=14);
rotate([0,90,0])
translate([12,0,127])
cylinder(h=20,d=11.1);
}
Cheers! Robbie
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
I will also mention that the second cylinder in the first difference of the first sketch should have an increased height and small translate, such as the following:
difference(){
cylinder(h=10,d=39);
translate([0,0,-1])cylinder(h=12,d=35);}
When using difference() the item(s) being subtracted should be slightly larger than the original. This prevents the renderer from being "confused" as to whether the edges are to be subtracted or not.
Nathan Sokalski
njsokalski@hotmail.commailto:njsokalski@hotmail.com
From: David Phillip Oster via Discuss discuss@lists.openscad.org
Sent: Tuesday, April 23, 2024 1:52 AM
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc: David Phillip Oster davidphilliposter@gmail.com
Subject: [OpenSCAD] Re: Trouble with transformation
In that last difference, the translate should be outside the last rotate:
difference()
{
translate([21,0,127])
sphere(d=14);
translate([12,0,127])
rotate([0,90,0])
cylinder(h=20,d=11.1);
}
that is: make a cylinder, then rotate it, then translate it - we say: translate()rotate()cylinder().
This falls out of the language grammar: clearly cylinder()rotate()translate() would be nonsense. But these built-ins implicitly take their list of children as a last argument. If OpenSCAD were C, you'd say: translate(rotate(cylinder())) - that is, to evaluate a function, you apply the function to the evaluation of its arguments.
On Mon, Apr 22, 2024 at 10:29 PM Robbie Sandberg via Discuss <discuss@lists.openscad.orgmailto:discuss@lists.openscad.org> wrote:
Hi!
In the following 2 sketches I’m trying to create a hole in the middle of a sphere by subtracting a cylinder.
While the sphere comes out in the correct place, There is no hole.
I should mention that I’m blind and can’t check my design in the app.
Obviously there is something I’m not getting about transformation. I’d be really glad if someone could enlighten me as to the actual positions of the cylinders.
Sketch 1:
difference()
{
cylinder(h=10,d=39);
cylinder(h=10,d=35);
}
difference()
{
translate([0,0,5])
cylinder(h=50,r1=23,r2=5);
cylinder(h=50,r1=19,r2=4);
}
difference()
{
translate([0,0,50])
sphere(d=10);
translate([0,0,50])
cylinder(h=10,d=3, center=true);
}
Sketch 2:
difference()
{
cylinder(h=140,r1=33,r2=23);
cylinder(h=140,r1=30.5,r2=20.5);
}
difference()
{
translate([0,0,7])
cylinder(h=3,d=65);
translate([0,0,7])
cylinder(h=3,d=54);
}
difference()
{
translate([21,0,127])
sphere(d=14);
rotate([0,90,0])
translate([12,0,127])
cylinder(h=20,d=11.1);
}
Cheers! Robbie
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.orgmailto:discuss-leave@lists.openscad.org