discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

I need to clarify scope better

GH
Gene Heskett
Sat, Jul 24, 2021 5:54 PM

That var names within a module's {} are known only inside that module,
so its a different var within different module, even if the same name is
used in another, different module?

I would like to have all this thing fairly parametric in that changing
a "global var" before any modules are defined, changes the var for every
module that uses it, but with 3d printers having a mind of their own, I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking at
the moon?

Thanks all.

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.

That var names within a module's {} are known only inside that module, so its a different var within different module, even if the same name is used in another, different module? I would like to have all this thing fairly parametric in that changing a "global var" before any modules are defined, changes the var for every module that uses it, but with 3d printers having a mind of their own, I find I need some fudge1, fudge2 etc vars defined inside a module, to fine tune sizes for a good fit. So is my first sentence above unconditionally true, or am I barking at the moon? Thanks all. Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page <http://geneslinuxbox.net:6309/gene>
NH
nop head
Sat, Jul 24, 2021 6:14 PM

The only way a variable set in one module can be seen in another is if you
prefix it with $ and then it is visible in modules called by the module
that sets it.

Or you can have global variables seen in all modules in the same file by
defining them at file scope.

I 3D print all the time with no fudge factors. I simply have my 3D printers
set up accurately and only ever use one wall.

On Sat, 24 Jul 2021 at 18:54, Gene Heskett gheskett@shentel.net wrote:

That var names within a module's {} are known only inside that module,
so its a different var within different module, even if the same name is
used in another, different module?

I would like to have all this thing fairly parametric in that changing
a "global var" before any modules are defined, changes the var for every
module that uses it, but with 3d printers having a mind of their own, I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking at
the moon?

Thanks all.

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.


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

The only way a variable set in one module can be seen in another is if you prefix it with $ and then it is visible in modules called by the module that sets it. Or you can have global variables seen in all modules in the same file by defining them at file scope. I 3D print all the time with no fudge factors. I simply have my 3D printers set up accurately and only ever use one wall. On Sat, 24 Jul 2021 at 18:54, Gene Heskett <gheskett@shentel.net> wrote: > That var names within a module's {} are known only inside that module, > so its a different var within different module, even if the same name is > used in another, different module? > > I would like to have all this thing fairly parametric in that changing > a "global var" before any modules are defined, changes the var for every > module that uses it, but with 3d printers having a mind of their own, I > find I need some fudge1, fudge2 etc vars defined inside a module, to > fine tune sizes for a good fit. > > So is my first sentence above unconditionally true, or am I barking at > the moon? > > Thanks all. > > Cheers, Gene Heskett > -- > "There are four boxes to be used in defense of liberty: > soap, ballot, jury, and ammo. Please use in that order." > -Ed Howdershelt (Author) > If we desire respect for the law, we must first make the law respectable. > - Louis D. Brandeis > Genes Web page <http://geneslinuxbox.net:6309/gene> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
FH
Father Horton
Sat, Jul 24, 2021 6:18 PM

Can child modules see variables in the parent's scope?

On Sat, Jul 24, 2021 at 1:15 PM nop head nop.head@gmail.com wrote:

The only way a variable set in one module can be seen in another is if you
prefix it with $ and then it is visible in modules called by the module
that sets it.

Or you can have global variables seen in all modules in the same file by
defining them at file scope.

I 3D print all the time with no fudge factors. I simply have my 3D
printers set up accurately and only ever use one wall.

On Sat, 24 Jul 2021 at 18:54, Gene Heskett gheskett@shentel.net wrote:

That var names within a module's {} are known only inside that module,
so its a different var within different module, even if the same name is
used in another, different module?

I would like to have all this thing fairly parametric in that changing
a "global var" before any modules are defined, changes the var for every
module that uses it, but with 3d printers having a mind of their own, I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking at
the moon?

Thanks all.

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.


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


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

