### childern() with parameter and index? BW
Benjamin Wand
Wed, Sep 6, 2023 6:41 PM

Hello,

after several happy and sometimes head-scratchy years with OpenSCAD I’m finally at asking the list something again. I’m trying to make a 3d puzzle of a truncated dodecahedron, using the maths in this file: https://www.printables.com/de/model/430670-truncated-icosahedron-rounded-soccer-form

Now, I have modules of puzzle pieces and places where they should go, and the puzzle pieces come in a large and a small version, made with offset. The puzzle pieces have an order and they sit in a list. I would like to take pieces from that list by index and with or without the offset. I tried it with children() but couldn’t find out how to get the offset-parameter across. Any idea how to do that?

Simplified code, and please just ignore the maths, the question is at the end of the code.

Benjamin

// Parameters
s = 10;    // basic edgelenth
gap = 0.4;  // gap between puzzle pieces
t = s/2;    // maximal thickness of shell

// Math (Thanks to Lukas Süss aka mechadense for typing it math into an OpenSCAD file!)

sph_diam = (s3)1/6sqrt(29/2+9/2sqrt(5));

rhex = s;
rpent = (s/2)/cos(54);

hhex =  sqrt(pow(sph_diam,2)-pow(rhex,2));
hpent = sqrt(pow(sph_diam,2)-pow(rpent,2));

hh = (180-90-acos(-1/3sqrt(5))/2)2;
hp = atan(rhex
cos(30)/hhex)+atan(rpent
cos(72/2)/hpent);
pp = 2atan(rpent/hpent) + 2atan((s/2)/(hhex/cos(hh/2)));

// Building blocks

module five(n, gap=0)
translate([0,0,-hpent]) {
color("black") linear_extrude(t) offset(gap, \$fn=10)
rotate([0, 0, 90]) circle(t, r=s/(2*sin(36)), \$fn = 5);
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, valign="center", halign="center");
};
module six(n, gap=0)
translate([0,0,-hhex]) {
color("white") linear_extrude(t) offset(gap, \$fn=10)
circle(t, r=s, \$fn = 6);
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, valign="center", halign="center");
};

// Flow control

module ball() {
// here I would like to do things with the pieces with or without the offset, for instance:
for (i = [0 : 2 : \$children -1])
let(gap=gap)children(i);
// or
for (i = [1 : 2 : \$children -1])
children(i, gap=0);
// but I don't know how
};

ball() {
rotate([hp,0,60]) five(1);
six(2);
rotate([hh,0,0]) six(3);
rotate([hh,0,0]) rotate([hh,0,60]) six(4);
rotate([hp+pp,180,0]) rotate([0,0,180]) five(5);
rotate([hh,0,0]) rotate([hh,0,-60]) six(6);
rotate([hp,0,-60]) five(7);
rotate([hh,0,-120]) six(8);
rotate([hp,0,180]) five(9);
};

