discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Learning how to use OpenSCAD

T
tjhowse
Tue, Feb 26, 2019 3:59 AM

I made this tutorial video a few years ago. People seem to like it:
https://www.youtube.com/watch?v=_2r9bWsVwdM

On Tue, 26 Feb 2019 at 01:26, adrianv avm4@cornell.edu wrote:

RevarBat wrote

On Feb 23, 2019, at 8:43 AM, adrianv <

avm4@

> wrote:

The BOSL library looks very good, and it's great that it's documented.
I
started trying to use it and so far have the following observations.

I have been finding it useful to define a cube by its corner

coordinates.

It doesn't supply this, as far as I could see.

Good idea.  I've added cube2pt(p1,p2) to implement this.

I realized that I actually mis-wrote what I did.  I defined the cube by
ranges of x, y, and z.    My function is boundcube(xrange, yrange,
zrange).
Does this difference matter?  I think it does.  I went on to define an
"infinity" called inf, and "all" as [-inf,inf] so I could define
half-spaces
like boundcube([0,inf],all,all).  This is less natural with the two points
method.  Maybe both approaches should be provided?  I think my thinking
process also tended to be about the x, y and z ranges, and not about the
corner points---like I need to fill in this space from this x position to
that one.

Is this a reasonable way to design shapes?  Is there a downside to creating
large coordinates, like setting inf=10^4 or 10^5?  When I did my sliding
dovetails I made them by using halfspaces defined like this, rotating them,
and then doing intersections and unions.  Is there a better way?

There are a whole bunch of cube functions that make cubes in different
places, and then separate functions that make rounded cubes.  It seems
like
it might be better to have this be unified, so you can create rounded
cubes
in any desired manner.  In other words, rounding would be an option, or
cube
positioning would be an option.  Or there might be a master cube module
that
can make any kind of cube and more restricted functions that are simpler
that make specific ones.

Yeah, the set of cube modules were evolved over time and it shows.  I'll
take look at
this and decide what to do.  Maybe take offsetcube(), rename it something
more
generic like cuboid() and give it align, fillet and chamfer
arguments.

Sounds like that could be a reasonable approach.  Will fillet and chamfer
have interior and exterior options?

I wanted to specify the inner diameter of a tube.  This seems like it
would
be very common--maybe even the most common way to make a tube.  Having

to

specify ID+wall and then wall again is clumsy.

I've updated tube() to be able to take inner and outer diams and radii,

or

wall with
either inner or outer diams/radii.  The following calls should all create
the same tube shape.

  • tube(h=10, r=50, ir=45);
  • tube(h=10, d=100, id=90);
  • tube(h=10, r=50, wall=5);
  • tube(h=10, d=100, wall=5);
  • tube(h=10, ir=45, wall=5);
  • tube(h=10, id=90, wall=5);

Looks good to me.  I know there's already a ton of parameters, but is it
worth adding od as an option for outer diameter for consistency?

The last concern has to do with the use of the term "fillet" and the
functionality I meant when I used the term.  I may not understand

general

usage here.  I understood the term "fillet" to refer to specifically
rounding of *concave" corners.  Wikipedia presents this as the primary
definition:  https://en.wikipedia.org/wiki/Fillet_(mechanics)
<https://en.wikipedia.org/wiki/Fillet_(mechanics)>

Err, Wikipedia defines a fillet as

 "In mechanical engineering, a fillet is a rounding of an _interior or

exterior_ corner of a part design."

However, dictionary.com <http://dictionary.com/> indicates a

fillet

is a rounding of an interior corner.

Yeah,  Wikipedia does define it as including exterior.  But then they give
only examples of interior rounding.  Also the word "fillet" refers to "a
strip of material", so an added strip in a transition, not to removal.

AutoCAD uses fillet for both interior and exterior corners.

I figure if it's good enough for AutoCAD and Wikipedia, it's a generally
understood name for interior and exterior angle rounding.

Well, maybe, but maybe not.  I noticed in watching autocad tutorials a
couple things.  One is that there is one button.  So they wanted one
term...
Well, except they didn't.  the button is labeled "rounds and fillets
edges".
This suggests that rounds and fillets are not the same.