Can child modules see variables in the parent's scope? On Sat, Jul 24, 2021 at 1:15 PM nop head <nop.head@gmail.com> wrote: > The only way a variable set in one module can be seen in another is if you > prefix it with $ and then it is visible in modules called by the module > that sets it. > > Or you can have global variables seen in all modules in the same file by > defining them at file scope. > > I 3D print all the time with no fudge factors. I simply have my 3D > printers set up accurately and only ever use one wall. > > On Sat, 24 Jul 2021 at 18:54, Gene Heskett <gheskett@shentel.net> wrote: > >> That var names within a module's {} are known only inside that module, >> so its a different var within different module, even if the same name is >> used in another, different module? >> >> I would like to have all this thing fairly parametric in that changing >> a "global var" before any modules are defined, changes the var for every >> module that uses it, but with 3d printers having a mind of their own, I >> find I need some fudge1, fudge2 etc vars defined inside a module, to >> fine tune sizes for a good fit. >> >> So is my first sentence above unconditionally true, or am I barking at >> the moon? >> >> Thanks all. >> >> Cheers, Gene Heskett >> -- >> "There are four boxes to be used in defense of liberty: >> soap, ballot, jury, and ammo. Please use in that order." >> -Ed Howdershelt (Author) >> If we desire respect for the law, we must first make the law respectable. >> - Louis D. Brandeis >> Genes Web page <http://geneslinuxbox.net:6309/gene> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
NH
nop head
Sat, Jul 24, 2021 6:22 PM

Only if the variable name starts with a $.

On Sat, 24 Jul 2021 at 19:18, Father Horton fatherhorton@gmail.com wrote:

Can child modules see variables in the parent's scope?

On Sat, Jul 24, 2021 at 1:15 PM nop head nop.head@gmail.com wrote:

The only way a variable set in one module can be seen in another is if
you prefix it with $ and then it is visible in modules called by the module
that sets it.

Or you can have global variables seen in all modules in the same file by
defining them at file scope.

I 3D print all the time with no fudge factors. I simply have my 3D
printers set up accurately and only ever use one wall.

On Sat, 24 Jul 2021 at 18:54, Gene Heskett gheskett@shentel.net wrote:

That var names within a module's {} are known only inside that module,
so its a different var within different module, even if the same name is
used in another, different module?

I would like to have all this thing fairly parametric in that changing
a "global var" before any modules are defined, changes the var for every
module that uses it, but with 3d printers having a mind of their own, I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking at
the moon?

Thanks all.

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.


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


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


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

Only if the variable name starts with a $. On Sat, 24 Jul 2021 at 19:18, Father Horton <fatherhorton@gmail.com> wrote: > Can child modules see variables in the parent's scope? > > On Sat, Jul 24, 2021 at 1:15 PM nop head <nop.head@gmail.com> wrote: > >> The only way a variable set in one module can be seen in another is if >> you prefix it with $ and then it is visible in modules called by the module >> that sets it. >> >> Or you can have global variables seen in all modules in the same file by >> defining them at file scope. >> >> I 3D print all the time with no fudge factors. I simply have my 3D >> printers set up accurately and only ever use one wall. >> >> On Sat, 24 Jul 2021 at 18:54, Gene Heskett <gheskett@shentel.net> wrote: >> >>> That var names within a module's {} are known only inside that module, >>> so its a different var within different module, even if the same name is >>> used in another, different module? >>> >>> I would like to have all this thing fairly parametric in that changing >>> a "global var" before any modules are defined, changes the var for every >>> module that uses it, but with 3d printers having a mind of their own, I >>> find I need some fudge1, fudge2 etc vars defined inside a module, to >>> fine tune sizes for a good fit. >>> >>> So is my first sentence above unconditionally true, or am I barking at >>> the moon? >>> >>> Thanks all. >>> >>> Cheers, Gene Heskett >>> -- >>> "There are four boxes to be used in defense of liberty: >>> soap, ballot, jury, and ammo. Please use in that order." >>> -Ed Howdershelt (Author) >>> If we desire respect for the law, we must first make the law respectable. >>> - Louis D. Brandeis >>> Genes Web page <http://geneslinuxbox.net:6309/gene> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
FH
Father Horton
Sat, Jul 24, 2021 7:51 PM

I thought I'd try it:

i = 1;
module test() {
i = 2;
module subtest() {
echo("subtest ", i);
};
echo("test ", i);
subtest();
};

test();

produces

ECHO: "test ", 2

ECHO: "subtest ", 2


I might have been using "child" in a different sense than you took it, but
the inner module does see the value in scope in its parent module.

