# simple BOSL question Classic List Threaded 24 messages 12
Open this post in threaded view
|

## simple BOSL question

 I clearly do not understand what is going on here.  This works --- include include include 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 include include 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 [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: simple BOSL question

 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 [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: simple BOSL question

Open this post in threaded view
|

## Re: simple BOSL question

Open this post in threaded view
|

## Re: simple BOSL question

Open this post in threaded view
|

## Re: simple BOSL question

 Still flailing around... This works fine: left_half(planar = true) circle(1); This left_half(planar = true, circle(1)); fails with 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 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 [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: simple BOSL question

 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 <[hidden email]> wrote: Still flailing around... This works fine: left_half(planar = true) circle(1); This left_half(planar = true, circle(1)); fails with 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 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 [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: simple BOSL question

Open this post in threaded view
|

## Re: simple BOSL question

 In reply to this post by nophead 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 [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: simple BOSL question

 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 include 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/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: simple BOSL question

Open this post in threaded view
|

## Re: simple BOSL question

Open this post in threaded view
|

## Re: simple BOSL question

If I go here

I see this

### left_half()

Type: Function/Module

Usage: as module

• left_half(<s>, <x>) ...
• left_half(planar=true, <s>, <x>) ...

Usage: as function

• left_half(<s>, <x>, path)
• left_half(<s>, <x>, region)
• left_half(<s>, <x>, vnf)

No wonder I thought that you could use it as a function without assigning it to anything.

Jon

On 1/2/2021 11:44 AM, adrianv wrote:
```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:

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.

```

_______________________________________________
[hidden email]
Open this post in threaded view
|

## Re: simple BOSL question

Library documentation assumes that you know the OpenSCAD language.

On Sat, 2 Jan 2021 at 17:33, jon <[hidden email]> wrote:

If I go here

I see this

### left_half()

Type: Function/Module

Usage: as module

• left_half(<s>, <x>) ...
• left_half(planar=true, <s>, <x>) ...

Usage: as function

• left_half(<s>, <x>, path)
• left_half(<s>, <x>, region)
• left_half(<s>, <x>, vnf)

No wonder I thought that you could use it as a function without assigning it to anything.

Jon

On 1/2/2021 11:44 AM, adrianv wrote:
```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:

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.

```

_______________________________________________
[hidden email]

_______________________________________________
[hidden email]
Open this post in threaded view
|

## Re: simple BOSL question

Understood, nop head, but the usage as a function could have been more like "x = left_half(<x>, <x>, path)".  More clarity at a modest cost.

:)

On 1/2/2021 12:37 PM, nop head wrote:
Library documentation assumes that you know the OpenSCAD language.

On Sat, 2 Jan 2021 at 17:33, jon <[hidden email]> wrote:

If I go here

I see this

### left_half()

Type: Function/Module

Usage: as module

• left_half(<s>, <x>) ...
• left_half(planar=true, <s>, <x>) ...

Usage: as function

• left_half(<s>, <x>, path)
• left_half(<s>, <x>, region)
• left_half(<s>, <x>, vnf)

No wonder I thought that you could use it as a function without assigning it to anything.

Jon

_______________________________________________
[hidden email]
Open this post in threaded view
|

## Re: simple BOSL question

Open this post in threaded view
|

## Re: simple BOSL question

 In the code you provided, below, you use all functions except at the very end: \$fn=64; bottom = arc(angle=[210,330], d=20); top = offset(bottom, r=1); shape = concat(top,reverse(bottom)); polygon(shape); the result is that this fails because polygon() is not a function myProfsB = [for (i=[0:14])         xscale(1, polygon(concat(offset(bottom, r=1), reverse(arc(angle=[210,330], d=wB[i])))))]; Any hints? _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: simple BOSL question

 If you want to see something in OpenSCAD you have to eventually run a module that creates geometry.  In my example below I create the shape and then I show it with polygon, which converts the point list into something you can view.  If you want to do something else with the point list then you shouldn't invoke polygon on it, because polygon turns the point list into geometry.  The point list, shape, is what you were after.   In your example below remove the reference to polygon and change your second arg to xscale to say p= to ensure it works in other BOSL2 versions.   jon_bondy wrote > In the code you provided, below, you use all functions except at the very > end: > > \$fn=64; > > bottom = arc(angle=[210,330], d=20); > top = offset(bottom, r=1); > shape = concat(top,reverse(bottom)); > polygon(shape); > > the result is that this fails because polygon() is not a function > > myProfsB = [for (i=[0:14]) > xscale(1, polygon(concat(offset(bottom, r=1), > reverse(arc(angle=[210,330], d=wB[i])))))]; > > Any hints? > > > _______________________________________________ > OpenSCAD mailing list > Discuss@.openscad > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org-- Sent from: http://forum.openscad.org/_______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|

## Re: simple BOSL question

 LOL.  As soon as I sent that to you, I took a walk, and almost immediately thought "the polygon() was just there to reveal the geometry". Thanks! On 1/2/2021 2:30 PM, adrianv wrote: > If you want to see something in OpenSCAD you have to eventually run a module > that creates geometry.  In my example below I create the shape and then I > show it with polygon, which converts the point list into something you can > view.  If you want to do something else with the point list then you > shouldn't invoke polygon on it, because polygon turns the point list into > geometry.  The point list, shape, is what you were after. > > In your example below remove the reference to polygon and change your second > arg to xscale to say p= to ensure it works in other BOSL2 versions. > > > > jon_bondy wrote >> In the code you provided, below, you use all functions except at the very >> end: >> >> \$fn=64; >> >> bottom = arc(angle=[210,330], d=20); >> top = offset(bottom, r=1); >> shape = concat(top,reverse(bottom)); >> polygon(shape); >> >> the result is that this fails because polygon() is not a function >> >> myProfsB = [for (i=[0:14]) >> xscale(1, polygon(concat(offset(bottom, r=1), >> reverse(arc(angle=[210,330], d=wB[i])))))]; >> >> Any hints? >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@.openscad >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> > > > > -- > Sent from: http://forum.openscad.org/> > _______________________________________________ > OpenSCAD mailing list > [hidden email] > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org