J
jon
Thu, Dec 31, 2020 6:53 PM
I clearly do not understand what is going on here. This works
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
but if I add the "right(1)", below, in myProfs, this fails with a syntax
error:
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
right(1) xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
If I try wrapping the right() and the xscale() together, as
module RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then
myProfs = [for (x=[0, 1, 2])
RightAndXScale(x);
fails with a syntax error
and if I try
function RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then the function fails with a syntax error.
I clearly do not understand what is going on here. This works
---
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
---
but if I add the "right(1)", below, in myProfs, this fails with a syntax
error:
---
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
right(1) xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
---
If I try wrapping the right() and the xscale() together, as
module RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then
myProfs = [for (x=[0, 1, 2])
RightAndXScale(x);
fails with a syntax error
---
and if I try
function RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then the function fails with a syntax error.
A
adrianv
Thu, Dec 31, 2020 7:14 PM
The problem is your mixing up the module versions and function versions of
the transformation commands.
If you do right(1) without other arguments then it can be a module, in which
case you need some geometry next or it can be a function, which returns the
transformation matrix that shifts right by 1, in which case you need to do
something with it, like perhaps pass it to multmatrix. (But see below.)
In your "working" example (which actually doesn't work in the latest BOSL2)
you're doing
xscale(value, circle(...));
In this code, circle is the functional form of circle supplied by BOSL2.
It's giving you a point list which is being passed as the second arg to
xscale. To make this work robustly you should change it to
xscale(value,p=circle(...));
A new argument was added to xscale (centerpoint) so the second arg changed,
and for most of the other transformation functions the position of the point
list argument is not fixed. So if you want to add right(1) to this you can
do it like this:
right(1, p=xscale(value, p=circle(...)));
Now that's kind of messy. I recommend only using the "p=" form when you are
applying just one transformation. If you want several, it's cleaner to use
apply(). If you use a transformation without a point list it gives you the
transformation matrix, and apply applies it to a point list, like multmatrix
for point lists. So that would look like:
apply(right(1)*xscale(x/15), circle(....));
Does that help? You can now stack transformations using multiplication
similar to how you do it in plain OpenSCAD.
jon_bondy wrote
I clearly do not understand what is going on here. This works
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
but if I add the "right(1)", below, in myProfs, this fails with a syntax
error:
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
right(1) xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
If I try wrapping the right() and the xscale() together, as
module RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then
myProfs = [for (x=[0, 1, 2])
RightAndXScale(x);
fails with a syntax error
and if I try
function RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then the function fails with a syntax error.
OpenSCAD mailing list
The problem is your mixing up the module versions and function versions of
the transformation commands.
If you do right(1) without other arguments then it can be a module, in which
case you need some geometry next or it can be a function, which returns the
transformation matrix that shifts right by 1, in which case you need to do
something with it, like perhaps pass it to multmatrix. (But see below.)
In your "working" example (which actually doesn't work in the latest BOSL2)
you're doing
xscale(value, circle(...));
In this code, circle is the functional form of circle supplied by BOSL2.
It's giving you a point list which is being passed as the second arg to
xscale. To make this work robustly you should change it to
xscale(value,p=circle(...));
A new argument was added to xscale (centerpoint) so the second arg changed,
and for most of the other transformation functions the position of the point
list argument is not fixed. So if you want to add right(1) to this you can
do it like this:
right(1, p=xscale(value, p=circle(...)));
Now that's kind of messy. I recommend only using the "p=" form when you are
applying just one transformation. If you want several, it's cleaner to use
apply(). If you use a transformation without a point list it gives you the
transformation matrix, and apply applies it to a point list, like multmatrix
for point lists. So that would look like:
apply(right(1)*xscale(x/15), circle(....));
Does that help? You can now stack transformations using multiplication
similar to how you do it in plain OpenSCAD.
jon_bondy wrote
> I clearly do not understand what is going on here. This works
>
> ---
>
> include <BOSL2/std.scad>
> include <BOSL2/rounding.scad>
> include <BOSL2/skin.scad>
>
> myScale = [1, 2, 4];
> myZ = [0, 11, 22];
> myProfs = [for (x=[0, 1, 2])
> xscale(x/15, circle(d = 15, $fn = 80))];
>
> skin(myProfs, z=myZ, slices=10, method="reindex");
>
> ---
>
> but if I add the "right(1)", below, in myProfs, this fails with a syntax
> error:
>
> ---
>
> include <BOSL2/std.scad>
> include <BOSL2/rounding.scad>
> include <BOSL2/skin.scad>
>
> myScale = [1, 2, 4];
> myZ = [0, 11, 22];
> myProfs = [for (x=[0, 1, 2])
> right(1) xscale(x/15, circle(d = 15, $fn = 80))];
>
> skin(myProfs, z=myZ, slices=10, method="reindex");
>
> ---
>
> If I try wrapping the right() and the xscale() together, as
>
> module RightAndXScale(x)
> right(x) xscale(x/15, circle(d = 15, $fn = 80));
>
> then
>
> myProfs = [for (x=[0, 1, 2])
> RightAndXScale(x);
>
> fails with a syntax error
>
> ---
>
> and if I try
>
> function RightAndXScale(x)
> right(x) xscale(x/15, circle(d = 15, $fn = 80));
>
> then the function fails with a syntax error.
>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@.openscad
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/
J
jon
Thu, Dec 31, 2020 7:17 PM
Excellent explanation! Thanks so much!
Jon
On 12/31/2020 2:14 PM, adrianv wrote:
The problem is your mixing up the module versions and function versions of
the transformation commands.
If you do right(1) without other arguments then it can be a module, in which
case you need some geometry next or it can be a function, which returns the
transformation matrix that shifts right by 1, in which case you need to do
something with it, like perhaps pass it to multmatrix. (But see below.)
In your "working" example (which actually doesn't work in the latest BOSL2)
you're doing
xscale(value, circle(...));
In this code, circle is the functional form of circle supplied by BOSL2.
It's giving you a point list which is being passed as the second arg to
xscale. To make this work robustly you should change it to
xscale(value,p=circle(...));
A new argument was added to xscale (centerpoint) so the second arg changed,
and for most of the other transformation functions the position of the point
list argument is not fixed. So if you want to add right(1) to this you can
do it like this:
right(1, p=xscale(value, p=circle(...)));
Now that's kind of messy. I recommend only using the "p=" form when you are
applying just one transformation. If you want several, it's cleaner to use
apply(). If you use a transformation without a point list it gives you the
transformation matrix, and apply applies it to a point list, like multmatrix
for point lists. So that would look like:
apply(right(1)*xscale(x/15), circle(....));
Does that help? You can now stack transformations using multiplication
similar to how you do it in plain OpenSCAD.
jon_bondy wrote
I clearly do not understand what is going on here. This works
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
but if I add the "right(1)", below, in myProfs, this fails with a syntax
error:
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
right(1) xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
If I try wrapping the right() and the xscale() together, as
module RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then
myProfs = [for (x=[0, 1, 2])
RightAndXScale(x);
fails with a syntax error
and if I try
function RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then the function fails with a syntax error.
OpenSCAD mailing list
Discuss@.openscad
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Excellent explanation! Thanks so much!
Jon
On 12/31/2020 2:14 PM, adrianv wrote:
> The problem is your mixing up the module versions and function versions of
> the transformation commands.
>
> If you do right(1) without other arguments then it can be a module, in which
> case you need some geometry next or it can be a function, which returns the
> transformation matrix that shifts right by 1, in which case you need to do
> something with it, like perhaps pass it to multmatrix. (But see below.)
>
> In your "working" example (which actually doesn't work in the latest BOSL2)
> you're doing
>
> xscale(value, circle(...));
>
> In this code, circle is the functional form of circle supplied by BOSL2.
> It's giving you a point list which is being passed as the second arg to
> xscale. To make this work robustly you should change it to
>
> xscale(value,p=circle(...));
>
> A new argument was added to xscale (centerpoint) so the second arg changed,
> and for most of the other transformation functions the position of the point
> list argument is not fixed. So if you want to add right(1) to this you can
> do it like this:
>
> right(1, p=xscale(value, p=circle(...)));
>
> Now that's kind of messy. I recommend only using the "p=" form when you are
> applying just one transformation. If you want several, it's cleaner to use
> apply(). If you use a transformation without a point list it gives you the
> transformation matrix, and apply applies it to a point list, like multmatrix
> for point lists. So that would look like:
>
> apply(right(1)*xscale(x/15), circle(....));
>
> Does that help? You can now stack transformations using multiplication
> similar to how you do it in plain OpenSCAD.
>
>
> jon_bondy wrote
>> I clearly do not understand what is going on here. This works
>>
>> ---
>>
>> include <BOSL2/std.scad>
>> include <BOSL2/rounding.scad>
>> include <BOSL2/skin.scad>
>>
>> myScale = [1, 2, 4];
>> myZ = [0, 11, 22];
>> myProfs = [for (x=[0, 1, 2])
>> xscale(x/15, circle(d = 15, $fn = 80))];
>>
>> skin(myProfs, z=myZ, slices=10, method="reindex");
>>
>> ---
>>
>> but if I add the "right(1)", below, in myProfs, this fails with a syntax
>> error:
>>
>> ---
>>
>> include <BOSL2/std.scad>
>> include <BOSL2/rounding.scad>
>> include <BOSL2/skin.scad>
>>
>> myScale = [1, 2, 4];
>> myZ = [0, 11, 22];
>> myProfs = [for (x=[0, 1, 2])
>> right(1) xscale(x/15, circle(d = 15, $fn = 80))];
>>
>> skin(myProfs, z=myZ, slices=10, method="reindex");
>>
>> ---
>>
>> If I try wrapping the right() and the xscale() together, as
>>
>> module RightAndXScale(x)
>> right(x) xscale(x/15, circle(d = 15, $fn = 80));
>>
>> then
>>
>> myProfs = [for (x=[0, 1, 2])
>> RightAndXScale(x);
>>
>> fails with a syntax error
>>
>> ---
>>
>> and if I try
>>
>> function RightAndXScale(x)
>> right(x) xscale(x/15, circle(d = 15, $fn = 80));
>>
>> then the function fails with a syntax error.
>>
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@.openscad
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
J
jon
Fri, Jan 1, 2021 11:27 PM
So, if I want to do
shell2d(2, p=circle(20))
I am out of luck, because shell2d() only exists as a module and not as a
function?
And my attempt to convert this into a function
function xxx() = shell2d(2) circle(d = 20, $fn = 80);
also fails. Is there a way to convert this into a function which
returns a point list?
Jon
On 12/31/2020 2:14 PM, adrianv wrote:
The problem is your mixing up the module versions and function versions of
the transformation commands.
If you do right(1) without other arguments then it can be a module, in which
case you need some geometry next or it can be a function, which returns the
transformation matrix that shifts right by 1, in which case you need to do
something with it, like perhaps pass it to multmatrix. (But see below.)
In your "working" example (which actually doesn't work in the latest BOSL2)
you're doing
xscale(value, circle(...));
In this code, circle is the functional form of circle supplied by BOSL2.
It's giving you a point list which is being passed as the second arg to
xscale. To make this work robustly you should change it to
xscale(value,p=circle(...));
A new argument was added to xscale (centerpoint) so the second arg changed,
and for most of the other transformation functions the position of the point
list argument is not fixed. So if you want to add right(1) to this you can
do it like this:
right(1, p=xscale(value, p=circle(...)));
Now that's kind of messy. I recommend only using the "p=" form when you are
applying just one transformation. If you want several, it's cleaner to use
apply(). If you use a transformation without a point list it gives you the
transformation matrix, and apply applies it to a point list, like multmatrix
for point lists. So that would look like:
apply(right(1)*xscale(x/15), circle(....));
Does that help? You can now stack transformations using multiplication
similar to how you do it in plain OpenSCAD.
jon_bondy wrote
I clearly do not understand what is going on here. This works
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
but if I add the "right(1)", below, in myProfs, this fails with a syntax
error:
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
right(1) xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
If I try wrapping the right() and the xscale() together, as
module RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then
myProfs = [for (x=[0, 1, 2])
RightAndXScale(x);
fails with a syntax error
and if I try
function RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then the function fails with a syntax error.
OpenSCAD mailing list
Discuss@.openscad
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
So, if I want to do
shell2d(2, p=circle(20))
I am out of luck, because shell2d() only exists as a module and not as a
function?
And my attempt to convert this into a function
function xxx() = shell2d(2) circle(d = 20, $fn = 80);
also fails. Is there a way to convert this into a function which
returns a point list?
Jon
On 12/31/2020 2:14 PM, adrianv wrote:
> The problem is your mixing up the module versions and function versions of
> the transformation commands.
>
> If you do right(1) without other arguments then it can be a module, in which
> case you need some geometry next or it can be a function, which returns the
> transformation matrix that shifts right by 1, in which case you need to do
> something with it, like perhaps pass it to multmatrix. (But see below.)
>
> In your "working" example (which actually doesn't work in the latest BOSL2)
> you're doing
>
> xscale(value, circle(...));
>
> In this code, circle is the functional form of circle supplied by BOSL2.
> It's giving you a point list which is being passed as the second arg to
> xscale. To make this work robustly you should change it to
>
> xscale(value,p=circle(...));
>
> A new argument was added to xscale (centerpoint) so the second arg changed,
> and for most of the other transformation functions the position of the point
> list argument is not fixed. So if you want to add right(1) to this you can
> do it like this:
>
> right(1, p=xscale(value, p=circle(...)));
>
> Now that's kind of messy. I recommend only using the "p=" form when you are
> applying just one transformation. If you want several, it's cleaner to use
> apply(). If you use a transformation without a point list it gives you the
> transformation matrix, and apply applies it to a point list, like multmatrix
> for point lists. So that would look like:
>
> apply(right(1)*xscale(x/15), circle(....));
>
> Does that help? You can now stack transformations using multiplication
> similar to how you do it in plain OpenSCAD.
>
>
> jon_bondy wrote
>> I clearly do not understand what is going on here. This works
>>
>> ---
>>
>> include <BOSL2/std.scad>
>> include <BOSL2/rounding.scad>
>> include <BOSL2/skin.scad>
>>
>> myScale = [1, 2, 4];
>> myZ = [0, 11, 22];
>> myProfs = [for (x=[0, 1, 2])
>> xscale(x/15, circle(d = 15, $fn = 80))];
>>
>> skin(myProfs, z=myZ, slices=10, method="reindex");
>>
>> ---
>>
>> but if I add the "right(1)", below, in myProfs, this fails with a syntax
>> error:
>>
>> ---
>>
>> include <BOSL2/std.scad>
>> include <BOSL2/rounding.scad>
>> include <BOSL2/skin.scad>
>>
>> myScale = [1, 2, 4];
>> myZ = [0, 11, 22];
>> myProfs = [for (x=[0, 1, 2])
>> right(1) xscale(x/15, circle(d = 15, $fn = 80))];
>>
>> skin(myProfs, z=myZ, slices=10, method="reindex");
>>
>> ---
>>
>> If I try wrapping the right() and the xscale() together, as
>>
>> module RightAndXScale(x)
>> right(x) xscale(x/15, circle(d = 15, $fn = 80));
>>
>> then
>>
>> myProfs = [for (x=[0, 1, 2])
>> RightAndXScale(x);
>>
>> fails with a syntax error
>>
>> ---
>>
>> and if I try
>>
>> function RightAndXScale(x)
>> right(x) xscale(x/15, circle(d = 15, $fn = 80));
>>
>> then the function fails with a syntax error.
>>
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> Discuss@.openscad
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
>
>
> --
> 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
Sat, Jan 2, 2021 1:07 AM
What does shell2d actually do when you write shell2d(2) circle(20)? It runs
offset to expand the circle by 2 and then subtracts the original circle.
The resulting shell shape has two boundaries, an internal one which is
circle(20) and an external one, circle(22). If you're planning to use
skin() then you can only have one boundary. (Note that path_sweep and sweep
will work on "regions" which can have multiple boundaries, but due to the
complexity of point association, skin requires just a single boundary, so it
only works on paths.)
So the previous question that I'm guessing inspired your question, the
poster wanted a shape that wasn't enclosed, like a circle with a slot cut in
it. That sort of shape has only one boundary path so you can make it by
concating the inside and outside boundaries (one reversed). But assuming
you're interested in the two-boundary shape of a tube of some sort, then
you'll need to construct the inside and outside separately as 3d objects and
then difference them.
If you are actually using circles it's easy to construct the outer boundary
by changing the radius. If you have in mind something more complex then the
way to construct the other boundary is with the offset() function (part of
BOSL2) which will take a point list input and produce the offset point list
as output.
jon_bondy wrote
So, if I want to do
shell2d(2, p=circle(20))
I am out of luck, because shell2d() only exists as a module and not as a
function?
And my attempt to convert this into a function
function xxx() = shell2d(2) circle(d = 20, $fn = 80);
also fails. Is there a way to convert this into a function which
returns a point list?
Jon
On 12/31/2020 2:14 PM, adrianv wrote:
The problem is your mixing up the module versions and function versions
of
the transformation commands.
If you do right(1) without other arguments then it can be a module, in
which
case you need some geometry next or it can be a function, which returns
the
transformation matrix that shifts right by 1, in which case you need to
do
something with it, like perhaps pass it to multmatrix. (But see below.)
In your "working" example (which actually doesn't work in the latest
BOSL2)
you're doing
xscale(value, circle(...));
In this code, circle is the functional form of circle supplied by BOSL2.
It's giving you a point list which is being passed as the second arg to
xscale. To make this work robustly you should change it to
xscale(value,p=circle(...));
A new argument was added to xscale (centerpoint) so the second arg
changed,
and for most of the other transformation functions the position of the
point
list argument is not fixed. So if you want to add right(1) to this you
can
do it like this:
right(1, p=xscale(value, p=circle(...)));
Now that's kind of messy. I recommend only using the "p=" form when you
are
applying just one transformation. If you want several, it's cleaner to
use
apply(). If you use a transformation without a point list it gives you
the
transformation matrix, and apply applies it to a point list, like
multmatrix
for point lists. So that would look like:
apply(right(1)*xscale(x/15), circle(....));
Does that help? You can now stack transformations using multiplication
similar to how you do it in plain OpenSCAD.
jon_bondy wrote
I clearly do not understand what is going on here. This works
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
but if I add the "right(1)", below, in myProfs, this fails with a syntax
error:
include <BOSL2/std.scad>
include <BOSL2/rounding.scad>
include <BOSL2/skin.scad>
myScale = [1, 2, 4];
myZ = [0, 11, 22];
myProfs = [for (x=[0, 1, 2])
right(1) xscale(x/15, circle(d = 15, $fn = 80))];
skin(myProfs, z=myZ, slices=10, method="reindex");
If I try wrapping the right() and the xscale() together, as
module RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then
myProfs = [for (x=[0, 1, 2])
RightAndXScale(x);
fails with a syntax error
and if I try
function RightAndXScale(x)
right(x) xscale(x/15, circle(d = 15, $fn = 80));
then the function fails with a syntax error.
OpenSCAD mailing list
Discuss@.openscad
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
What does shell2d actually do when you write shell2d(2) circle(20)? It runs
offset to expand the circle by 2 and then subtracts the original circle.
The resulting shell shape has two boundaries, an internal one which is
circle(20) and an external one, circle(22). If you're planning to use
skin() then you can only have one boundary. (Note that path_sweep and sweep
will work on "regions" which can have multiple boundaries, but due to the
complexity of point association, skin requires just a single boundary, so it
only works on paths.)
So the previous question that I'm guessing inspired your question, the
poster wanted a shape that wasn't enclosed, like a circle with a slot cut in
it. That sort of shape has only one boundary path so you can make it by
concating the inside and outside boundaries (one reversed). But assuming
you're interested in the two-boundary shape of a tube of some sort, then
you'll need to construct the inside and outside separately as 3d objects and
then difference them.
If you are actually using circles it's easy to construct the outer boundary
by changing the radius. If you have in mind something more complex then the
way to construct the other boundary is with the offset() function (part of
BOSL2) which will take a point list input and produce the offset point list
as output.
jon_bondy wrote
> So, if I want to do
>
> shell2d(2, p=circle(20))
>
> I am out of luck, because shell2d() only exists as a module and not as a
> function?
>
> And my attempt to convert this into a function
>
> function xxx() = shell2d(2) circle(d = 20, $fn = 80);
>
> also fails. Is there a way to convert this into a function which
> returns a point list?
>
> Jon
>
>
> On 12/31/2020 2:14 PM, adrianv wrote:
>> The problem is your mixing up the module versions and function versions
>> of
>> the transformation commands.
>>
>> If you do right(1) without other arguments then it can be a module, in
>> which
>> case you need some geometry next or it can be a function, which returns
>> the
>> transformation matrix that shifts right by 1, in which case you need to
>> do
>> something with it, like perhaps pass it to multmatrix. (But see below.)
>>
>> In your "working" example (which actually doesn't work in the latest
>> BOSL2)
>> you're doing
>>
>> xscale(value, circle(...));
>>
>> In this code, circle is the functional form of circle supplied by BOSL2.
>> It's giving you a point list which is being passed as the second arg to
>> xscale. To make this work robustly you should change it to
>>
>> xscale(value,p=circle(...));
>>
>> A new argument was added to xscale (centerpoint) so the second arg
>> changed,
>> and for most of the other transformation functions the position of the
>> point
>> list argument is not fixed. So if you want to add right(1) to this you
>> can
>> do it like this:
>>
>> right(1, p=xscale(value, p=circle(...)));
>>
>> Now that's kind of messy. I recommend only using the "p=" form when you
>> are
>> applying just one transformation. If you want several, it's cleaner to
>> use
>> apply(). If you use a transformation without a point list it gives you
>> the
>> transformation matrix, and apply applies it to a point list, like
>> multmatrix
>> for point lists. So that would look like:
>>
>> apply(right(1)*xscale(x/15), circle(....));
>>
>> Does that help? You can now stack transformations using multiplication
>> similar to how you do it in plain OpenSCAD.
>>
>>
>> jon_bondy wrote
>>> I clearly do not understand what is going on here. This works
>>>
>>> ---
>>>
>>> include <BOSL2/std.scad>
>>> include <BOSL2/rounding.scad>
>>> include <BOSL2/skin.scad>
>>>
>>> myScale = [1, 2, 4];
>>> myZ = [0, 11, 22];
>>> myProfs = [for (x=[0, 1, 2])
>>> xscale(x/15, circle(d = 15, $fn = 80))];
>>>
>>> skin(myProfs, z=myZ, slices=10, method="reindex");
>>>
>>> ---
>>>
>>> but if I add the "right(1)", below, in myProfs, this fails with a syntax
>>> error:
>>>
>>> ---
>>>
>>> include <BOSL2/std.scad>
>>> include <BOSL2/rounding.scad>
>>> include <BOSL2/skin.scad>
>>>
>>> myScale = [1, 2, 4];
>>> myZ = [0, 11, 22];
>>> myProfs = [for (x=[0, 1, 2])
>>> right(1) xscale(x/15, circle(d = 15, $fn = 80))];
>>>
>>> skin(myProfs, z=myZ, slices=10, method="reindex");
>>>
>>> ---
>>>
>>> If I try wrapping the right() and the xscale() together, as
>>>
>>> module RightAndXScale(x)
>>> right(x) xscale(x/15, circle(d = 15, $fn = 80));
>>>
>>> then
>>>
>>> myProfs = [for (x=[0, 1, 2])
>>> RightAndXScale(x);
>>>
>>> fails with a syntax error
>>>
>>> ---
>>>
>>> and if I try
>>>
>>> function RightAndXScale(x)
>>> right(x) xscale(x/15, circle(d = 15, $fn = 80));
>>>
>>> then the function fails with a syntax error.
>>>
>>>
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> Discuss@.openscad
>>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>>
>>
>>
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>>
> Discuss@.openscad
>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@.openscad
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/
J
jon
Sat, Jan 2, 2021 2:36 PM
Still flailing around...
This works fine:
left_half(planar = true) circle(1);
This
left_half(planar = true, circle(1));
fails with
WARNING: vector*matrix requires vector length to match matrix row count
(3 != 100) in file
C:/Users/jon/Documents/OpenSCAD/libraries/BOSL2/mutators.scad, line 139
And this
module Bowl() {
myZB = [for (i=[0:14]) -5*i];
myProfsB = [for (i=[0:14])
xscale(1, p = left_half(planar = true, circle(d = wB[i], $fn =
80)))];
skin(myProfsB, z=myZB, slices=10, method="reindex");
}
fails with
WARNING: Ignoring unknown function 'left_half' in file Spoon.scad, line 134
Why is left_half() recognized as a function in the 2nd example, but not
in the 3rd?
At some point, it may be easier for me to just explain what I'm trying
to do, rather than keep beating my head against this.
Jon
Still flailing around...
This works fine:
left_half(planar = true) circle(1);
This
left_half(planar = true, circle(1));
fails with
WARNING: vector*matrix requires vector length to match matrix row count
(3 != 100) in file
C:/Users/jon/Documents/OpenSCAD/libraries/BOSL2/mutators.scad, line 139
And this
module Bowl() {
myZB = [for (i=[0:14]) -5*i];
myProfsB = [for (i=[0:14])
xscale(1, p = left_half(planar = true, circle(d = wB[i], $fn =
80)))];
skin(myProfsB, z=myZB, slices=10, method="reindex");
}
fails with
WARNING: Ignoring unknown function 'left_half' in file Spoon.scad, line 134
Why is left_half() recognized as a function in the 2nd example, but not
in the 3rd?
At some point, it may be easier for me to just explain what I'm trying
to do, rather than keep beating my head against this.
Jon
NH
nop head
Sat, Jan 2, 2021 3:22 PM
left_half() must be a module in your first two examples. You can only call
a function in an expression, modules are statements.
On Sat, 2 Jan 2021 at 14:37, jon jon@jonbondy.com wrote:
Still flailing around...
This works fine:
left_half(planar = true) circle(1);
This
left_half(planar = true, circle(1));
fails with
WARNING: vector*matrix requires vector length to match matrix row count (3
!= 100) in file
C:/Users/jon/Documents/OpenSCAD/libraries/BOSL2/mutators.scad, line 139
And this
module Bowl() {
myZB = [for (i=[0:14]) -5*i];
myProfsB = [for (i=[0:14])
xscale(1, p = left_half(planar = true, circle(d = wB[i], $fn =
80)))];
skin(myProfsB, z=myZB, slices=10, method="reindex");
}
fails with
WARNING: Ignoring unknown function 'left_half' in file Spoon.scad, line 134
Why is left_half() recognized as a function in the 2nd example, but not in
the 3rd?
At some point, it may be easier for me to just explain what I'm trying to
do, rather than keep beating my head against this.
Jon
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
left_half() must be a module in your first two examples. You can only call
a function in an expression, modules are statements.
On Sat, 2 Jan 2021 at 14:37, jon <jon@jonbondy.com> wrote:
> Still flailing around...
>
> This works fine:
>
> left_half(planar = true) circle(1);
>
> This
>
> left_half(planar = true, circle(1));
>
> fails with
>
> WARNING: vector*matrix requires vector length to match matrix row count (3
> != 100) in file
> C:/Users/jon/Documents/OpenSCAD/libraries/BOSL2/mutators.scad, line 139
>
> And this
>
> module Bowl() {
> myZB = [for (i=[0:14]) -5*i];
> myProfsB = [for (i=[0:14])
> xscale(1, p = left_half(planar = true, circle(d = wB[i], $fn =
> 80)))];
> skin(myProfsB, z=myZB, slices=10, method="reindex");
> }
>
> fails with
>
> WARNING: Ignoring unknown function 'left_half' in file Spoon.scad, line 134
>
> Why is left_half() recognized as a function in the 2nd example, but not in
> the 3rd?
>
> At some point, it may be easier for me to just explain what I'm trying to
> do, rather than keep beating my head against this.
>
> Jon
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@lists.openscad.org
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
A
adrianv
Sat, Jan 2, 2021 4:02 PM
I have this feeling that you're experimenting with different variations but
that you don't understand what's really going on. Revar is trying to write
tutorials now for BOSL2, and it would be good if we could understand why you
don't understand and what to say to help you (and others) understand better.
The tutorials are here: https://github.com/revarbat/BOSL2/wiki/Tutorials
and maybe the Paths and Regions tutorial would help?
OpenSCAD has modules that create geometry and other modules that operate on
geometry. In core OpenSCAD if you invoke circle() it creates 2d geometry.
If you give it to linear_extrude as a child then you get a cylinder.
It is impossible to get the points out of geometry, so doing more
interesting manipulations requires that we work in a different way. To this
end, BOSL2 provides function versions of the core geometry modules. They
look the same, but what happens depends on context. So with BOSL2 loaded,
circle() will sometimes make geometry (in a module context) and sometimes
produce a "path" (in a function context). A path is BOSL2 term for an
ordered list of points. Operating on paths requires that you use functions,
not modules. So this is the difference between
newpath=xscale(factor,p=some_path); and xscale(factor) some_geomety(); The
former version is passing a path (point list) to a function and getting a
new path out. The latter is generating geometry in a module and passing it
as a child to xscale, resulting finally in geometry as the result. If you
run the first one you won't see anything because no geometry has yet been
created. You need to convert the output, newpath, into geometry, perhaps
with polygon(newpath);
So let's take a look at what you're doing below:
left_half(planar=true) circle(1);
You've used the core circle module to create geometry and you're giving it
as a child to the left_half module which shows just the left part.
left_half(planar=true, circle(1));
You're invoking the module left_half. We know it's a module because you
didn't assign a return value to something. The circle(1) invocation is the
function version of circle, so it produces a path. So you're invoking the
module with planar=true and a list of points. But if you check the manual,
you'll see that the module version does not accept a path, only two scalars.
So you've given invalid input. The error message need to be improved.
If you change it to
lcirc=left_half(....);
then you will get the functional form. However, the functional form of the
"half" operators was added recently and appears to be seriously buggy. So
for now....don't try to use it. It looks like your version of BOSL2
predates the existence of the functional form of left_half because in your
example below you show an error, "unknown function left_half".
I think maybe your code would do what you want if you use arc() instead of
circle(), since arc() can create a half circle directly.
Here's your code with arc inserted. You didn't define wB so I'm not sure
what you're after. You might want to explain what you're trying to do as
there might possibly be a completely different approach.
module Bowl() {
myZB = [for (i=[0:14]) -5*i];
myProfsB = [for (i=[0:14])
xscale(1, p=arc(angle=[180,360],d = wB[i], $fn = 80))];
skin(myProfsB, z=myZB, slices=10, method="reindex");
}
jon_bondy wrote
Still flailing around...
This works fine:
left_half(planar = true) circle(1);
This
left_half(planar = true, circle(1));
fails with
WARNING: vector*matrix requires vector length to match matrix row count
(3 != 100) in file
C:/Users/jon/Documents/OpenSCAD/libraries/BOSL2/mutators.scad, line 139
And this
module Bowl() {
myZB = [for (i=[0:14]) -5*i];
myProfsB = [for (i=[0:14])
xscale(1, p = left_half(planar = true, circle(d = wB[i], $fn =
80)))];
skin(myProfsB, z=myZB, slices=10, method="reindex");
}
fails with
WARNING: Ignoring unknown function 'left_half' in file Spoon.scad, line
134
Why is left_half() recognized as a function in the 2nd example, but not
in the 3rd?
At some point, it may be easier for me to just explain what I'm trying
to do, rather than keep beating my head against this.
Jon
OpenSCAD mailing list
I have this feeling that you're experimenting with different variations but
that you don't understand what's really going on. Revar is trying to write
tutorials now for BOSL2, and it would be good if we could understand why you
don't understand and what to say to help you (and others) understand better.
The tutorials are here: https://github.com/revarbat/BOSL2/wiki/Tutorials
and maybe the Paths and Regions tutorial would help?
OpenSCAD has modules that create geometry and other modules that operate on
geometry. In core OpenSCAD if you invoke circle() it creates 2d geometry.
If you give it to linear_extrude as a child then you get a cylinder.
It is impossible to get the points out of geometry, so doing more
interesting manipulations requires that we work in a different way. To this
end, BOSL2 provides function versions of the core geometry modules. They
look the same, but what happens depends on context. So with BOSL2 loaded,
circle() will sometimes make geometry (in a module context) and sometimes
produce a "path" (in a function context). A path is BOSL2 term for an
ordered list of points. Operating on paths requires that you use functions,
not modules. So this is the difference between
newpath=xscale(factor,p=some_path); and xscale(factor) some_geomety(); The
former version is passing a path (point list) to a function and getting a
new path out. The latter is generating geometry in a module and passing it
as a child to xscale, resulting finally in geometry as the result. If you
run the first one you won't see anything because no geometry has yet been
created. You need to convert the output, newpath, into geometry, perhaps
with polygon(newpath);
So let's take a look at what you're doing below:
left_half(planar=true) circle(1);
You've used the core circle module to create geometry and you're giving it
as a child to the left_half module which shows just the left part.
left_half(planar=true, circle(1));
You're invoking the module left_half. We know it's a module because you
didn't assign a return value to something. The circle(1) invocation is the
function version of circle, so it produces a path. So you're invoking the
module with planar=true and a list of points. But if you check the manual,
you'll see that the module version does not accept a path, only two scalars.
So you've given invalid input. The error message need to be improved.
If you change it to
lcirc=left_half(....);
then you will get the functional form. However, the functional form of the
"half" operators was added recently and appears to be seriously buggy. So
for now....don't try to use it. It looks like your version of BOSL2
predates the existence of the functional form of left_half because in your
example below you show an error, "unknown function left_half".
I think maybe your code would do what you want if you use arc() instead of
circle(), since arc() can create a half circle directly.
Here's your code with arc inserted. You didn't define wB so I'm not sure
what you're after. You might want to explain what you're trying to do as
there might possibly be a completely different approach.
module Bowl() {
myZB = [for (i=[0:14]) -5*i];
myProfsB = [for (i=[0:14])
xscale(1, p=arc(angle=[180,360],d = wB[i], $fn = 80))];
skin(myProfsB, z=myZB, slices=10, method="reindex");
}
jon_bondy wrote
> Still flailing around...
>
> This works fine:
>
> left_half(planar = true) circle(1);
>
> This
>
> left_half(planar = true, circle(1));
>
> fails with
>
> WARNING: vector*matrix requires vector length to match matrix row count
> (3 != 100) in file
> C:/Users/jon/Documents/OpenSCAD/libraries/BOSL2/mutators.scad, line 139
>
> And this
>
> module Bowl() {
> myZB = [for (i=[0:14]) -5*i];
> myProfsB = [for (i=[0:14])
> xscale(1, p = left_half(planar = true, circle(d = wB[i], $fn =
> 80)))];
> skin(myProfsB, z=myZB, slices=10, method="reindex");
> }
>
> fails with
>
> WARNING: Ignoring unknown function 'left_half' in file Spoon.scad, line
> 134
>
> Why is left_half() recognized as a function in the 2nd example, but not
> in the 3rd?
>
> At some point, it may be easier for me to just explain what I'm trying
> to do, rather than keep beating my head against this.
>
> Jon
>
>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@.openscad
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/
J
jon
Sat, Jan 2, 2021 4:03 PM
The documentation says that left_half() can be used as a function and
provides examples...
On 1/2/2021 10:22 AM, nop head wrote:
left_half() must be a module in your first two examples. You can only
call a function in an expression, modules are statements.
The documentation says that left_half() can be used as a function and
provides examples...
On 1/2/2021 10:22 AM, nop head wrote:
> left_half() must be a module in your first two examples. You can only
> call a function in an expression, modules are statements.
>
A
adrianv
Sat, Jan 2, 2021 4:44 PM
Yes, but you didn't use it as a function. You used it as a module. There
are in fact no examples in the manual of using it as a function. Here's an
example:
include <BOSL2/std.scad>
include <BOSL2/polyhedra.scad>
dodecahedron = regular_polyhedron_info("vnf","dodecahedron",side=10); //
Get something to use as input
half_dodec = left_half(dodecahedron);
vnf_wireframe(half_dodec,$fn=32,r=0.2);
Note that based on your previous post, your BOSL2 is probably older than the
introduction of the functional form of left_half. Also note that the above
code actually gives the right half. Like I said: the function version is
buggy.
jon_bondy wrote
The documentation says that left_half() can be used as a function and
provides examples...
On 1/2/2021 10:22 AM, nop head wrote:
left_half() must be a module in your first two examples. You can only
call a function in an expression, modules are statements.
Yes, but you didn't use it as a function. You used it as a module. There
are in fact no examples in the manual of using it as a function. Here's an
example:
include <BOSL2/std.scad>
include <BOSL2/polyhedra.scad>
dodecahedron = regular_polyhedron_info("vnf","dodecahedron",side=10); //
Get something to use as input
half_dodec = left_half(dodecahedron);
vnf_wireframe(half_dodec,$fn=32,r=0.2);
Note that based on your previous post, your BOSL2 is probably older than the
introduction of the functional form of left_half. Also note that the above
code actually gives the right half. Like I said: the function version is
buggy.
jon_bondy wrote
> The documentation says that left_half() can be used as a function and
> provides examples...
>
> On 1/2/2021 10:22 AM, nop head wrote:
>> left_half() must be a module in your first two examples. You can only
>> call a function in an expression, modules are statements.
>>
>
> _______________________________________________
> OpenSCAD mailing list
> Discuss@.openscad
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
Sent from: http://forum.openscad.org/