On Sat, Jul 24, 2021 at 1:23 PM nop head nop.head@gmail.com wrote:

Only if the variable name starts with a $.

On Sat, 24 Jul 2021 at 19:18, Father Horton fatherhorton@gmail.com
wrote:

Can child modules see variables in the parent's scope?

On Sat, Jul 24, 2021 at 1:15 PM nop head nop.head@gmail.com wrote:

The only way a variable set in one module can be seen in another is if
you prefix it with $ and then it is visible in modules called by the module
that sets it.

Or you can have global variables seen in all modules in the same file by
defining them at file scope.

I 3D print all the time with no fudge factors. I simply have my 3D
printers set up accurately and only ever use one wall.

On Sat, 24 Jul 2021 at 18:54, Gene Heskett gheskett@shentel.net wrote:

That var names within a module's {} are known only inside that module,
so its a different var within different module, even if the same name
is
used in another, different module?

I would like to have all this thing fairly parametric in that changing
a "global var" before any modules are defined, changes the var for
every
module that uses it, but with 3d printers having a mind of their own, I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking at
the moon?

Thanks all.

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law
respectable.


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


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


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


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

I thought I'd try it: i = 1; module test() { i = 2; module subtest() { echo("subtest ", i); }; echo("test ", i); subtest(); }; test(); produces ECHO: "test ", 2 ECHO: "subtest ", 2 ----- I might have been using "child" in a different sense than you took it, but the inner module does see the value in scope in its parent module. On Sat, Jul 24, 2021 at 1:23 PM nop head <nop.head@gmail.com> wrote: > Only if the variable name starts with a $. > > On Sat, 24 Jul 2021 at 19:18, Father Horton <fatherhorton@gmail.com> > wrote: > >> Can child modules see variables in the parent's scope? >> >> On Sat, Jul 24, 2021 at 1:15 PM nop head <nop.head@gmail.com> wrote: >> >>> The only way a variable set in one module can be seen in another is if >>> you prefix it with $ and then it is visible in modules called by the module >>> that sets it. >>> >>> Or you can have global variables seen in all modules in the same file by >>> defining them at file scope. >>> >>> I 3D print all the time with no fudge factors. I simply have my 3D >>> printers set up accurately and only ever use one wall. >>> >>> On Sat, 24 Jul 2021 at 18:54, Gene Heskett <gheskett@shentel.net> wrote: >>> >>>> That var names within a module's {} are known only inside that module, >>>> so its a different var within different module, even if the same name >>>> is >>>> used in another, different module? >>>> >>>> I would like to have all this thing fairly parametric in that changing >>>> a "global var" before any modules are defined, changes the var for >>>> every >>>> module that uses it, but with 3d printers having a mind of their own, I >>>> find I need some fudge1, fudge2 etc vars defined inside a module, to >>>> fine tune sizes for a good fit. >>>> >>>> So is my first sentence above unconditionally true, or am I barking at >>>> the moon? >>>> >>>> Thanks all. >>>> >>>> Cheers, Gene Heskett >>>> -- >>>> "There are four boxes to be used in defense of liberty: >>>> soap, ballot, jury, and ammo. Please use in that order." >>>> -Ed Howdershelt (Author) >>>> If we desire respect for the law, we must first make the law >>>> respectable. >>>> - Louis D. Brandeis >>>> Genes Web page <http://geneslinuxbox.net:6309/gene> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
NH
nop head
Sat, Jul 24, 2021 7:55 PM

Yes but that is a nested module, not a child invoked by children ().

On Sat, 24 Jul 2021, 20:52 Father Horton, fatherhorton@gmail.com wrote:

I thought I'd try it:

i = 1;
module test() {
i = 2;
module subtest() {
echo("subtest ", i);
};
echo("test ", i);
subtest();
};

test();

produces

ECHO: "test ", 2

ECHO: "subtest ", 2


I might have been using "child" in a different sense than you took it, but
the inner module does see the value in scope in its parent module.

On Sat, Jul 24, 2021 at 1:23 PM nop head nop.head@gmail.com wrote:

Only if the variable name starts with a $.

On Sat, 24 Jul 2021 at 19:18, Father Horton fatherhorton@gmail.com
wrote:

