A 2 year old post, but it challenged me.
I started with a simple one. One side slightly convex...
module roundfrontcube() {
intersection(){
cylinder(d=200,h=20);
translate([-30,-100,-.001])
#cube([60,30,21]);
}
}
Then I tried fillets and one side slightly convex...
intersection() {
translate([0,98,0])
}
module fil_cube() {
union(){
translate([-15.5,1,0])
hull() {
cylinder(h=12,r=2);
translate([30,0,0])
cylinder(h=12,r=2);
translate([30,20,0])
cylinder(h=12,r=2);
translate([0,20,0])
cylinder(h=12,r=2);
}
translate([-16,-4,0])
cube([31,3,12]);
}
}
--
Sent from: http://forum.openscad.org/
That solution has a non-smooth transition where the cylinder meets the
rounded cube---a small corner. It may not really matter, since it's pretty
subtle, but it seems inelegant to me:
http://forum.openscad.org/file/t2477/rect4.png
I see three basic approaches. One is to do something like previously
suggested with circles, for example. Note that my solution below actually
directly sets the bulge amount. But round2d() depends on offset().
The Round-Anything library is here:
https://github.com/Irev-Dev/Round-Anything
// Draw a segment of a circle with specified length and height
module segment(length, height){
r=(lengthlength+4height*height)/8/height;
intersection(){
translate([0,(height+1)/2])
square([length+2, height+1], center=true);
translate([0,-r+height])circle(r=r);
}
}
use <lib/Round-Anything/polyround.scad>
$fn=120;
bulge = 1;
cornerR = 1;
round2d(cornerR){
square([10,5],center=true);
translate([0,2.5])segment(10,bulge);
}
http://forum.openscad.org/file/t2477/rect1.png
Here's a second approach that avoids using offset() but instead relies on
polyRound, a function which applies a specified roundover radius at every
corner of a polygon.
use <lib/Round-Anything/polyround.scad>
bulge=2; // Actual bulge is less due to rounding to the inside
width=10;
height=5;
cornerR=1;
bulgeR=2*width;
rect = [[0,0,cornerR],
[width,0,cornerR],
[width,height,cornerR],
[width/2,height+bulge,bulgeR],
[0,height,cornerR]];
polygon(polyRound(rect,fn=20));
http://forum.openscad.org/file/t2477/rect2.png
Here's the third solution, my least favorite, using minkowski(). Of the
three, it took me the most fiddling to get this method working correctly,
and of course it runs slowly. It would be a bit simpler if I didn't cut off
the curved ends of the cylinder with the intersection---it wasn't clear
whether rounded ends were OK or not.
$fn=120;
bulge = 1;
cornerR = 1;
width = 10;
height = 5;
length = 10;
intersection(){
translate([0,bulge/2,length/2])
cube([width, height+bulge, length],center=true);
render() minkowski()
{
sphere(r=cornerR, $fn=32);
linear_extrude(height=length){
square([width-2cornerR,height-2cornerR],center=true);
translate([0,height/2-cornerR])segment(width-2*cornerR,bulge);
}
}
}
http://forum.openscad.org/file/t2477/rect3.png
--
Sent from: http://forum.openscad.org/
I knew when I posted that it was a little kludgy, but figured all I had to do
was to refine the Y offset of the large cylinder to find the sweet spot.
Tried (trial and error) for a while, but could not get it exactly right.
I was hoping that someone would figure out a better way, and perhaps even a
way to use math to position everything.
Anyway, thanks a bunch for your solutions, and a special thank you for the
Round-Anything library. That's a keeper! All I have to do now is to figure
it out and get some practice.
adrianv wrote
That solution has a non-smooth transition where the cylinder meets the
rounded cube---a small corner. It may not really matter, since it's
pretty
subtle, but it seems inelegant to me:
<http://forum.openscad.org/file/t2477/rect4.png>
I see three basic approaches. One is to do something like previously
suggested with circles, for example. Note that my solution below actually
directly sets the bulge amount. But round2d() depends on offset().
The Round-Anything library is here:
https://github.com/Irev-Dev/Round-Anything
--
Sent from: http://forum.openscad.org/
lar3ry wrote
I knew when I posted that it was a little kludgy, but figured all I had to
do
was to refine the Y offset of the large cylinder to find the sweet spot.
Tried (trial and error) for a while, but could not get it exactly right.
I suspect that to get a smooth transition you would have needed to vary the
radius of your cylinder, not just its position. That is, if you picked a
cylinder of a certain size the angle at which it connected with the
rectangle would probably be wrong for the rectangle's width. The equations
for this seem like they are probably messy to work out, so I haven't
checked.
I was hoping that someone would figure out a better way, and perhaps even
a
way to use math to position everything.
Fortunately, it's not necessary to use much math to get good positioning.
In my opinion, when you have to resort to using a lot of math in the design,
and doing calculations for positioning things, it means something is wrong.
The math should be encapsulated into libraries and the designer should not
have to fuss with it. Good solutions to most problems shouldn't require
using a lot of math at the high level. They also shouldn't require trial
and error.
--
Sent from: http://forum.openscad.org/
adrianv wrote
lar3ry wrote
I was hoping that someone would figure out a better way, and perhaps even
a way to use math to position everything.
Fortunately, it's not necessary to use much math to get good positioning.
In my opinion, when you have to resort to using a lot of math in the
design,
and doing calculations for positioning things, it means something is
wrong.
The math should be encapsulated into libraries and the designer should not
have to fuss with it. Good solutions to most problems shouldn't require
using a lot of math at the high level. They also shouldn't require trial
and error.
I have been doing a lot of modification on existing STL files, and the
easiest way I have found is to do pretty much all trial and error. I guess
that may be (bad)habit-forming. I am also the product of a lot of years of
self-taught programming in everything from assembler on up.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@.openscad
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/
lar3ry wrote
The math should be encapsulated into libraries and the designer should
not
have to fuss with it. Good solutions to most problems shouldn't require
using a lot of math at the high level. They also shouldn't require
trial
and error.
I have been doing a lot of modification on existing STL files, and the
easiest way I have found is to do pretty much all trial and error. I guess
that may be (bad)habit-forming. I am also the product of a lot of years of
self-taught programming in everything from assembler on up.
You're importing STL files into OpenSCAD and modifying them? That seems
like it would be difficult to do in a nice fashion.
But if you meant SCAD files then I think it relates to coding style. I
started a discussion here about learning how to use OpenSCAD because I have
been struggling with these issues myself---both finding that I am doing
things by trial and error, and also finding that I can't read my own code a
day later. And I think it has to do with writing code that is at too low a
level. To avoid this, it's necessary to use libraries to abstract the
design. But people here don't seem to be supportive of this approach.
There's an idea that you should do everything directly on your own. Things
like obiscad's attach library or the BOSL library I think are important for
helping us to write code that is easier to read, modify and reuse.
--
Sent from: http://forum.openscad.org/
adrianv wrote
lar3ry wrote
I have been doing a lot of modification on existing STL files, and the
easiest way I have found is to do pretty much all trial and error. I
guess
that may be (bad)habit-forming. I am also the product of a lot of years
of
self-taught programming in everything from assembler on up.
You're importing STL files into OpenSCAD and modifying them? That seems
like it would be difficult to do in a nice fashion.
Actually, I'm quite comfortable with the technique. I am curently in the
process of building a Hypercube Evolution printer, which is running. I want
to make some improvements, one of which is to use a piezo disk as a Z-stop
or bed probe. There is one available for the hotend mount, but I wanted to
make it an under-bed mount. So I took an aready-modified bed mount and used
union and difference to add some parts.
This was one of the more complex mods I've done.
Here's the STL and SCAD file. I have purposely left the congruent faces in
to show what's what in the preview.
Bed_Bracket_15_1-0_mod.stl
http://forum.openscad.org/file/t2121/Bed_Bracket_15_1-0_mod.stl
$fn=60;
translate([30,20,0])
piezomount();
main();
module main() {
difference() {
union() {
translate([0,12,0])
cylinder (h=10, d=30);
translate([9,-3,0])
cube([35,7.05,25]);
}
translate([0,12,0])
cylinder (h=15, d=5);
rotate([90,0,0])
translate([18,8,-6])
cylinder(h=10,d=3);
rotate([90,0,0])
translate([18,17,-6])
cylinder(h=10,d=3);
}
}
module piezomount () {
union() {
difference() {
cylinder (h=4, d=30);
cylinder (h=4, d=28);
}
difference () {
cylinder(h=2, d=30);
cylinder(h=2,d=25);
}
}
}
Z_Piezo_Endstop_V3.png
http://forum.openscad.org/file/t2121/Z_Piezo_Endstop_V3.png
But if you meant SCAD files then I think it relates to coding style. I
started a discussion here about learning how to use OpenSCAD because I
have
been struggling with these issues myself---both finding that I am doing
things by trial and error, and also finding that I can't read my own code
a
day later. And I think it has to do with writing code that is at too low
a
level. To avoid this, it's necessary to use libraries to abstract the
design. But people here don't seem to be supportive of this approach.
There's an idea that you should do everything directly on your own. Things
like obiscad's attach library or the BOSL library I think are important
for
helping us to write code that is easier to read, modify and reuse.
I know exactly what you mean. I always struggle with trying to achieve a
balance. I am definitely old-school in that I have a hard time wrapping my
mind around object oriented languages. Instead of using objects, I tend to
use subroutines and functions, but I do try to make re-usable ones, and
libraries are definitely a nice was to encapsulate groups of modules.
I LOVE the BOSL library, but haven't had a good look at the attach library.
I am going to get a lot of mileage out of the Round-Anything lib.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@.openscad
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/
adrianv wrote
lar3ry wrote
I have been doing a lot of modification on existing STL files, and the
easiest way I have found is to do pretty much all trial and error. I
guess
that may be (bad)habit-forming. I am also the product of a lot of years
of
self-taught programming in everything from assembler on up.
You're importing STL files into OpenSCAD and modifying them? That seems
like it would be difficult to do in a nice fashion.
Actually, I'm quite comfortable with the technique. I am curently in the
process of building a Hypercube Evolution printer, which is running. I want
to make some improvements, one of which is to use a piezo disk as a Z-stop
or bed probe. There is one available for the hotend mount, but I wanted to
make it an under-bed mount. So I took an aready-modified bed mount and used
union and difference to add some parts.
This was one of the more complex mods I've done.
Here's the STL and SCAD file. I have purposely left the congruent faces in
to show what's what in the preview.
Bed_Bracket_15_1-0_mod.stl
http://forum.openscad.org/file/t2121/Bed_Bracket_15_1-0_mod.stl
$fn=60;
translate([30,20,0])
piezomount();
main();
module main() {
difference() {
union() {
translate([0,12,0])
cylinder (h=10, d=30);
translate([9,-3,0])
cube([35,7.05,25]);
}
translate([0,12,0])
cylinder (h=15, d=5);
rotate([90,0,0])
translate([18,8,-6])
cylinder(h=10,d=3);
rotate([90,0,0])
translate([18,17,-6])
cylinder(h=10,d=3);
}
}
module piezomount () {
union() {
difference() {
cylinder (h=4, d=30);
cylinder (h=4, d=28);
}
difference () {
cylinder(h=2, d=30);
cylinder(h=2,d=25);
}
}
}
Z_Piezo_Endstop_V3.png
http://forum.openscad.org/file/t2121/Z_Piezo_Endstop_V3.png
But if you meant SCAD files then I think it relates to coding style. I
started a discussion here about learning how to use OpenSCAD because I
have
been struggling with these issues myself---both finding that I am doing
things by trial and error, and also finding that I can't read my own code
a
day later. And I think it has to do with writing code that is at too low
a
level. To avoid this, it's necessary to use libraries to abstract the
design. But people here don't seem to be supportive of this approach.
There's an idea that you should do everything directly on your own. Things
like obiscad's attach library or the BOSL library I think are important
for
helping us to write code that is easier to read, modify and reuse.
I know exactly what you mean. I always struggle with trying to achieve a
balance. I am definitely old-school in that I have a hard time wrapping my
mind around object oriented languages. Instead of using objects, I tend to
use subroutines and functions, but I do try to make re-usable ones, and
libraries are definitely a nice was to encapsulate groups of modules.
I LOVE the BOSL library, but haven't had a good look at the attach library.
I am going to get a lot of mileage out of the Round-Anything lib.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@.openscad
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/
lar3ry wrote
adrianv wrote
lar3ry wrote
I have been doing a lot of modification on existing STL files, and the
easiest way I have found is to do pretty much all trial and error. I
guess
that may be (bad)habit-forming. I am also the product of a lot of years
of
self-taught programming in everything from assembler on up.
You're importing STL files into OpenSCAD and modifying them? That seems
like it would be difficult to do in a nice fashion.
Actually, I'm quite comfortable with the technique. I am curently in the
process of building a Hypercube Evolution printer, which is running. I
want
to make some improvements, one of which is to use a piezo disk as a Z-stop
or bed probe. There is one available for the hotend mount, but I wanted to
make it an under-bed mount. So I took an aready-modified bed mount and
used
union and difference to add some parts.
<example deleted>
Interesting example. Note for anyone running it that that there is a subtle
filename mismatch.
I had never tried importing an STL file into OpenSCAD, so it was nice to see
this. But what I meant when I said it wasn't going to be "nice" is that
trial and error is going to be unavoidable, since you won't (presumably)
know where anything is in the imported model, or have any way to orient
things to it.
But if you meant SCAD files then I think it relates to coding style. I
started a discussion here about learning how to use OpenSCAD because I
have
been struggling with these issues myself---both finding that I am doing
things by trial and error, and also finding that I can't read my own code
a
day later. And I think it has to do with writing code that is at too low
a
level. To avoid this, it's necessary to use libraries to abstract the
design. But people here don't seem to be supportive of this approach.
There's an idea that you should do everything directly on your own.
Things
like obiscad's attach library or the BOSL library I think are important
for
helping us to write code that is easier to read, modify and reuse.
I know exactly what you mean. I always struggle with trying to achieve a
balance. I am definitely old-school in that I have a hard time wrapping my
mind around object oriented languages. Instead of using objects, I tend to
use subroutines and functions, but I do try to make re-usable ones, and
libraries are definitely a nice was to encapsulate groups of modules.
I LOVE the BOSL library, but haven't had a good look at the attach
library.
I am going to get a lot of mileage out of the Round-Anything lib.
Well, no "objects" in the sense of object oriented programming are available
in OpenSCAD, so you can stay old school. :)
What do you mean when you say "it's hard to find balance"? To me it seems
like the higher level I can write my code at the better, so it's not about
balance, but about pushing for libraries with more and more abstraction or
more power.
A major problem is that there seems to be little interest in libraries and
a weak infrastructure. It's hard to know that libraries exist and of those
that do, hard to figure out which ones you should be looking at to use.
Everybody is reinventing the wheel.
--
Sent from: http://forum.openscad.org/
BOSL creates a lot of trivial shortcuts for common operations. So instead
of having to remember a small number of flexible primitives you now have a
much larger language of simpler operations. That may suit some people but
my brain works by remembering how to work things out rather than lots of
arbitrary facts. For example, at school I didn't memorise trig formulas but
I could remember how to work them out from first principles if I needed to.
I have never known the number of days in a month because there is no proper
rule or formula I know of.
I use my own library to make my projects but it doesn't go about redefining
and extending the OpenSCAD language. Instead it is mainly models of real
world objects like fasteners and electronic components. I am quite happy
modelling those in OpenSCADs simple low level language and don't feel need
to abstract further. Even the most complicated models are mainly
combinations of circles, squares, cubes, cylinders and spheres, translated
and rotated.
I do have translate_z(z) as a shortcut for translate([0, 0, z]) but that is
about as far as it goes.
People have very different ways and thinking, so common libraries are only
popular when they do something that an individual doesn't have the time or
ability to do correctly themselves. Most things in BOSL are not hard to do
directly in OpenSCAD.
On Sat, 9 Mar 2019 at 12:29, adrianv avm4@cornell.edu wrote:
lar3ry wrote
adrianv wrote
lar3ry wrote
I have been doing a lot of modification on existing STL files, and the
easiest way I have found is to do pretty much all trial and error. I
guess
that may be (bad)habit-forming. I am also the product of a lot of years
of
self-taught programming in everything from assembler on up.
You're importing STL files into OpenSCAD and modifying them? That
seems
like it would be difficult to do in a nice fashion.
Actually, I'm quite comfortable with the technique. I am curently in the
process of building a Hypercube Evolution printer, which is running. I
want
to make some improvements, one of which is to use a piezo disk as a
Z-stop
or bed probe. There is one available for the hotend mount, but I wanted
to
make it an under-bed mount. So I took an aready-modified bed mount and
used
union and difference to add some parts.
<example deleted>
Interesting example. Note for anyone running it that that there is a
subtle
filename mismatch.
I had never tried importing an STL file into OpenSCAD, so it was nice to
see
this. But what I meant when I said it wasn't going to be "nice" is that
trial and error is going to be unavoidable, since you won't (presumably)
know where anything is in the imported model, or have any way to orient
things to it.
But if you meant SCAD files then I think it relates to coding style. I
started a discussion here about learning how to use OpenSCAD because I
have
been struggling with these issues myself---both finding that I am doing
things by trial and error, and also finding that I can't read my own
code
a
day later. And I think it has to do with writing code that is at too
low
a
level. To avoid this, it's necessary to use libraries to abstract the
design. But people here don't seem to be supportive of this
approach.
There's an idea that you should do everything directly on your own.
Things
like obiscad's attach library or the BOSL library I think are important
for
helping us to write code that is easier to read, modify and reuse.
I know exactly what you mean. I always struggle with trying to achieve a
balance. I am definitely old-school in that I have a hard time wrapping
my
mind around object oriented languages. Instead of using objects, I tend
to
use subroutines and functions, but I do try to make re-usable ones, and
libraries are definitely a nice was to encapsulate groups of modules.
I LOVE the BOSL library, but haven't had a good look at the attach
library.
I am going to get a lot of mileage out of the Round-Anything lib.
Well, no "objects" in the sense of object oriented programming are
available
in OpenSCAD, so you can stay old school. :)
What do you mean when you say "it's hard to find balance"? To me it seems
like the higher level I can write my code at the better, so it's not about
balance, but about pushing for libraries with more and more abstraction or
more power.
A major problem is that there seems to be little interest in libraries and
a weak infrastructure. It's hard to know that libraries exist and of those
that do, hard to figure out which ones you should be looking at to use.
Everybody is reinventing the wheel.
--
Sent from: http://forum.openscad.org/
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org