discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

incrementing a variable and other confusions for a procedural coder

D
David
Sat, Dec 5, 2020 7:04 AM

It's obviously not optimized yet.  As mentioned, it's kinda baselined
peek and poke just to get the function crystalized in my head.  Does the
snipped you wrote draw the entire (to this point) construction?

On 12/5/20 12:54 AM, lar3ry wrote:

Well, it's definitely not the way I would go about it, so here's what I would
do.
You'll have to play with the values, and you are certainly welcome to put
them into variables.
Note the pound sign (#). It will help you see where the line puts the
object.

difference() {
union() {
translate([0,18,0])
cube([37,16.67,4]);
translate([22,18,0])
cube([6,16.67,30]);
translate([28,0,0])
cube([9,19,4]);
}
translate([13,22,-.001])

cylinder(h=6,d=3);

translate([31,4,-.001])

cylinder(h=6,d=3);

}

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

It's obviously not optimized yet.  As mentioned, it's kinda baselined peek and poke just to get the function crystalized in my head.  Does the snipped you wrote draw the entire (to this point) construction? On 12/5/20 12:54 AM, lar3ry wrote: > Well, it's definitely not the way I would go about it, so here's what I would > do. > You'll have to play with the values, and you are certainly welcome to put > them into variables. > Note the pound sign (#). It will help you see where the line puts the > object. > > difference() { > union() { > translate([0,18,0]) > cube([37,16.67,4]); > translate([22,18,0]) > cube([6,16.67,30]); > translate([28,0,0]) > cube([9,19,4]); > } > translate([13,22,-.001]) > # cylinder(h=6,d=3); > translate([31,4,-.001]) > # cylinder(h=6,d=3); > } > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
D
David
Sat, Dec 5, 2020 7:07 AM

What function does the # indicate in OpenSCAD?

And what does the -0.001 do for us?

David

On 12/5/20 12:54 AM, lar3ry wrote:

Well, it's definitely not the way I would go about it, so here's what I would
do.
You'll have to play with the values, and you are certainly welcome to put
them into variables.
Note the pound sign (#). It will help you see where the line puts the
object.

difference() {
union() {
translate([0,18,0])
cube([37,16.67,4]);
translate([22,18,0])
cube([6,16.67,30]);
translate([28,0,0])
cube([9,19,4]);
}
translate([13,22,-.001])

cylinder(h=6,d=3);

translate([31,4,-.001])

cylinder(h=6,d=3);

}

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

What function does the # indicate in OpenSCAD? And what does the -0.001 do for us? David On 12/5/20 12:54 AM, lar3ry wrote: > Well, it's definitely not the way I would go about it, so here's what I would > do. > You'll have to play with the values, and you are certainly welcome to put > them into variables. > Note the pound sign (#). It will help you see where the line puts the > object. > > difference() { > union() { > translate([0,18,0]) > cube([37,16.67,4]); > translate([22,18,0]) > cube([6,16.67,30]); > translate([28,0,0]) > cube([9,19,4]); > } > translate([13,22,-.001]) > # cylinder(h=6,d=3); > translate([31,4,-.001]) > # cylinder(h=6,d=3); > } > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
L
lar3ry
Sat, Dec 5, 2020 7:29 AM

skypuppy wrote

It's obviously not optimized yet.  As mentioned, it's kinda baselined
peek and poke just to get the function crystalized in my head.  Does the
snipped you wrote draw the entire (to this point) construction?

What function does the # indicate in OpenSCAD?

And what does the -0.001 do for us?

You have made it (to my way of thinking) more complicated by starting off
with a large cube, putting all your values into variables, and cutting away
a lot of things.

Yes, my program draws the entire (to this point) construction. I did not
bother trying to figure out the exact values, but rather created an STL
file, imported it, and then created an approximate duplicate by overlaying
cubes and subtracting cylinders, each one using the # character to see when
I had the dimensions close enough.

When you put the # in front of a line, it highlights the part drawn in
translucent red so you can see what the line is doing, when you preview the
drawing. Just put the program into OpenSCAD and you'll see. Try putting it
in front of the first cube(). I purposely made the cube the size I made it
to show you something.

The -.001 moves the bottom of the cylinder .001 below the bottom of both
cubes. try replacing one of them with a 0, and rotate the preview until you
can see the bottom. You'll see a difference in the two holes. The shimmering
is caused by having two surfaces in the same plane. In either case, the hole
will be fine when it's rendered.

Just paste that into OpenSCAD and play with it.

--
Sent from: http://forum.openscad.org/

skypuppy wrote > It's obviously not optimized yet. As mentioned, it's kinda baselined > peek and poke just to get the function crystalized in my head. Does the > snipped you wrote draw the entire (to this point) construction? > > What function does the # indicate in OpenSCAD? > > And what does the -0.001 do for us? You have made it (to my way of thinking) more complicated by starting off with a large cube, putting all your values into variables, and cutting away a lot of things. Yes, my program draws the entire (to this point) construction. I did not bother trying to figure out the exact values, but rather created an STL file, imported it, and then created an approximate duplicate by overlaying cubes and subtracting cylinders, each one using the # character to see when I had the dimensions close enough. When you put the # in front of a line, it highlights the part drawn in translucent red so you can see what the line is doing, when you preview the drawing. Just put the program into OpenSCAD and you'll see. Try putting it in front of the first cube(). I purposely made the cube the size I made it to show you something. The -.001 moves the bottom of the cylinder .001 below the bottom of both cubes. try replacing one of them with a 0, and rotate the preview until you can see the bottom. You'll see a difference in the two holes. The shimmering is caused by having two surfaces in the same plane. In either case, the hole will be fine when it's rendered. Just paste that into OpenSCAD and play with it. -- Sent from: http://forum.openscad.org/