Can child modules see variables in the parent's scope?

On Sat, Jul 24, 2021 at 1:15 PM nop head nop.head@gmail.com wrote:

The only way a variable set in one module can be seen in another is if
you prefix it with $ and then it is visible in modules called by the module
that sets it.

Or you can have global variables seen in all modules in the same file
by defining them at file scope.

I 3D print all the time with no fudge factors. I simply have my 3D
printers set up accurately and only ever use one wall.

On Sat, 24 Jul 2021 at 18:54, Gene Heskett gheskett@shentel.net
wrote:

That var names within a module's {} are known only inside that module,
so its a different var within different module, even if the same name
is
used in another, different module?

I would like to have all this thing fairly parametric in that changing
a "global var" before any modules are defined, changes the var for
every
module that uses it, but with 3d printers having a mind of their own,
I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking at
the moon?

Thanks all.

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law
respectable.


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


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


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


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


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

Yes but that is a nested module, not a child invoked by children (). On Sat, 24 Jul 2021, 20:52 Father Horton, <fatherhorton@gmail.com> wrote: > I thought I'd try it: > > i = 1; > module test() { > i = 2; > module subtest() { > echo("subtest ", i); > }; > echo("test ", i); > subtest(); > }; > > test(); > > produces > > ECHO: "test ", 2 > > ECHO: "subtest ", 2 > > > ----- > > > I might have been using "child" in a different sense than you took it, but > the inner module does see the value in scope in its parent module. > > > > On Sat, Jul 24, 2021 at 1:23 PM nop head <nop.head@gmail.com> wrote: > >> Only if the variable name starts with a $. >> >> On Sat, 24 Jul 2021 at 19:18, Father Horton <fatherhorton@gmail.com> >> wrote: >> >>> Can child modules see variables in the parent's scope? >>> >>> On Sat, Jul 24, 2021 at 1:15 PM nop head <nop.head@gmail.com> wrote: >>> >>>> The only way a variable set in one module can be seen in another is if >>>> you prefix it with $ and then it is visible in modules called by the module >>>> that sets it. >>>> >>>> Or you can have global variables seen in all modules in the same file >>>> by defining them at file scope. >>>> >>>> I 3D print all the time with no fudge factors. I simply have my 3D >>>> printers set up accurately and only ever use one wall. >>>> >>>> On Sat, 24 Jul 2021 at 18:54, Gene Heskett <gheskett@shentel.net> >>>> wrote: >>>> >>>>> That var names within a module's {} are known only inside that module, >>>>> so its a different var within different module, even if the same name >>>>> is >>>>> used in another, different module? >>>>> >>>>> I would like to have all this thing fairly parametric in that changing >>>>> a "global var" before any modules are defined, changes the var for >>>>> every >>>>> module that uses it, but with 3d printers having a mind of their own, >>>>> I >>>>> find I need some fudge1, fudge2 etc vars defined inside a module, to >>>>> fine tune sizes for a good fit. >>>>> >>>>> So is my first sentence above unconditionally true, or am I barking at >>>>> the moon? >>>>> >>>>> Thanks all. >>>>> >>>>> Cheers, Gene Heskett >>>>> -- >>>>> "There are four boxes to be used in defense of liberty: >>>>> soap, ballot, jury, and ammo. Please use in that order." >>>>> -Ed Howdershelt (Author) >>>>> If we desire respect for the law, we must first make the law >>>>> respectable. >>>>> - Louis D. Brandeis >>>>> Genes Web page <http://geneslinuxbox.net:6309/gene> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
FH
Father Horton
Sat, Jul 24, 2021 8:25 PM

Like I thought, I was using the term "child" in a non-standard way. Thank
you for clarifying.

On Sat, Jul 24, 2021 at 2:56 PM nop head nop.head@gmail.com wrote:

Yes but that is a nested module, not a child invoked by children ().

On Sat, 24 Jul 2021, 20:52 Father Horton, fatherhorton@gmail.com wrote:

I thought I'd try it:

i = 1;
module test() {
i = 2;
module subtest() {
echo("subtest ", i);
};
echo("test ", i);
subtest();
};

test();

produces

ECHO: "test ", 2

ECHO: "subtest ", 2