Hello, after several happy and sometimes head-scratchy years with OpenSCAD I’m finally at asking the list something again. I’m trying to make a 3d puzzle of a truncated dodecahedron, using the maths in this file: https://www.printables.com/de/model/430670-truncated-icosahedron-rounded-soccer-form Now, I have modules of puzzle pieces and places where they should go, and the puzzle pieces come in a large and a small version, made with offset. The puzzle pieces have an order and they sit in a list. I would like to take pieces from that list by index and with or without the offset. I tried it with children() but couldn’t find out how to get the offset-parameter across. Any idea how to do that? Simplified code, and please just ignore the maths, the question is at the end of the code. Thanks in advance! Benjamin // Parameters s = 10; // basic edgelenth gap = 0.4; // gap between puzzle pieces t = s/2; // maximal thickness of shell // Math (Thanks to Lukas Süss aka mechadense for typing it math into an OpenSCAD file!) sph_diam = (s*3)*1/6*sqrt(29/2+9/2*sqrt(5)); rhex = s; rpent = (s/2)/cos(54); hhex = sqrt(pow(sph_diam,2)-pow(rhex,2)); hpent = sqrt(pow(sph_diam,2)-pow(rpent,2)); hh = (180-90-acos(-1/3*sqrt(5))/2)*2; hp = atan(rhex*cos(30)/hhex)+atan(rpent*cos(72/2)/hpent); pp = 2*atan(rpent/hpent) + 2*atan((s/2)/(hhex/cos(hh/2))); // Building blocks module five(n, gap=0) translate([0,0,-hpent]) { color("black") linear_extrude(t) offset(gap, \$fn=10) rotate([0, 0, 90]) circle(t, r=s/(2*sin(36)), \$fn = 5); linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, valign="center", halign="center"); }; module six(n, gap=0) translate([0,0,-hhex]) { color("white") linear_extrude(t) offset(gap, \$fn=10) circle(t, r=s, \$fn = 6); linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, valign="center", halign="center"); }; // Flow control module ball() { // here I would like to do things with the pieces with or without the offset, for instance: for (i = [0 : 2 : \$children -1]) let(gap=gap)children(i); // or for (i = [1 : 2 : \$children -1]) children(i, gap=0); // but I don't know how }; ball() { rotate([hp,0,60]) five(1); six(2); rotate([hh,0,0]) six(3); rotate([hh,0,0]) rotate([hh,0,60]) six(4); rotate([hp+pp,180,0]) rotate([0,0,180]) five(5); rotate([hh,0,0]) rotate([hh,0,-60]) six(6); rotate([hp,0,-60]) five(7); rotate([hh,0,-120]) six(8); rotate([hp,0,180]) five(9); }; NH
Wed, Sep 6, 2023 6:50 PM

Not sure if this what you mean, but you can pass values from a parent to
its children using \$variables.

On Wed, 6 Sept 2023 at 19:41, Benjamin Wand benjamin.wand@web.de wrote:

Hello,

finally at asking the list something again. I’m trying to make a 3d puzzle
of a truncated dodecahedron, using the maths in this file:
https://www.printables.com/de/model/430670-truncated-icosahedron-rounded-soccer-form

Now, I have modules of puzzle pieces and places where they should go, and
the puzzle pieces come in a large and a small version, made with offset.
The puzzle pieces have an order and they sit in a list. I would like to
take pieces from that list by index and with or without the offset. I tried
it with children() but couldn’t find out how to get the offset-parameter
across. Any idea how to do that?

Simplified code, and please just ignore the maths, the question is at the
end of the code.

Benjamin

// Parameters
s = 10;    // basic edgelenth
gap = 0.4;  // gap between puzzle pieces
t = s/2;    // maximal thickness of shell

// Math (Thanks to Lukas Süss aka mechadense for typing it math into an

sph_diam = (s3)1/6sqrt(29/2+9/2sqrt(5));

rhex = s;
rpent = (s/2)/cos(54);

hhex =  sqrt(pow(sph_diam,2)-pow(rhex,2));
hpent = sqrt(pow(sph_diam,2)-pow(rpent,2));

hh = (180-90-acos(-1/3sqrt(5))/2)2;
hp = atan(rhex
cos(30)/hhex)+atan(rpent
cos(72/2)/hpent);
pp = 2atan(rpent/hpent) + 2atan((s/2)/(hhex/cos(hh/2)));

// Building blocks

module five(n, gap=0)
translate([0,0,-hpent]) {
color("black") linear_extrude(t) offset(gap, \$fn=10)
rotate([0, 0, 90]) circle(t, r=s/(2*sin(36)), \$fn = 5);
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2,
valign="center", halign="center");
};
module six(n, gap=0)
translate([0,0,-hhex]) {
color("white") linear_extrude(t) offset(gap, \$fn=10)
circle(t, r=s, \$fn = 6);
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2,
valign="center", halign="center");
};

// Flow control

module ball() {
// here I would like to do things with the pieces with or without the
offset, for instance:
for (i = [0 : 2 : \$children -1])
let(gap=gap)children(i);
// or
for (i = [1 : 2 : \$children -1])
children(i, gap=0);
// but I don't know how
};