A second observation is that almost all the tutorials are in 2d operating
on
lines, where in fact there is no difference.

A third observation is that if you are operating on a 3d shape by selecting
edges, as one does in autocad, the program knows if it's concave or convex,
so it would be silly to have two functions for this.

So the autocad designers may have chosen to generalize "fillet" beyond its
normal meaning.  Since autocad is important, this broadened the term.  But
does OpenSCAD work the same way as autocad?

Nope.  We have to explicitly distinguish between exterior and interior
operations.  So the question is how will that be done.  I'm not insisting
that fillet is the wrong term here, but just make sure that people are
generally happy with the choice of terms.  It may also depend on how you do
things.

What is implemented in BOSL as "fillet" is what I would call a

roundover.

Now I poked around and found that some other programs (e.g. Autocad) use
the
term "fillet" to mean roundover.  So some sort of decision on
nomenclature
is necessary.  But also, the BOSL library appears to lack the ability to
do
the type of fillet I was referring to, at least in general.  There are
some
special cases such as the thinning brace and thinning wall.

I actually hadn't noticed this until you mentioned it.  I've added
interior_fillet() to shapes.scad to provide this capability, for
arbitrary interior angles.

This is a start.  I have a few thoughts.  One is that interior filletting
should be possible on cubes and cylinders just the way you have
filleted_cylinder().  In fact, I might want to make a cylinder that is
interior filleted on one end and exterior filleted on the other, so the
object includes both fillets.  This way if I want to make a stopped hole I
can simply create the cylinder and subtract it from a cube and I have all
of
my rounding handled effortlessly.  (This is possible now but I think you
need to use 3 objects to do it.)

Another thing is that there needs to be a way to make the corner interior
fillets for a cube.  In the

https://github.com/StephS/i2_xends/blob/master/inc/fillets.scad

library you can make the corners.  Actually for roundover masks perhaps you
need a way to mask off corners.  And stepping back, I am still not really
sure how to apply these kind of building blocks in complex situations.  I
made a shape over the weekend that had a rectangular base that tapered
wider
as it went up.  I needed the bottom corner to be rounded over.  That seemed
very difficult to do because it was an obtuse angle and I didn't know what
the angle was---and the fillet mask doesn't have an angle option.  I did a
chamfer instead.  This required trial and error shifting the chamfer mask
around so that I didn't have a little corner.  None of this is
satisfying.
If I make a shape using prismoid and want to round the bottom I don't want
to have to do a bunch of trig to figure out the angles.

The second observation is that if you're going to say interior_fillet then
you need to say exterior_fillet for the other case for consistency.  The
chamfer operation actually has this problem as well, in that you need
interior and exterior chamfers if you want to supply them on cubes or
cylinders.  I kind of like the term "flare" to refer to adding interior
angle chamfers or interior fillets to the edges of cubes.  In other words,
you specify a flared cylinder end and then somehow indicate whether you
want
it rounded or chamfered.
One possible way to do this might be to make a data structure that
describes
edge treatments and have functions that create the data structure with
different characteristics and defaults.

So what is the right language for OpenSCAD (not autocad) to use to capture
all of this stuff.  And what are the right functions and operations to make
it easy to do?

The others who have written on this thread about libraries, do you have any
thoughts about the BOSL library?  It appears much better than MCAD to me in
general.  What does MCAD have that is missing from BOSL?  Does it make
sense to give BOSL a section in the OpenSCAD manual?  Does anybody else
have any thoughts on how to improve BOSL and make it something you'd be
happy to use?

I mentioned in an earlier post that generalized polygon roundover seems
like
a nice feature.  And it turns out it does exist, already done, just like
BOSL was out there kind of in hiding.
https://github.com/Irev-Dev/Round-Anything
There was a thread about a year ago about this.  This library also supplies
a minkowski rounding function that could be useful in cases where it's not
too slow to use.  Hmmm.  Assuming there are any such cases.  (The author
speaks of waiting 10 hours for the result.)  I just ran it on a simple
test
case and am still waiting, which doesn't inspire a whole lot of excitement,
though I suppose if I could get my model to a finished state and then run
this for an hour to apply the rounding it might still be useful.    It took
25 seconds to round over a cube with $fn=8.  I took a look at the code and
it calls minkowski three times.  There's also a round2d based on offset()
which rounds any 2d object and runs in reasonable time, so that could be
useful.

