Why is the upper sphere not smaller?
$fn=32;
r=2;
o=1;
module sphereo(r=1){
sphere(r+o);
%cube(2*(r),true);
}
{sphereo(r);echo(o);}
translate([0,0,8])
assign(o=-o){sphereo(r);echo(o);}
The output is:
ECHO: 1
ECHO: -1
So the assign works for echo but not for the module call???
--
stempeldergeschichte@googlemail.com karsten@rohrbach.de
P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.
Enjoy!
On Mar 25, 2015, at 13:47 PM, Peter Falke stempeldergeschichte@googlemail.com wrote:
Why is the upper sphere not smaller?
So the assign works for echo but not for the module call???
Variables use lexical scoping. If you don’t pass the o variable, or accept it in the sphereo module, it will lookup o from the scope in which the module is defined (global scope).
-Marius
Now this works:
Still, this is confusing to me!
$fn=32;
r=2;
o=1;
module sphereo(r=1,o=0){
sphere(r+o);
%cube(2*(r),true);
}
{sphereo(r,o);echo(o);}
translate([0,0,8])
assign(o=-o){sphereo(r,0);echo(o);}
2015-03-25 18:52 GMT+01:00 Marius Kintel marius@kintel.net:
On Mar 25, 2015, at 13:47 PM, Peter Falke <
stempeldergeschichte@googlemail.com> wrote:
Why is the upper sphere not smaller?
So the assign works for echo but not for the module call???
Variables use lexical scoping. If you don’t pass the o variable, or accept
it in the sphereo module, it will lookup o from the scope in which the
module is defined (global scope).
-Marius
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
stempeldergeschichte@googlemail.com karsten@rohrbach.de
P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.
Enjoy!
On Mar 25, 2015, at 13:57 PM, Peter Falke stempeldergeschichte@googlemail.com wrote:
Now this works:
Still, this is confusing to me!
translate([0,0,8])
assign(o=-o){sphereo(r,0);echo(o);}
It’s probably confusing because you pass the value 0 (zero) instead of the variable o.
-Marius
Oh - o - 0
2015-03-25 19:05 GMT+01:00 Marius Kintel marius@kintel.net:
On Mar 25, 2015, at 13:57 PM, Peter Falke <
stempeldergeschichte@googlemail.com> wrote:
Now this works:
Still, this is confusing to me!
translate([0,0,8])
assign(o=-o){sphereo(r,0);echo(o);}
It’s probably confusing because you pass the value 0 (zero) instead of the
variable o.
-Marius
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
stempeldergeschichte@googlemail.com karsten@rohrbach.de
P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.
Enjoy!
Unfortunately one can not assign values through to children.
Or, do you see a way to do that?
$fn=32;
r=2;
o=1;
module sphereo(r=1,o=0){
sphere(r+o);
%cube(2*(r),true);
}
{sphereo(r,o);echo(o);}
translate([0,0,8])
Kind(){sphereo(r,o);echo(o);}
module Kind(){
assign(o=-o)children();
}
Output:
ECHO: 1
ECHO: 1
2015-03-25 19:16 GMT+01:00 Peter Falke stempeldergeschichte@googlemail.com
:
Oh - o - 0
2015-03-25 19:05 GMT+01:00 Marius Kintel marius@kintel.net:
On Mar 25, 2015, at 13:57 PM, Peter Falke <
stempeldergeschichte@googlemail.com> wrote:
Now this works:
Still, this is confusing to me!
translate([0,0,8])
assign(o=-o){sphereo(r,0);echo(o);}
It’s probably confusing because you pass the value 0 (zero) instead of
the variable o.
-Marius
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
stempeldergeschichte@googlemail.com karsten@rohrbach.de
P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.
Enjoy!
--
stempeldergeschichte@googlemail.com karsten@rohrbach.de
P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.
Enjoy!
The only way to do it is with a $ variable as they have dynamic scope so
can be set in a parent and accessed in a child in same way as $fn works.
On 25 March 2015 at 18:43, Peter Falke stempeldergeschichte@googlemail.com
wrote:
Unfortunately one can not assign values through to children.
Or, do you see a way to do that?
$fn=32;
r=2;
o=1;
module sphereo(r=1,o=0){
sphere(r+o);
%cube(2*(r),true);
}
{sphereo(r,o);echo(o);}
translate([0,0,8])
Kind(){sphereo(r,o);echo(o);}
module Kind(){
assign(o=-o)children();
}
Output:
ECHO: 1
ECHO: 1
2015-03-25 19:16 GMT+01:00 Peter Falke <
stempeldergeschichte@googlemail.com>:
Oh - o - 0
2015-03-25 19:05 GMT+01:00 Marius Kintel marius@kintel.net:
On Mar 25, 2015, at 13:57 PM, Peter Falke <
stempeldergeschichte@googlemail.com> wrote:
Now this works:
Still, this is confusing to me!
translate([0,0,8])
assign(o=-o){sphereo(r,0);echo(o);}
It's probably confusing because you pass the value 0 (zero) instead of
the variable o.
-Marius
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
stempeldergeschichte@googlemail.com karsten@rohrbach.de
P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.
Enjoy!
--
stempeldergeschichte@googlemail.com karsten@rohrbach.de
P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.
Enjoy!
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Thanks, nop. Now it works:
$fn=32;
r=2;
$o=1;
module sphereo(r=1,o=0){
sphere(r+o);
// %cube(2*(r),true);
%sphere(r);
}
{sphereo(r,$o);echo($o);}
translate([0,0,8])
Kind(){sphereo(r,$o);echo($o);}
module Kind(){
assign($o=-$o)children();
}
Output:
ECHO: 1
ECHO: -1
2015-03-25 20:30 GMT+01:00 nop head nop.head@gmail.com:
The only way to do it is with a $ variable as they have dynamic scope so
can be set in a parent and accessed in a child in same way as $fn works.
On 25 March 2015 at 18:43, Peter Falke <
stempeldergeschichte@googlemail.com> wrote:
Unfortunately one can not assign values through to children.
Or, do you see a way to do that?
$fn=32;
r=2;
o=1;
module sphereo(r=1,o=0){
sphere(r+o);
%cube(2*(r),true);
}
{sphereo(r,o);echo(o);}
translate([0,0,8])
Kind(){sphereo(r,o);echo(o);}
module Kind(){
assign(o=-o)children();
}
Output:
ECHO: 1
ECHO: 1
2015-03-25 19:16 GMT+01:00 Peter Falke <
stempeldergeschichte@googlemail.com>:
Oh - o - 0
2015-03-25 19:05 GMT+01:00 Marius Kintel marius@kintel.net:
On Mar 25, 2015, at 13:57 PM, Peter Falke <
stempeldergeschichte@googlemail.com> wrote:
Now this works:
Still, this is confusing to me!
translate([0,0,8])
assign(o=-o){sphereo(r,0);echo(o);}
It’s probably confusing because you pass the value 0 (zero) instead of
the variable o.
-Marius
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
stempeldergeschichte@googlemail.com karsten@rohrbach.de
P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.
Enjoy!
--
stempeldergeschichte@googlemail.com karsten@rohrbach.de
P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.
Enjoy!
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
--
stempeldergeschichte@googlemail.com karsten@rohrbach.de
P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu
schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.
P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.
Enjoy!