ball() {
rotate([hp,0,60]) five(1);
six(2);
rotate([hh,0,0]) six(3);
rotate([hh,0,0]) rotate([hh,0,60]) six(4);
rotate([hp+pp,180,0]) rotate([0,0,180]) five(5);
rotate([hh,0,0]) rotate([hh,0,-60]) six(6);
rotate([hp,0,-60]) five(7);
rotate([hh,0,-120]) six(8);
rotate([hp,0,180]) five(9);
};

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

Not sure if this what you mean, but you can pass values from a parent to its children using \$variables. On Wed, 6 Sept 2023 at 19:41, Benjamin Wand <benjamin.wand@web.de> wrote: > Hello, > > after several happy and sometimes head-scratchy years with OpenSCAD I’m > finally at asking the list something again. I’m trying to make a 3d puzzle > of a truncated dodecahedron, using the maths in this file: > https://www.printables.com/de/model/430670-truncated-icosahedron-rounded-soccer-form > > Now, I have modules of puzzle pieces and places where they should go, and > the puzzle pieces come in a large and a small version, made with offset. > The puzzle pieces have an order and they sit in a list. I would like to > take pieces from that list by index and with or without the offset. I tried > it with children() but couldn’t find out how to get the offset-parameter > across. Any idea how to do that? > > Simplified code, and please just ignore the maths, the question is at the > end of the code. > > Thanks in advance! > Benjamin > > > // Parameters > s = 10; // basic edgelenth > gap = 0.4; // gap between puzzle pieces > t = s/2; // maximal thickness of shell > > > // Math (Thanks to Lukas Süss aka mechadense for typing it math into an > OpenSCAD file!) > > sph_diam = (s*3)*1/6*sqrt(29/2+9/2*sqrt(5)); > > rhex = s; > rpent = (s/2)/cos(54); > > hhex = sqrt(pow(sph_diam,2)-pow(rhex,2)); > hpent = sqrt(pow(sph_diam,2)-pow(rpent,2)); > > hh = (180-90-acos(-1/3*sqrt(5))/2)*2; > hp = atan(rhex*cos(30)/hhex)+atan(rpent*cos(72/2)/hpent); > pp = 2*atan(rpent/hpent) + 2*atan((s/2)/(hhex/cos(hh/2))); > > // Building blocks > > module five(n, gap=0) > translate([0,0,-hpent]) { > color("black") linear_extrude(t) offset(gap, \$fn=10) > rotate([0, 0, 90]) circle(t, r=s/(2*sin(36)), \$fn = 5); > linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, > valign="center", halign="center"); > }; > module six(n, gap=0) > translate([0,0,-hhex]) { > color("white") linear_extrude(t) offset(gap, \$fn=10) > circle(t, r=s, \$fn = 6); > linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, > valign="center", halign="center"); > }; > > // Flow control > > module ball() { > // here I would like to do things with the pieces with or without the > offset, for instance: > for (i = [0 : 2 : \$children -1]) > let(gap=gap)children(i); > // or > for (i = [1 : 2 : \$children -1]) > children(i, gap=0); > // but I don't know how > }; > > ball() { > rotate([hp,0,60]) five(1); > six(2); > rotate([hh,0,0]) six(3); > rotate([hh,0,0]) rotate([hh,0,60]) six(4); > rotate([hp+pp,180,0]) rotate([0,0,180]) five(5); > rotate([hh,0,0]) rotate([hh,0,-60]) six(6); > rotate([hp,0,-60]) five(7); > rotate([hh,0,-120]) six(8); > rotate([hp,0,180]) five(9); > }; > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > BW
Benjamin Wand
Wed, Sep 6, 2023 7:42 PM

That sounds right but I can’t find any code examples in the wikibook, they are all just referencing children by index and with no further parameter, could you point me to one? I’d like to say something like "give me child 4 with the offset and child 5 without."

Not sure if this what you mean, but you can pass values from a parent to its children using \$variables.