I might have been using "child" in a different sense than you took it,
but the inner module does see the value in scope in its parent module.

On Sat, Jul 24, 2021 at 1:23 PM nop head nop.head@gmail.com wrote:

Only if the variable name starts with a $.

On Sat, 24 Jul 2021 at 19:18, Father Horton fatherhorton@gmail.com
wrote:

Can child modules see variables in the parent's scope?

On Sat, Jul 24, 2021 at 1:15 PM nop head nop.head@gmail.com wrote:

The only way a variable set in one module can be seen in another is if
you prefix it with $ and then it is visible in modules called by the module
that sets it.

Or you can have global variables seen in all modules in the same file
by defining them at file scope.

I 3D print all the time with no fudge factors. I simply have my 3D
printers set up accurately and only ever use one wall.

On Sat, 24 Jul 2021 at 18:54, Gene Heskett gheskett@shentel.net
wrote:

That var names within a module's {} are known only inside that module,
so its a different var within different module, even if the same name
is
used in another, different module?

I would like to have all this thing fairly parametric in that
changing
a "global var" before any modules are defined, changes the var for
every
module that uses it, but with 3d printers having a mind of their own,
I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking
at
the moon?

Thanks all.

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law
respectable.


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


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


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


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


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


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

Like I thought, I was using the term "child" in a non-standard way. Thank you for clarifying. On Sat, Jul 24, 2021 at 2:56 PM nop head <nop.head@gmail.com> wrote: > Yes but that is a nested module, not a child invoked by children (). > > On Sat, 24 Jul 2021, 20:52 Father Horton, <fatherhorton@gmail.com> wrote: > >> I thought I'd try it: >> >> i = 1; >> module test() { >> i = 2; >> module subtest() { >> echo("subtest ", i); >> }; >> echo("test ", i); >> subtest(); >> }; >> >> test(); >> >> produces >> >> ECHO: "test ", 2 >> >> ECHO: "subtest ", 2 >> >> >> ----- >> >> >> I might have been using "child" in a different sense than you took it, >> but the inner module does see the value in scope in its parent module. >> >> >> >> On Sat, Jul 24, 2021 at 1:23 PM nop head <nop.head@gmail.com> wrote: >> >>> Only if the variable name starts with a $. >>> >>> On Sat, 24 Jul 2021 at 19:18, Father Horton <fatherhorton@gmail.com> >>> wrote: >>> >>>> Can child modules see variables in the parent's scope? >>>> >>>> On Sat, Jul 24, 2021 at 1:15 PM nop head <nop.head@gmail.com> wrote: >>>> >>>>> The only way a variable set in one module can be seen in another is if >>>>> you prefix it with $ and then it is visible in modules called by the module >>>>> that sets it. >>>>> >>>>> Or you can have global variables seen in all modules in the same file >>>>> by defining them at file scope. >>>>> >>>>> I 3D print all the time with no fudge factors. I simply have my 3D >>>>> printers set up accurately and only ever use one wall. >>>>> >>>>> On Sat, 24 Jul 2021 at 18:54, Gene Heskett <gheskett@shentel.net> >>>>> wrote: >>>>> >>>>>> That var names within a module's {} are known only inside that module, >>>>>> so its a different var within different module, even if the same name >>>>>> is >>>>>> used in another, different module? >>>>>> >>>>>> I would like to have all this thing fairly parametric in that >>>>>> changing >>>>>> a "global var" before any modules are defined, changes the var for >>>>>> every >>>>>> module that uses it, but with 3d printers having a mind of their own, >>>>>> I >>>>>> find I need some fudge1, fudge2 etc vars defined inside a module, to >>>>>> fine tune sizes for a good fit. >>>>>> >>>>>> So is my first sentence above unconditionally true, or am I barking >>>>>> at >>>>>> the moon? >>>>>> >>>>>> Thanks all. >>>>>> >>>>>> Cheers, Gene Heskett >>>>>> -- >>>>>> "There are four boxes to be used in defense of liberty: >>>>>> soap, ballot, jury, and ammo. Please use in that order." >>>>>> -Ed Howdershelt (Author) >>>>>> If we desire respect for the law, we must first make the law >>>>>> respectable. >>>>>> - Louis D. Brandeis >>>>>> Genes Web page <http://geneslinuxbox.net:6309/gene> >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
NH
nop head
Sat, Jul 24, 2021 10:12 PM