My simple test case finally finished.  It took 30 minutes and this is the
result:
http://forum.openscad.org/file/t2477/round.png

Another question I had is what is the standard way to use a library like
this.  I have put it in a lib directory (as a subdirectory of where my work
is) so I'm doing stuff like

use <lib/bosl/shapes.scad>

Is that the right thing to do?  Ideally I should be able to share my code
with other people and they should be able to run it without having to
tinker
with the use statements.

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


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

I made this tutorial video a few years ago. People seem to like it: https://www.youtube.com/watch?v=_2r9bWsVwdM On Tue, 26 Feb 2019 at 01:26, adrianv <avm4@cornell.edu> wrote: > RevarBat wrote > >> On Feb 23, 2019, at 8:43 AM, adrianv &lt; > > > avm4@ > > > &gt; wrote: > >> > >> The BOSL library looks very good, and it's great that it's documented. > >> I > >> started trying to use it and so far have the following observations. > >> > >> I have been finding it useful to define a cube by its corner > coordinates. > >> It doesn't supply this, as far as I could see. > > > > Good idea. I've added `cube2pt(p1,p2)` to implement this. > > I realized that I actually mis-wrote what I did. I defined the cube by > ranges of x, y, and z. My function is boundcube(xrange, yrange, > zrange). > Does this difference matter? I think it does. I went on to define an > "infinity" called inf, and "all" as [-inf,inf] so I could define > half-spaces > like boundcube([0,inf],all,all). This is less natural with the two points > method. Maybe both approaches should be provided? I think my thinking > process also tended to be about the x, y and z ranges, and not about the > corner points---like I need to fill in this space from this x position to > that one. > > Is this a reasonable way to design shapes? Is there a downside to creating > large coordinates, like setting inf=10^4 or 10^5? When I did my sliding > dovetails I made them by using halfspaces defined like this, rotating them, > and then doing intersections and unions. Is there a better way? > > > > >> There are a whole bunch of cube functions that make cubes in different > >> places, and then separate functions that make rounded cubes. It seems > >> like > >> it might be better to have this be unified, so you can create rounded > >> cubes > >> in any desired manner. In other words, rounding would be an option, or > >> cube > >> positioning would be an option. Or there might be a master cube module > >> that > >> can make any kind of cube and more restricted functions that are simpler > >> that make specific ones. > > > > Yeah, the set of cube modules were evolved over time and it shows. I'll > > take look at > > this and decide what to do. Maybe take offsetcube(), rename it something > > more > > generic like `cuboid()` and give it `align`, `fillet` and `chamfer` > > arguments. > > Sounds like that could be a reasonable approach. Will fillet and chamfer > have interior and exterior options? > > > >> I wanted to specify the inner diameter of a tube. This seems like it > >> would > >> be very common--maybe even the most common way to make a tube. Having > to > >> specify ID+wall and then wall again is clumsy. > > > > I've updated tube() to be able to take inner and outer diams and radii, > or > > `wall` with > > either inner or outer diams/radii. The following calls should all create > > the same tube shape. > > > > - tube(h=10, r=50, ir=45); > > - tube(h=10, d=100, id=90); > > - tube(h=10, r=50, wall=5); > > - tube(h=10, d=100, wall=5); > > - tube(h=10, ir=45, wall=5); > > - tube(h=10, id=90, wall=5); > > Looks good to me. I know there's already a ton of parameters, but is it > worth adding od as an option for outer diameter for consistency? > > > >> The last concern has to do with the use of the term "fillet" and the > >> functionality I meant when I used the term. I may not understand > general > >> usage here. I understood the term "fillet" to refer to specifically > >> rounding of *concave" corners. Wikipedia presents this as the primary > >> definition: https://en.wikipedia.org/wiki/Fillet_(mechanics) > >> &lt;https://en.wikipedia.org/wiki/Fillet_(mechanics)&gt; > > > > Err, Wikipedia defines a fillet as > > > > "In mechanical engineering, a fillet is a rounding of an _interior or > > exterior_ corner of a part design." > > > > However, dictionary.com &lt;http://dictionary.com/&gt; indicates a > fillet > > is a rounding of an interior corner. > > Yeah, Wikipedia does define it as including exterior. But then they give > only examples of interior rounding. Also the word "fillet" refers to "a > strip of material", so an added strip in a transition, not to removal. > > > > AutoCAD uses fillet for both interior and exterior corners. > > > > I figure if it's good enough for AutoCAD and Wikipedia, it's a generally > > understood name for interior and exterior angle rounding. > > Well, maybe, but maybe not. I noticed in watching autocad tutorials a > couple things. One is that there is one button. So they wanted one > term... > Well, except they didn't. the button is labeled "rounds and fillets > edges". > This suggests that rounds and fillets are not the same. > > A second observation is that almost all the tutorials are in 2d operating > on > lines, where in fact there is no difference. > > A third observation is that if you are operating on a 3d shape by selecting > edges, as one does in autocad, the program knows if it's concave or convex, > so it would be silly to have two functions for this. > > So the autocad designers may have chosen to generalize "fillet" beyond its > normal meaning. Since autocad is important, this broadened the term. But > does OpenSCAD work the same way as autocad? > > Nope. We have to explicitly distinguish between exterior and interior > operations. So the question is how will that be done. I'm not insisting > that fillet is the wrong term here, but just make sure that people are > generally happy with the choice of terms. It may also depend on how you do > things. > > > >> What is implemented in BOSL as "fillet" is what I would call a > roundover. > >> Now I poked around and found that some other programs (e.g. Autocad) use > >> the > >> term "fillet" to mean roundover. So some sort of decision on > >> nomenclature > >> is necessary. But also, the BOSL library appears to lack the ability to > >> do > >> the type of fillet I was referring to, at least in general. There are > >> some > >> special cases such as the thinning brace and thinning wall. > > > > I actually hadn't noticed this until you mentioned it. I've added > > `interior_fillet()` to `shapes.scad` to provide this capability, for > > arbitrary interior angles. > > This is a start. I have a few thoughts. One is that interior filletting > should be possible on cubes and cylinders just the way you have > filleted_cylinder(). In fact, I might want to make a cylinder that is > interior filleted on one end and exterior filleted on the other, so the > object includes both fillets. This way if I want to make a stopped hole I > can simply create the cylinder and subtract it from a cube and I have all > of > my rounding handled effortlessly. (This is possible now but I think you > need to use 3 objects to do it.) > > Another thing is that there needs to be a way to make the corner interior > fillets for a cube. In the > > https://github.com/StephS/i2_xends/blob/master/inc/fillets.scad > > library you can make the corners. Actually for roundover masks perhaps you > need a way to mask off corners. And stepping back, I am still not really > sure how to apply these kind of building blocks in complex situations. I > made a shape over the weekend that had a rectangular base that tapered > wider > as it went up. I needed the bottom corner to be rounded over. That seemed > very difficult to do because it was an obtuse angle and I didn't know what > the angle was---and the fillet mask doesn't have an angle option. I did a > chamfer instead. This required trial and error shifting the chamfer mask > around so that I didn't have a little corner. None of this is > satisfying. > If I make a shape using prismoid and want to round the bottom I don't want > to have to do a bunch of trig to figure out the angles. > > The second observation is that if you're going to say interior_fillet then > you need to say exterior_fillet for the other case for consistency. The > chamfer operation actually has this problem as well, in that you need > interior and exterior chamfers if you want to supply them on cubes or > cylinders. I kind of like the term "flare" to refer to adding interior > angle chamfers or interior fillets to the edges of cubes. In other words, > you specify a flared cylinder end and then somehow indicate whether you > want > it rounded or chamfered. > One possible way to do this might be to make a data structure that > describes > edge treatments and have functions that create the data structure with > different characteristics and defaults. > > So what is the right language for OpenSCAD (not autocad) to use to capture > all of this stuff. And what are the right functions and operations to make > it easy to do? > > The others who have written on this thread about libraries, do you have any > thoughts about the BOSL library? It appears much better than MCAD to me in > general. What does MCAD have that is missing from BOSL? Does it make > sense to give BOSL a section in the OpenSCAD manual? Does anybody else > have any thoughts on how to improve BOSL and make it something you'd be > happy to use? > > I mentioned in an earlier post that generalized polygon roundover seems > like > a nice feature. And it turns out it does exist, already done, just like > BOSL was out there kind of in hiding. > https://github.com/Irev-Dev/Round-Anything > There was a thread about a year ago about this. This library also supplies > a minkowski rounding function that could be useful in cases where it's not > too slow to use. Hmmm. Assuming there are any such cases. (The author > speaks of waiting 10 hours for the result.) I just ran it on a simple > test > case and am still waiting, which doesn't inspire a whole lot of excitement, > though I suppose if I could get my model to a finished state and then run > this for an hour to apply the rounding it might still be useful. It took > 25 seconds to round over a cube with $fn=8. I took a look at the code and > it calls minkowski three times. There's also a round2d based on offset() > which rounds any 2d object and runs in reasonable time, so that could be > useful. > > My simple test case finally finished. It took 30 minutes and this is the > result: > <http://forum.openscad.org/file/t2477/round.png> > > Another question I had is what is the standard way to use a library like > this. I have put it in a lib directory (as a subdirectory of where my work > is) so I'm doing stuff like > > use <lib/bosl/shapes.scad> > > Is that the right thing to do? Ideally I should be able to share my code > with other people and they should be able to run it without having to > tinker > with the use statements. > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
A
adrianv
Tue, Feb 26, 2019 2:28 PM