On Wed, 6 Sept 2023 at 19:41, Benjamin Wand <benjamin.wand@web.de mailto:benjamin.wand@web.de> wrote:

Hello,

after several happy and sometimes head-scratchy years with OpenSCAD I’m finally at asking the list something again. I’m trying to make a 3d puzzle of a truncated dodecahedron, using the maths in this file: https://www.printables.com/de/model/430670-truncated-icosahedron-rounded-soccer-form

Now, I have modules of puzzle pieces and places where they should go, and the puzzle pieces come in a large and a small version, made with offset. The puzzle pieces have an order and they sit in a list. I would like to take pieces from that list by index and with or without the offset. I tried it with children() but couldn’t find out how to get the offset-parameter across. Any idea how to do that?

Simplified code, and please just ignore the maths, the question is at the end of the code.

Benjamin

// Parameters
s = 10;    // basic edgelenth
gap = 0.4;  // gap between puzzle pieces
t = s/2;    // maximal thickness of shell

// Math (Thanks to Lukas Süss aka mechadense for typing it math into an OpenSCAD file!)

sph_diam = (s3)1/6sqrt(29/2+9/2sqrt(5));

rhex = s;
rpent = (s/2)/cos(54);

hhex =  sqrt(pow(sph_diam,2)-pow(rhex,2));
hpent = sqrt(pow(sph_diam,2)-pow(rpent,2));

hh = (180-90-acos(-1/3sqrt(5))/2)2;
hp = atan(rhex
cos(30)/hhex)+atan(rpent
cos(72/2)/hpent);
pp = 2atan(rpent/hpent) + 2atan((s/2)/(hhex/cos(hh/2)));

// Building blocks

module five(n, gap=0)
translate([0,0,-hpent]) {
color("black") linear_extrude(t) offset(gap, \$fn=10)
rotate([0, 0, 90]) circle(t, r=s/(2*sin(36)), \$fn = 5);
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, valign="center", halign="center");
};
module six(n, gap=0)
translate([0,0,-hhex]) {
color("white") linear_extrude(t) offset(gap, \$fn=10)
circle(t, r=s, \$fn = 6);
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, valign="center", halign="center");
};

// Flow control

module ball() {
// here I would like to do things with the pieces with or without the offset, for instance:
for (i = [0 : 2 : \$children -1])
let(gap=gap)children(i);
// or
for (i = [1 : 2 : \$children -1])
children(i, gap=0);
// but I don't know how
};

ball() {
rotate([hp,0,60]) five(1);
six(2);
rotate([hh,0,0]) six(3);
rotate([hh,0,0]) rotate([hh,0,60]) six(4);
rotate([hp+pp,180,0]) rotate([0,0,180]) five(5);
rotate([hh,0,0]) rotate([hh,0,-60]) six(6);
rotate([hp,0,-60]) five(7);
rotate([hh,0,-120]) six(8);
rotate([hp,0,180]) five(9);
};

To unsubscribe send an email to discuss-leave@lists.openscad.org NH
Wed, Sep 6, 2023 7:45 PM

Something like this:

module parent() {
let(\$offset = 1) children(4);
let(\$offset = 0) children(5);
}

Then in the child you can access \$offset. It isn't passed a named argument
but it is accessible. A bit of an ugly work around for that fact you can't
pass parameters to children.

On Wed, 6 Sept 2023 at 20:42, Benjamin Wand benjamin.wand@web.de wrote:

That sounds right but I can’t find any code examples in the wikibook, they
are all just referencing children by index and with no further parameter,
could you point me to one? I’d like to say something like "give me child 4
with the offset and child 5 without."

Not sure if this what you mean, but you can pass values from a parent to
its children using \$variables.

On Wed, 6 Sept 2023 at 19:41, Benjamin Wand benjamin.wand@web.de wrote:

Hello,

finally at asking the list something again. I’m trying to make a 3d puzzle
of a truncated dodecahedron, using the maths in this file:
https://www.printables.com/de/model/430670-truncated-icosahedron-rounded-soccer-form