Normal variables have lexical scope, which means they can be seen in the
current block and any nested block. $ variables have dynamic scope, which
means they can be seen in any module or function called from the current
block.

On Sat, 24 Jul 2021 at 21:26, Father Horton fatherhorton@gmail.com wrote:

Like I thought, I was using the term "child" in a non-standard way. Thank
you for clarifying.

On Sat, Jul 24, 2021 at 2:56 PM nop head nop.head@gmail.com wrote:

Yes but that is a nested module, not a child invoked by children ().

On Sat, 24 Jul 2021, 20:52 Father Horton, fatherhorton@gmail.com wrote:

I thought I'd try it:

i = 1;
module test() {
i = 2;
module subtest() {
echo("subtest ", i);
};
echo("test ", i);
subtest();
};

test();

produces

ECHO: "test ", 2

ECHO: "subtest ", 2


I might have been using "child" in a different sense than you took it,
but the inner module does see the value in scope in its parent module.

On Sat, Jul 24, 2021 at 1:23 PM nop head nop.head@gmail.com wrote:

Only if the variable name starts with a $.

On Sat, 24 Jul 2021 at 19:18, Father Horton fatherhorton@gmail.com
wrote:

Can child modules see variables in the parent's scope?

On Sat, Jul 24, 2021 at 1:15 PM nop head nop.head@gmail.com wrote:

The only way a variable set in one module can be seen in another is
if you prefix it with $ and then it is visible in modules called by the
module that sets it.

Or you can have global variables seen in all modules in the same file
by defining them at file scope.

I 3D print all the time with no fudge factors. I simply have my 3D
printers set up accurately and only ever use one wall.

On Sat, 24 Jul 2021 at 18:54, Gene Heskett gheskett@shentel.net
wrote:

That var names within a module's {} are known only inside that
module,
so its a different var within different module, even if the same
name is
used in another, different module?

I would like to have all this thing fairly parametric in that
changing
a "global var" before any modules are defined, changes the var for
every
module that uses it, but with 3d printers having a mind of their
own, I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking
at
the moon?

Thanks all.

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law
respectable.


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


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


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


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


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


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


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