tjhowse wrote

I made this tutorial video a few years ago. People seem to like it:
https://www.youtube.com/watch?v=_2r9bWsVwdM

I'll admit that I didn't look at any of the tutorial videos I saw listed.  I
personally dislike the idea of video in general, and learning to write code
from a video seems insane.  That said, I did take a look at your video and
it seems like it's could be helpful to people who like that kind of thing.
You probably should have shown a method of designing the shape without
minkowski(), though---e.g. making the square and circle bigger by the width
using offset() to get the outside shape.  But there's nothing in your
tutorial that I didn't learn from reading the manual.  And yet there's much
to be learned that is not in the manual.  And that's what I'm talking about
here.

My problem is not that I am trying to learn the basics.  I'm trying to
understand how to become an OpenSCAD expert. Are there multiple ways to
model something?  Is one better?  More elegant?  More efficient?  Or maybe
more importantly, how can I write code that I can still understand an hour
later?  How can I avoid struggling with getting elements in the model
oriented the right way and positioned correctly.    And also I'm trying to
understand how one avoids reinventing the wheel.  The more I dig around the
more it becomes apparent that standard practice in OpenSCAD is that
everybody does in fact just reinvent the wheel.

I'm going to start a new topic to try to better focus this discussion.

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

tjhowse wrote > I made this tutorial video a few years ago. People seem to like it: > https://www.youtube.com/watch?v=_2r9bWsVwdM I'll admit that I didn't look at any of the tutorial videos I saw listed. I personally dislike the idea of video in general, and learning to write code from a video seems insane. That said, I did take a look at your video and it seems like it's could be helpful to people who like that kind of thing. You probably should have shown a method of designing the shape without minkowski(), though---e.g. making the square and circle bigger by the width using offset() to get the outside shape. But there's nothing in your tutorial that I didn't learn from reading the manual. And yet there's much to be learned that is not in the manual. And that's what I'm talking about here. My problem is not that I am trying to learn the basics. I'm trying to understand how to become an OpenSCAD *expert*. Are there multiple ways to model something? Is one better? More elegant? More efficient? Or maybe more importantly, how can I write code that I can still understand an hour later? How can I avoid struggling with getting elements in the model oriented the right way and positioned correctly. And also I'm trying to understand how one avoids reinventing the wheel. The more I dig around the more it becomes apparent that standard practice in OpenSCAD is that everybody does in fact just reinvent the wheel. I'm going to start a new topic to try to better focus this discussion. -- Sent from: http://forum.openscad.org/