Now, I have modules of puzzle pieces and places where they should go, and
the puzzle pieces come in a large and a small version, made with offset.
The puzzle pieces have an order and they sit in a list. I would like to
take pieces from that list by index and with or without the offset. I tried
it with children() but couldn’t find out how to get the offset-parameter
across. Any idea how to do that?

Simplified code, and please just ignore the maths, the question is at the
end of the code.

Benjamin

// Parameters
s = 10;    // basic edgelenth
gap = 0.4;  // gap between puzzle pieces
t = s/2;    // maximal thickness of shell

// Math (Thanks to Lukas Süss aka mechadense for typing it math into an

sph_diam = (s3)1/6sqrt(29/2+9/2sqrt(5));

rhex = s;
rpent = (s/2)/cos(54);

hhex =  sqrt(pow(sph_diam,2)-pow(rhex,2));
hpent = sqrt(pow(sph_diam,2)-pow(rpent,2));

hh = (180-90-acos(-1/3sqrt(5))/2)2;
hp = atan(rhex
cos(30)/hhex)+atan(rpent
cos(72/2)/hpent);
pp = 2atan(rpent/hpent) + 2atan((s/2)/(hhex/cos(hh/2)));

// Building blocks

module five(n, gap=0)
translate([0,0,-hpent]) {
color("black") linear_extrude(t) offset(gap, \$fn=10)
rotate([0, 0, 90]) circle(t, r=s/(2*sin(36)), \$fn = 5);
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2,
valign="center", halign="center");
};
module six(n, gap=0)
translate([0,0,-hhex]) {
color("white") linear_extrude(t) offset(gap, \$fn=10)
circle(t, r=s, \$fn = 6);
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2,
valign="center", halign="center");
};

// Flow control

module ball() {
// here I would like to do things with the pieces with or without the
offset, for instance:
for (i = [0 : 2 : \$children -1])
let(gap=gap)children(i);
// or
for (i = [1 : 2 : \$children -1])
children(i, gap=0);
// but I don't know how
};

ball() {
rotate([hp,0,60]) five(1);
six(2);
rotate([hh,0,0]) six(3);
rotate([hh,0,0]) rotate([hh,0,60]) six(4);
rotate([hp+pp,180,0]) rotate([0,0,180]) five(5);
rotate([hh,0,0]) rotate([hh,0,-60]) six(6);
rotate([hp,0,-60]) five(7);
rotate([hh,0,-120]) six(8);
rotate([hp,0,180]) five(9);
};

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 BW
Benjamin Wand
Wed, Sep 6, 2023 8:49 PM

Mh, changing the offset in module five() or module six() or ball() does have an effect, but in module ball(), where I would want it, it won’t work. What am I missing?
The only option that comes to my mind is having all things in ball() twice, once with and once without the offset to be able to access it from module ball but that would be a bit of an ugly double code.

// Building blocks

module five(n, offset)
translate([0,0,-hpent]) { color("black") linear_extrude(t) rotate([0, 0, 90])
if (offset == true) { offset(gap, \$fn=10)
circle(t, r=s/(2sin(36)), \$fn = 5);}
else {
circle(t, r=s/(2
sin(36)), \$fn = 5);}
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, valign="center", halign="center");
};
module six(n, offset)
translate([0,0,-hhex]) { color("white") linear_extrude(t)
if (offset == true) { offset(gap, \$fn=10)
circle(t, r=s, \$fn = 6);}
else {
circle(t, r=s, \$fn = 6);}
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, valign="center", halign="center");
};

// Flow control

module ball() {
let(\$offset = false) children([1 : 2 : \$children -1]);
let(\$offset = true) children([0 : 2 : \$children -1]);
}

ball() {
rotate([hp,0,60]) five(1);
six(2);
rotate([hh,0,0]) six(3);
rotate([hh,0,0]) rotate([hh,0,60]) six(4);
rotate([hp+pp,180,0]) rotate([0,0,180]) five(5);
rotate([hh,0,0]) rotate([hh,0,-60]) six(6);
rotate([hp,0,-60]) five(7);
rotate([hh,0,-120]) six(8);
};

