### little question

SP
Sanjeev Prabhakar
Thu, Jul 18, 2024 4:03 PM

there is another one:

path=arc(6,55,360);
newpath = path3d(path);

for(i=[0:4])
{
echo (i);
echo(newpath[i]);
translate(newpath[i]) cylinder(h=2,d=2);
}

On Thu, 18 Jul 2024 at 21:32, Sanjeev Prabhakar sprabhakar2006@gmail.com
wrote:

but there are some syntax error which I can see and corrected below

path=arc(6,55,360);
newpath = path3d(path);

for(i=[0:4])
{
echo (i);
echo(newpath[i]);
translate([newpath[i]]) cylinder(h=2,d=2);
}

On Thu, 18 Jul 2024 at 20:35, Karl Exler via Discuss <

Thanks you all for your help, but I can't  find a solution.. I always

\$fn=100;
id=55; //Innendurchmesser
od=64; //Außendurchmesser
h=10;  //Höhe über Alles
s=2;  //Stärke
nz=6;  //Anzahl kleine Löcher

path=arc(6,55,360);
newpath = path3d(path);

for(i=[0:4])

echo (i)
echo(newpath[i]);
translate([newpath[i]]) cylinder(h=2,d=2);

yours Karl
Am 18.07.24 um 12:19 schrieb Revar Desmera:

In BOSL2, to convert a path from XY 2D, to XYZ 3D, use `p3d = path3d(p2d);`.

-Revar

On Jul 17, 2024, at 10:10 PM, Karl Exler via Discuss

﻿ Hi Peter,

THIS is my favorite.... but I have a problem, as in these coordinates the
z-Achse is missing. So If I want to operate next with something like

path=arc(n=6,d=100,angle=360);

... it returns an array with x and y

*BUT to continue with *

for(i=[0:nz-1])

translate([path[i],0])

echo(path[i],0);
cylinder(d=2);

I need an array with a Z-Axis, too...

I receive an failure in "translate"

So my question is: How can I use the result from the path-Variable in the
first line?

Many thanks
Karl

if you just want the vectors:

echo(path);

ECHO: [[50, 0], [-25, 43.3013], [-25, -43.3013], [50, 0]]

On 16 Jul 2024, at 10:18, Karl Exler via Discuss

Dear all