Normal variables have lexical scope, which means they can be seen in the current block and any nested block. $ variables have dynamic scope, which means they can be seen in any module or function called from the current block. On Sat, 24 Jul 2021 at 21:26, Father Horton <fatherhorton@gmail.com> wrote: > Like I thought, I was using the term "child" in a non-standard way. Thank > you for clarifying. > > On Sat, Jul 24, 2021 at 2:56 PM nop head <nop.head@gmail.com> wrote: > >> Yes but that is a nested module, not a child invoked by children (). >> >> On Sat, 24 Jul 2021, 20:52 Father Horton, <fatherhorton@gmail.com> wrote: >> >>> I thought I'd try it: >>> >>> i = 1; >>> module test() { >>> i = 2; >>> module subtest() { >>> echo("subtest ", i); >>> }; >>> echo("test ", i); >>> subtest(); >>> }; >>> >>> test(); >>> >>> produces >>> >>> ECHO: "test ", 2 >>> >>> ECHO: "subtest ", 2 >>> >>> >>> ----- >>> >>> >>> I might have been using "child" in a different sense than you took it, >>> but the inner module does see the value in scope in its parent module. >>> >>> >>> >>> On Sat, Jul 24, 2021 at 1:23 PM nop head <nop.head@gmail.com> wrote: >>> >>>> Only if the variable name starts with a $. >>>> >>>> On Sat, 24 Jul 2021 at 19:18, Father Horton <fatherhorton@gmail.com> >>>> wrote: >>>> >>>>> Can child modules see variables in the parent's scope? >>>>> >>>>> On Sat, Jul 24, 2021 at 1:15 PM nop head <nop.head@gmail.com> wrote: >>>>> >>>>>> The only way a variable set in one module can be seen in another is >>>>>> if you prefix it with $ and then it is visible in modules called by the >>>>>> module that sets it. >>>>>> >>>>>> Or you can have global variables seen in all modules in the same file >>>>>> by defining them at file scope. >>>>>> >>>>>> I 3D print all the time with no fudge factors. I simply have my 3D >>>>>> printers set up accurately and only ever use one wall. >>>>>> >>>>>> On Sat, 24 Jul 2021 at 18:54, Gene Heskett <gheskett@shentel.net> >>>>>> wrote: >>>>>> >>>>>>> That var names within a module's {} are known only inside that >>>>>>> module, >>>>>>> so its a different var within different module, even if the same >>>>>>> name is >>>>>>> used in another, different module? >>>>>>> >>>>>>> I would like to have all this thing fairly parametric in that >>>>>>> changing >>>>>>> a "global var" before any modules are defined, changes the var for >>>>>>> every >>>>>>> module that uses it, but with 3d printers having a mind of their >>>>>>> own, I >>>>>>> find I need some fudge1, fudge2 etc vars defined inside a module, to >>>>>>> fine tune sizes for a good fit. >>>>>>> >>>>>>> So is my first sentence above unconditionally true, or am I barking >>>>>>> at >>>>>>> the moon? >>>>>>> >>>>>>> Thanks all. >>>>>>> >>>>>>> Cheers, Gene Heskett >>>>>>> -- >>>>>>> "There are four boxes to be used in defense of liberty: >>>>>>> soap, ballot, jury, and ammo. Please use in that order." >>>>>>> -Ed Howdershelt (Author) >>>>>>> If we desire respect for the law, we must first make the law >>>>>>> respectable. >>>>>>> - Louis D. Brandeis >>>>>>> Genes Web page <http://geneslinuxbox.net:6309/gene> >>>>>>> _______________________________________________ >>>>>>> OpenSCAD mailing list >>>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>>> >>>>>> _______________________________________________ >>>>>> OpenSCAD mailing list >>>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>>> >>>>> _______________________________________________ >>>>> OpenSCAD mailing list >>>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>>> >>>> _______________________________________________ >>>> OpenSCAD mailing list >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RW
Ray West
Sat, Jul 24, 2021 10:46 PM

Hi Gene,

There are a few things to think about. Forgetting the 3d printing side
of things, you can't fit a two inch diameter cylinder inside a two inch
diameter hole, say, no matter how you try, even if both are rounder than
a round thing. The hole has to be bigger, or the cylinder smaller, or
the hole a tiny bit bigger, and the cylinder a tiny bit smaller. As you
know, traditionally in most engineering hard materials, then the
differences are taken care of in the specified manufacturer's
tolerances. For woodwork and modern glues, it is not so fussy. I reckon
3d printing is somewhere between the two, at least for the largely
flexible plastics that are commonly used, and the relatively crude diy
3d printers. Couple with that, the way in which openscad, stl, and
whatever slicer and firmware tries to make a round hole (or cylinder),
as you have found, you will never, for example get a two inch diameter
print to fit into a two inch diameter hole, or anywhere near, using
metal fitting tolerances.

If you are talking about both pieces being something you are 3d
printing, then I would decide on the hole diameter, and use a fudge
factor to reduce that diameter for the cylinder. If the cylinder is a
bit too big, it is probably easier to reduce that, rather than
increasing the hole diameter. You will need different factors for
different sized holes, tightness of fit, materials etc. It will take
some iterations to get the right values for your fits. If you were
having, say a metal bearing to fit in a hole in the 3d printed plastic,
then I would use a fudge factor on the hole diameter, it's not so easy
to file down the bearing.

I would keep the fudge factors outside of the modules, possibly one for
each cylinder. I've put a bit of code below, to emphasize an inherent
source of a bad fit

diam1 = 2;
fudge1 = 1.01;
fudge2 = 1.02; //whatever

$fn=6;  //obviously change this

module hole(d){
    difference(){
        cube(10,true);
        translate ([0,0,-20])cylinder(60,d=d);
    }
}

module  peg1(d,f1){
     cylinder (50,d=d-f1);
}

      hole(diam1);
      peg1(diam1,fudge1);

    translate ([20,20,0])  peg1(4,fudge2);
    translate ([20,20,0]) hole(4);

On 24/07/2021 18:54, Gene Heskett wrote:

That var names within a module's {} are known only inside that module,
so its a different var within different module, even if the same name is
used in another, different module?

I would like to have all this thing fairly parametric in that changing
a "global var" before any modules are defined, changes the var for every
module that uses it, but with 3d printers having a mind of their own, I
find I need some fudge1, fudge2 etc vars defined inside a module, to
fine tune sizes for a good fit.

So is my first sentence above unconditionally true, or am I barking at
the moon?

Thanks all.

Cheers, Gene Heskett

Hi Gene, There are a few things to think about. Forgetting the 3d printing side of things, you can't fit a two inch diameter cylinder inside a two inch diameter hole, say, no matter how you try, even if both are rounder than a round thing. The hole has to be bigger, or the cylinder smaller, or the hole a tiny bit bigger, and the cylinder a tiny bit smaller. As you know, traditionally in most engineering hard materials, then the differences are taken care of in the specified manufacturer's tolerances. For woodwork and modern glues, it is not so fussy. I reckon 3d printing is somewhere between the two, at least for the largely flexible plastics that are commonly used, and the relatively crude diy 3d printers. Couple with that, the way in which openscad, stl, and whatever slicer and firmware tries to make a round hole (or cylinder), as you have found, you will never, for example get a two inch diameter print to fit into a two inch diameter hole, or anywhere near, using metal fitting tolerances. If you are talking about both pieces being something you are 3d printing, then I would decide on the hole diameter, and use a fudge factor to reduce that diameter for the cylinder. If the cylinder is a bit too big, it is probably easier to reduce that, rather than increasing the hole diameter. You will need different factors for different sized holes, tightness of fit, materials etc. It will take some iterations to get the right values for your fits. If you were having, say a metal bearing to fit in a hole in the 3d printed plastic, then I would use a fudge factor on the hole diameter, it's not so easy to file down the bearing. I would keep the fudge factors outside of the modules, possibly one for each cylinder. I've put a bit of code below, to emphasize an inherent source of a bad fit diam1 = 2; fudge1 = 1.01; fudge2 = 1.02; //whatever $fn=6;  //obviously change this module hole(d){     difference(){         cube(10,true);         translate ([0,0,-20])cylinder(60,d=d);     } } module  peg1(d,f1){      cylinder (50,d=d-f1); }       hole(diam1);       peg1(diam1,fudge1);     translate ([20,20,0])  peg1(4,fudge2);     translate ([20,20,0]) hole(4); On 24/07/2021 18:54, Gene Heskett wrote: > That var names within a module's {} are known only inside that module, > so its a different var within different module, even if the same name is > used in another, different module? > > I would like to have all this thing fairly parametric in that changing > a "global var" before any modules are defined, changes the var for every > module that uses it, but with 3d printers having a mind of their own, I > find I need some fudge1, fudge2 etc vars defined inside a module, to > fine tune sizes for a good fit. > > So is my first sentence above unconditionally true, or am I barking at > the moon? > > Thanks all. > > Cheers, Gene Heskett
GH
Gene Heskett
Sat, Jul 24, 2021 11:12 PM

On Saturday 24 July 2021 18:12:22 nop head wrote:

Normal variables have lexical scope, which means they can be seen in
the current block and any nested block. $ variables have dynamic
scope, which means they can be seen in any module or function called
from the current block.

Eggxactly as my testing seems to confirm. thank you all.

My 6th printer is a prusa MK3S kit and its calibration seems to put a
line at the center of the .4mm nozzle, meaning if something needs to fit
inside of another part, but parts need to adjusted by .2mm in order to
put them together.  So thats the basis for using a .2 or -.2 fudge to
get good fittings.

[...]

Cheers, Gene Heskett

"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.

On Saturday 24 July 2021 18:12:22 nop head wrote: > Normal variables have lexical scope, which means they can be seen in > the current block and any nested block. $ variables have dynamic > scope, which means they can be seen in any module or function called > from the current block. > Eggxactly as my testing seems to confirm. thank you all. My 6th printer is a prusa MK3S kit and its calibration seems to put a line at the center of the .4mm nozzle, meaning if something needs to fit inside of another part, but parts need to adjusted by .2mm in order to put them together. So thats the basis for using a .2 or -.2 fudge to get good fittings. [...] Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis Genes Web page <http://geneslinuxbox.net:6309/gene>