Something like this:

module parent() {
let(\$offset = 1) children(4);
let(\$offset = 0) children(5);
}

Then in the child you can access \$offset. It isn't passed a named argument but it is accessible. A bit of an ugly work around for that fact you can't pass parameters to children.

On Wed, 6 Sept 2023 at 20:42, Benjamin Wand <benjamin.wand@web.de mailto:benjamin.wand@web.de> wrote:

That sounds right but I can’t find any code examples in the wikibook, they are all just referencing children by index and with no further parameter, could you point me to one? I’d like to say something like "give me child 4 with the offset and child 5 without."

Not sure if this what you mean, but you can pass values from a parent to its children using \$variables.

On Wed, 6 Sept 2023 at 19:41, Benjamin Wand <benjamin.wand@web.de mailto:benjamin.wand@web.de> wrote:

Hello,

after several happy and sometimes head-scratchy years with OpenSCAD I’m finally at asking the list something again. I’m trying to make a 3d puzzle of a truncated dodecahedron, using the maths in this file: https://www.printables.com/de/model/430670-truncated-icosahedron-rounded-soccer-form

Now, I have modules of puzzle pieces and places where they should go, and the puzzle pieces come in a large and a small version, made with offset. The puzzle pieces have an order and they sit in a list. I would like to take pieces from that list by index and with or without the offset. I tried it with children() but couldn’t find out how to get the offset-parameter across. Any idea how to do that?

Simplified code, and please just ignore the maths, the question is at the end of the code.

Benjamin

// Parameters
s = 10;    // basic edgelenth
gap = 0.4;  // gap between puzzle pieces
t = s/2;    // maximal thickness of shell

// Math (Thanks to Lukas Süss aka mechadense for typing it math into an OpenSCAD file!)

sph_diam = (s3)1/6sqrt(29/2+9/2sqrt(5));

rhex = s;
rpent = (s/2)/cos(54);

hhex =  sqrt(pow(sph_diam,2)-pow(rhex,2));
hpent = sqrt(pow(sph_diam,2)-pow(rpent,2));

hh = (180-90-acos(-1/3sqrt(5))/2)2;
hp = atan(rhex
cos(30)/hhex)+atan(rpent
cos(72/2)/hpent);
pp = 2atan(rpent/hpent) + 2atan((s/2)/(hhex/cos(hh/2)));

// Building blocks

module five(n, gap=0)
translate([0,0,-hpent]) {
color("black") linear_extrude(t) offset(gap, \$fn=10)
rotate([0, 0, 90]) circle(t, r=s/(2*sin(36)), \$fn = 5);
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, valign="center", halign="center");
};
module six(n, gap=0)
translate([0,0,-hhex]) {
color("white") linear_extrude(t) offset(gap, \$fn=10)
circle(t, r=s, \$fn = 6);
linear_extrude(1) mirror([1,0,0]) text(str(n), size=s/2, valign="center", halign="center");
};

// Flow control

module ball() {
// here I would like to do things with the pieces with or without the offset, for instance:
for (i = [0 : 2 : \$children -1])
let(gap=gap)children(i);
// or
for (i = [1 : 2 : \$children -1])
children(i, gap=0);
// but I don't know how
};

ball() {
rotate([hp,0,60]) five(1);
six(2);
rotate([hh,0,0]) six(3);
rotate([hh,0,0]) rotate([hh,0,60]) six(4);
rotate([hp+pp,180,0]) rotate([0,0,180]) five(5);
rotate([hh,0,0]) rotate([hh,0,-60]) six(6);
rotate([hp,0,-60]) five(7);
rotate([hh,0,-120]) six(8);
rotate([hp,0,180]) five(9);
};

To unsubscribe send an email to discuss-leave@lists.openscad.org JB
Jordan Brown
Wed, Sep 6, 2023 8:54 PM

On 9/6/2023 1:49 PM, Benjamin Wand wrote:

Mh, changing the offset in module five() or module six() or ball()
does have an effect, but in module ball(), where I would want it, it
won’t work. What am I missing?