...... this is the way a non programmer works.. but it is painful. :-(

\$fn=100;
id=55; //Innendurchmesser
od=64; //Außendurchmesser
h=10;  //Höhe über Alles
s=2;  //Stärke

translate([0,0,h/2+s/2])
tube(h=h-s, or=id/2, wall=s);
difference()

{
cylinder(s,d=od);
translate([-id/20.7,id/20.4,s0.5]) sphere(r=2);
translate([-id/2
0.3,id/20.6,s0.5]) sphere(r=2);
translate([id/20.4,id/20.5,s0.5]) sphere(r=2);
translate([id/2
0.5,id/20.2,s0.5]) sphere(r=2);
translate([id/20.2,-id/20.3,s0.5]) sphere(r=2);
translate([-id/2
0.6,id/2*-0.3,s*0.5]) sphere(r=2);
}

How can I manage to get a valid array of coordinates which are all within
a defined circle with a diameter of n?

Karl

P.S.
the goal is to print a kind of lid for different sizes of glasses... to
use them as vase for small flowers.

<PXL_20240715_100200132.MP.jpg>

To unsubscribe send an email to discuss-leave@lists.openscad.org

To unsubscribe send an email to discuss-leave@lists.openscad.org

To unsubscribe send an email to discuss-leave@lists.openscad.org

JB
Jordan Brown
Fri, Jul 19, 2024 6:48 AM

Thanks you all for your help, but I can't  find a solution.. I always receive an error message

When saying that you are getting an error message, it is always good to report what error message you are getting. That said, I see a couple of clear problems.  Sanjeev seems to have found them, but didn’t really elaborate.

path=arc(6,55,360);
newpath = path3d(path);

for(i=[0:4])

echo (i)
echo(newpath[i]);
translate([newpath[i]]) cylinder(h=2,d=2);

The first echo() has no semicolon after it.  Syntactically, that makes the second echo be its child.  To my mild surprise, that does work, but it’s still not a conventional structure.

The scope of the for() is the pair of echo() calls.  The translate() is outside its scope.  You want braces around all three.

The argument to the translate is the wrong type.  This one merits a bit more discussion.

translate() wants a vector (list) of two or three numbers.  Brackets make a list, so [1,2,3] is a list of three numbers.  BOSL2’s path stuff generates a list of such lists.  newpath[i] is such a list; in this case, a list of three numbers. So far so good.  But then you have brackets around it, so you are making a list of one element, with that one element being a list of three numbers.  That’s not what translate() wants. Lose the brackets.

I don’t know whether it applied here, but I think that something like this is a common error in new OpenSCAD users: thinking that brackets are part of the syntax of translate() and similar modules.  They aren’t.  translate() wants a list of three numbers, however constructed.  The argument can be an explicitly constructed list with [num1,num2,num3], or it can be a variable whose value is such a list, or it can be constructed some other way (function call, et cetera).  Brackets are only necessary and appropriate when you are explicitly creating the list right there.

BTW, a simplification:  while many languages require you to loop through the indexes of an array to retrieve the values in succession, OpenSCAD doesn’t.  “for (val = list) …” will execute the body once for each element in the list.  When you don’t need the index for some other purpose, avoiding it makes things simpler.

Net, your snippet above should probably look like:

for (p = newpath) {
echo(p);
translate(p) cylinder(h=2,d=2);
}

> Thanks you all for your help, but I can't find a solution.. I always receive an error message > When saying that you are getting an error message, it is always good to report what error message you are getting. That said, I see a couple of clear problems. Sanjeev seems to have found them, but didn’t really elaborate. > path=arc(6,55,360); > newpath = path3d(path); > > for(i=[0:4]) > > echo (i) > echo(newpath[i]); > translate([newpath[i]]) cylinder(h=2,d=2); > The first echo() has no semicolon after it. Syntactically, that makes the second echo be its child. To my mild surprise, that *does* work, but it’s still not a conventional structure. The scope of the for() is the pair of echo() calls. The translate() is outside its scope. You want braces around all three. The argument to the translate is the wrong type. This one merits a bit more discussion. translate() wants a vector (list) of two or three numbers. Brackets make a list, so [1,2,3] is a list of three numbers. BOSL2’s path stuff generates a list of such lists. newpath[i] is such a list; in this case, a list of three numbers. So far so good. But then you have brackets around it, so you are making a list of one element, with that one element being a list of three numbers. That’s *not* what translate() wants. Lose the brackets. I don’t know whether it applied here, but I think that something like this is a common error in new OpenSCAD users: thinking that brackets are part of the syntax of translate() and similar modules. They aren’t. translate() wants a list of three numbers, however constructed. The argument can be an explicitly constructed list with [num1,num2,num3], or it can be a variable whose value is such a list, or it can be constructed some other way (function call, et cetera). Brackets are only necessary and appropriate when you are explicitly creating the list right there. BTW, a simplification: while many languages require you to loop through the indexes of an array to retrieve the values in succession, OpenSCAD doesn’t. “for (val = list) …” will execute the body once for each element in the list. When you don’t need the index for some other purpose, avoiding it makes things simpler. Net, your snippet above should probably look like: for (p = newpath) { echo(p); translate(p) cylinder(h=2,d=2); }
JB
Jordan Brown
Fri, Jul 19, 2024 6:56 AM

[ Sorry if this is a duplicate.  Not sure if the first went through. ]

Thanks you all for your help, but I can't  find a solution.. I always receive an error message

When saying that you are getting an error message, it is always good to report what error message you are getting. That said, I see a couple of clear problems.  Sanjeev and Jon seem to have found them, but didn’t really elaborate.

path=arc(6,55,360);
newpath = path3d(path);

for(i=[0:4])

echo (i)
echo(newpath[i]);
translate([newpath[i]]) cylinder(h=2,d=2);

The first echo() has no semicolon after it.  Syntactically, that makes the second echo be its child.  To my mild surprise, that does work, but it’s still not a conventional structure.

The scope of the for() is the pair of echo() calls.  The translate() is outside its scope.  You want braces around all three.

The argument to the translate is the wrong type.  This one merits a bit more discussion.

translate() wants a vector (list) of two or three numbers.  Brackets make a list, so [1,2,3] is a list of three numbers.  BOSL2’s path stuff generates a list of such lists.  newpath[i] is such a list; in this case, a list of three numbers. So far so good.  But then you have brackets around it, so you are making a list of one element, with that one element being a list of three numbers.  That’s not what translate() wants. Lose the brackets.

I don’t know whether it applied here, but I think that something like this is a common error in new OpenSCAD users: thinking that brackets are part of the syntax of translate() and similar modules.  They aren’t.  translate() wants a list of three numbers, however constructed.  The argument can be an explicitly constructed list with [num1,num2,num3], or it can be a variable whose value is such a list, or it can be constructed some other way (function call, et cetera).  Brackets are only necessary and appropriate when you are explicitly creating the list right there.

BTW, a simplification:  while many languages require you to loop through the indexes of an array to retrieve the values in succession, OpenSCAD doesn’t.  “for (val = list) …” will execute the body once for each element in the list.  When you don’t need the index for some other purpose, avoiding it makes things simpler.

Net, your snippet above should probably look like:

for (p = newpath) {
echo(p);
translate(p) cylinder(h=2,d=2);
}

[ Sorry if this is a duplicate. Not sure if the first went through. ] > Thanks you all for your help, but I can't find a solution.. I always receive an error message > When saying that you are getting an error message, it is always good to report what error message you are getting. That said, I see a couple of clear problems. Sanjeev and Jon seem to have found them, but didn’t really elaborate. > path=arc(6,55,360); > newpath = path3d(path); > > for(i=[0:4]) > > echo (i) > echo(newpath[i]); > translate([newpath[i]]) cylinder(h=2,d=2); > The first echo() has no semicolon after it. Syntactically, that makes the second echo be its child. To my mild surprise, that *does* work, but it’s still not a conventional structure. The scope of the for() is the pair of echo() calls. The translate() is outside its scope. You want braces around all three. The argument to the translate is the wrong type. This one merits a bit more discussion. translate() wants a vector (list) of two or three numbers. Brackets make a list, so [1,2,3] is a list of three numbers. BOSL2’s path stuff generates a list of such lists. newpath[i] is such a list; in this case, a list of three numbers. So far so good. But then you have brackets around it, so you are making a list of one element, with that one element being a list of three numbers. That’s *not* what translate() wants. Lose the brackets. I don’t know whether it applied here, but I think that something like this is a common error in new OpenSCAD users: thinking that brackets are part of the syntax of translate() and similar modules. They aren’t. translate() wants a list of three numbers, however constructed. The argument can be an explicitly constructed list with [num1,num2,num3], or it can be a variable whose value is such a list, or it can be constructed some other way (function call, et cetera). Brackets are only necessary and appropriate when you are explicitly creating the list right there. BTW, a simplification: while many languages require you to loop through the indexes of an array to retrieve the values in succession, OpenSCAD doesn’t. “for (val = list) …” will execute the body once for each element in the list. When you don’t need the index for some other purpose, avoiding it makes things simpler. Net, your snippet above should probably look like: for (p = newpath) { echo(p); translate(p) cylinder(h=2,d=2); }
KE
Karl Exler
Fri, Jul 19, 2024 7:23 AM

Hi Jordan
thanks for this didactic wonderful explanation!!

BR Karl

Am 19.07.24 um 08:48 schrieb Jordan Brown:

Thanks you all for your help, but I can't  find a solution.. I always

When saying that you are getting an error message, it is always good
to report what error message you are getting. That said, I see a
couple of clear problems.  Sanjeev seems to have found them, but
didn’t really elaborate.

path=arc(6,55,360);
newpath = path3d(path);

for(i=[0:4])

echo (i)
echo(newpath[i]);
translate([newpath[i]]) cylinder(h=2,d=2);

The first echo() has no semicolon after it.  Syntactically, that makes
the second echo be its child.  To my mild surprise, that does work,
but it’s still not a conventional structure.

The scope of the for() is the pair of echo() calls.  The translate()
is outside its scope.  You want braces around all three.

The argument to the translate is the wrong type.  This one merits a
bit more discussion.

translate() wants a vector (list) of two or three numbers.  Brackets
make a list, so [1,2,3] is a list of three numbers.  BOSL2’s path
stuff generates a list of such lists.  newpath[i] is such a list; in
this case, a list of three numbers. So far so good.  But then you have
brackets around it, so you are making a list of one element, with that
one element being a list of three numbers.  That’s not what
translate() wants. Lose the brackets.

I don’t know whether it applied here, but I think that something like
this is a common error in new OpenSCAD users: thinking that brackets
are part of the syntax of translate() and similar modules.  They
aren’t.  translate() wants a list of three numbers, however
constructed.  The argument can be an explicitly constructed list with
[num1,num2,num3], or it can be a variable whose value is such a list,
or it can be constructed some other way (function call, et cetera).
Brackets are only necessary and appropriate when you are explicitly
creating the list right there.

BTW, a simplification:  while many languages require you to loop
through the indexes of an array to retrieve the values in succession,
OpenSCAD doesn’t.  “for (val = list) …” will execute the body once for
each element in the list.  When you don’t need the index for some
other purpose, avoiding it makes things simpler.

Net, your snippet above should probably look like:

for (p = newpath) {
echo(p);
translate(p) cylinder(h=2,d=2);
}

Hi Jordan thanks for this didactic wonderful explanation!! BR Karl Am 19.07.24 um 08:48 schrieb Jordan Brown: > >> Thanks you all for your help, but I can't  find a solution.. I always >> receive an error message >> > > When saying that you are getting an error message, it is always good > to report what error message you are getting. That said, I see a > couple of clear problems.  Sanjeev seems to have found them, but > didn’t really elaborate. > >> path=arc(6,55,360); >> newpath = path3d(path); >> >> for(i=[0:4]) >> >>   echo (i) >>   echo(newpath[i]); >>   translate([newpath[i]]) cylinder(h=2,d=2); >> > > The first echo() has no semicolon after it.  Syntactically, that makes > the second echo be its child.  To my mild surprise, that *does* work, > but it’s still not a conventional structure. > > The scope of the for() is the pair of echo() calls.  The translate() > is outside its scope.  You want braces around all three. > > The argument to the translate is the wrong type.  This one merits a > bit more discussion. > > translate() wants a vector (list) of two or three numbers.  Brackets > make a list, so [1,2,3] is a list of three numbers.  BOSL2’s path > stuff generates a list of such lists.  newpath[i] is such a list; in > this case, a list of three numbers. So far so good.  But then you have > brackets around it, so you are making a list of one element, with that > one element being a list of three numbers.  That’s *not* what > translate() wants. Lose the brackets. > > I don’t know whether it applied here, but I think that something like > this is a common error in new OpenSCAD users: thinking that brackets > are part of the syntax of translate() and similar modules.  They > aren’t.  translate() wants a list of three numbers, however > constructed.  The argument can be an explicitly constructed list with > [num1,num2,num3], or it can be a variable whose value is such a list, > or it can be constructed some other way (function call, et cetera). >  Brackets are only necessary and appropriate when you are explicitly > creating the list right there. > > BTW, a simplification:  while many languages require you to loop > through the indexes of an array to retrieve the values in succession, > OpenSCAD doesn’t.  “for (val = list) …” will execute the body once for > each element in the list.  When you don’t need the index for some > other purpose, avoiding it makes things simpler. > > Net, your snippet above should probably look like: > > for (p = newpath) { >     echo(p); >     translate(p) cylinder(h=2,d=2); > }