This may be a case of the "interesting" scoping behavior for \$ variables
that I described in this thread:

On 9/6/2023 1:49 PM, Benjamin Wand wrote: > Mh, changing the offset in module five() or module six() or ball() > does have an effect, but in module ball(), where I would want it, it > won’t work. What am I missing? This may be a case of the "interesting" scoping behavior for \$ variables that I described in this thread: https://lists.openscad.org/empathy/thread/YUCPSTGM45U27DSWTSJ5PXS6GVEFF6RT NH
Wed, Sep 6, 2023 9:06 PM

You aren't using \$offset in five and six. You have a parameter called
offset.

Try
ball() {
rotate([hp,0,60]) five(1, \$offset);
six(2, \$offset);
rotate([hh,0,0]) six(3,  \$offset  );
rotate([hh,0,0]) rotate([hh,0,60]) six(4 , \$offset  );
rotate([hp+pp,180,0]) rotate([0,0,180]) five(5,  \$offset  );
rotate([hh,0,0]) rotate([hh,0,-60]) six(6,  \$offset  );
rotate([hp,0,-60]) five(7,  \$offset  );
rotate([hh,0,-120]) six(8,  \$offset  );
};

On Wed, 6 Sept 2023 at 21:54, Jordan Brown openscad@jordan.maileater.net
wrote:

On 9/6/2023 1:49 PM, Benjamin Wand wrote:

Mh, changing the offset in module five() or module six() or ball() does
have an effect, but in module ball(), where I would want it, it won’t work.
What am I missing?

This may be a case of the "interesting" scoping behavior for \$ variables
that I described in this thread:

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

You aren't using \$offset in five and six. You have a parameter called offset. Try ball() { rotate([hp,0,60]) five(1, \$offset); six(2, \$offset); rotate([hh,0,0]) six(3, \$offset ); rotate([hh,0,0]) rotate([hh,0,60]) six(4 , \$offset ); rotate([hp+pp,180,0]) rotate([0,0,180]) five(5, \$offset ); rotate([hh,0,0]) rotate([hh,0,-60]) six(6, \$offset ); rotate([hp,0,-60]) five(7, \$offset ); rotate([hh,0,-120]) six(8, \$offset ); }; On Wed, 6 Sept 2023 at 21:54, Jordan Brown <openscad@jordan.maileater.net> wrote: > On 9/6/2023 1:49 PM, Benjamin Wand wrote: > > Mh, changing the offset in module five() or module six() or ball() does > have an effect, but in module ball(), where I would want it, it won’t work. > What am I missing? > > > This may be a case of the "interesting" scoping behavior for \$ variables > that I described in this thread: > https://lists.openscad.org/empathy/thread/YUCPSTGM45U27DSWTSJ5PXS6GVEFF6RT > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > BW
Benjamin Wand
Thu, Sep 7, 2023 5:38 AM

Ooooh, that’s it, thanks a lot!

You aren't using \$offset in five and six. You have a parameter called offset.

Try
ball() {
rotate([hp,0,60]) five(1, \$offset);
six(2, \$offset);
rotate([hh,0,0]) six(3,  \$offset  );
rotate([hh,0,0]) rotate([hh,0,60]) six(4 , \$offset  );
rotate([hp+pp,180,0]) rotate([0,0,180]) five(5,  \$offset  );
rotate([hh,0,0]) rotate([hh,0,-60]) six(6,  \$offset  );
rotate([hp,0,-60]) five(7,  \$offset  );
rotate([hh,0,-120]) six(8,  \$offset  );
};

On Wed, 6 Sept 2023 at 21:54, Jordan Brown <openscad@jordan.maileater.net mailto:openscad@jordan.maileater.net> wrote:

On 9/6/2023 1:49 PM, Benjamin Wand wrote:

Mh, changing the offset in module five() or module six() or ball() does have an effect, but in module ball(), where I would want it, it won’t work. What am I missing?

This may be a case of the "interesting" scoping behavior for \$ variables that I described in this thread: