discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

I don't understand the errors

BR
Bob Roos
Sat, Mar 12, 2022 1:51 AM

Hello Discuss,

I decided to try making a module since things will be repeating.  I get an error on every arithmetic operation.
for example:

WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24
WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24
WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24
WARNING: Unable to convert cube(size=[undef, undef, undef], ...) parameter to a number or a vec3 of numbers in file Spool Holder.scad, line 24

Thank you for any insights.

Bob Roos

Here is the program:

// spool holder
// Bob Roos
// March 11, 2022

$fn = 48;

// bearing
BOD = 22;
BID = 8;
BW = 7;

// material
FF = 1;      // fudge factor
FF2 = 2FF;
T = 1.5;
W = 2
T+BW+FF;
L = 1.5BOD;
H = BOD
.67 + T;
Sep = 105;

module BearingBlock (w,l,h,bod,bid,bw,ff){
translate([0,0,0])difference(){
minkowski(){
cube([w-ff,l-ff,h-ff],center=true);
sphere(ff);
}
translate([0,0,bod/4])rotate([0,90,0])cylinder(h=bw+ff,d=bod+ff2,center=true);
translate([0,0,bod/4])rotate([0,0,0])cube([w+2
ff,bod+2ff,h/2],center=true);
translate([0,0,bod/4])rotate([0,90,0])cylinder(h=w+ff,d=bid+2
ff,center=true);

}

}

module BlockSide (sep,w,l,h,bod,bid,bw,ff){
BearingBlock(w,l,bod,bid,bw,ff);
minkowski(){
translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true);
sphere(ff);
}
BearingBlock(w,l,bod,bid,bw,ff);
}

//BlockSide(Sep,W,L,H,BOD,BID,BW,FF);
BlockSide(sep=Sep,w=W,l=L,h=H,bod=BOD,bid=BID,bw=BW,ff=FF);

--
Best regards,
Bob                          mailto:roosbob@wybatap.com

Hello Discuss, I decided to try making a module since things will be repeating. I get an error on every arithmetic operation. for example: WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24 WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24 WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24 WARNING: Unable to convert cube(size=[undef, undef, undef], ...) parameter to a number or a vec3 of numbers in file Spool Holder.scad, line 24 Thank you for any insights. Bob Roos Here is the program: // spool holder // Bob Roos // March 11, 2022 $fn = 48; // bearing BOD = 22; BID = 8; BW = 7; // material FF = 1; // fudge factor FF2 = 2*FF; T = 1.5; W = 2*T+BW+FF; L = 1.5*BOD; H = BOD*.67 + T; Sep = 105; module BearingBlock (w,l,h,bod,bid,bw,ff){ translate([0,0,0])difference(){ minkowski(){ cube([w-ff,l-ff,h-ff],center=true); sphere(ff); } translate([0,0,bod/4])rotate([0,90,0])cylinder(h=bw+ff,d=bod+ff*2,center=true); translate([0,0,bod/4])rotate([0,0,0])cube([w+2*ff,bod+2*ff,h/2],center=true); translate([0,0,bod/4])rotate([0,90,0])cylinder(h=w+ff,d=bid+2*ff,center=true); } } module BlockSide (sep,w,l,h,bod,bid,bw,ff){ BearingBlock(w,l,bod,bid,bw,ff); minkowski(){ translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true); sphere(ff); } BearingBlock(w,l,bod,bid,bw,ff); } //BlockSide(Sep,W,L,H,BOD,BID,BW,FF); BlockSide(sep=Sep,w=W,l=L,h=H,bod=BOD,bid=BID,bw=BW,ff=FF); -- Best regards, Bob mailto:roosbob@wybatap.com
W
Whosawhatsis
Sat, Mar 12, 2022 1:57 AM

ff is undefined in BearingBlock() because you passed it one too few parameters in BlockSide(). You skipped  h.
On Mar 11, 2022, 17:52 -0800, Bob Roos roosbob@wybatap.com, wrote:

Hello Discuss,

I decided to try making a module since things will be repeating. I get an error on every arithmetic operation.
for example:

WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24
WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24
WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24
WARNING: Unable to convert cube(size=[undef, undef, undef], ...) parameter to a number or a vec3 of numbers in file Spool Holder.scad, line 24

Thank you for any insights.

Bob Roos

Here is the program:

// spool holder
// Bob Roos
// March 11, 2022

$fn = 48;

// bearing
BOD = 22;
BID = 8;
BW = 7;

// material
FF = 1; // fudge factor
FF2 = 2FF;
T = 1.5;
W = 2
T+BW+FF;
L = 1.5BOD;
H = BOD
.67 + T;
Sep = 105;

module BearingBlock (w,l,h,bod,bid,bw,ff){
translate([0,0,0])difference(){
minkowski(){
cube([w-ff,l-ff,h-ff],center=true);
sphere(ff);
}
translate([0,0,bod/4])rotate([0,90,0])cylinder(h=bw+ff,d=bod+ff2,center=true);
translate([0,0,bod/4])rotate([0,0,0])cube([w+2
ff,bod+2ff,h/2],center=true);
translate([0,0,bod/4])rotate([0,90,0])cylinder(h=w+ff,d=bid+2
ff,center=true);

}
}

module BlockSide (sep,w,l,h,bod,bid,bw,ff){
BearingBlock(w,l,bod,bid,bw,ff);
minkowski(){
translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true);
sphere(ff);
}
BearingBlock(w,l,bod,bid,bw,ff);
}

//BlockSide(Sep,W,L,H,BOD,BID,BW,FF);
BlockSide(sep=Sep,w=W,l=L,h=H,bod=BOD,bid=BID,bw=BW,ff=FF);

--
Best regards,
Bob mailto:roosbob@wybatap.com


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

ff is undefined in BearingBlock() because you passed it one too few parameters in BlockSide(). You skipped  h. On Mar 11, 2022, 17:52 -0800, Bob Roos <roosbob@wybatap.com>, wrote: > Hello Discuss, > > I decided to try making a module since things will be repeating. I get an error on every arithmetic operation. > for example: > > WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24 > WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24 > WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24 > WARNING: Unable to convert cube(size=[undef, undef, undef], ...) parameter to a number or a vec3 of numbers in file Spool Holder.scad, line 24 > > Thank you for any insights. > > Bob Roos > > Here is the program: > > // spool holder > // Bob Roos > // March 11, 2022 > > $fn = 48; > > // bearing > BOD = 22; > BID = 8; > BW = 7; > > // material > FF = 1; // fudge factor > FF2 = 2*FF; > T = 1.5; > W = 2*T+BW+FF; > L = 1.5*BOD; > H = BOD*.67 + T; > Sep = 105; > > module BearingBlock (w,l,h,bod,bid,bw,ff){ > translate([0,0,0])difference(){ > minkowski(){ > cube([w-ff,l-ff,h-ff],center=true); > sphere(ff); > } > translate([0,0,bod/4])rotate([0,90,0])cylinder(h=bw+ff,d=bod+ff*2,center=true); > translate([0,0,bod/4])rotate([0,0,0])cube([w+2*ff,bod+2*ff,h/2],center=true); > translate([0,0,bod/4])rotate([0,90,0])cylinder(h=w+ff,d=bid+2*ff,center=true); > > } > } > > module BlockSide (sep,w,l,h,bod,bid,bw,ff){ > BearingBlock(w,l,bod,bid,bw,ff); > minkowski(){ > translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true); > sphere(ff); > } > BearingBlock(w,l,bod,bid,bw,ff); > } > > //BlockSide(Sep,W,L,H,BOD,BID,BW,FF); > BlockSide(sep=Sep,w=W,l=L,h=H,bod=BOD,bid=BID,bw=BW,ff=FF); > > -- > Best regards, > Bob mailto:roosbob@wybatap.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Sat, Mar 12, 2022 2:19 AM

It would be nice if warnings like these came with stack backtraces,
including the arguments to each call, identified by name.

That would be very verbose, so it would also be nice if those stack
backtraces were also collapsed by default and could be expanded by
clicking on the warning.

And I realize that this is probably a pretty tricky thing to do in
what's basically a log viewer.  But it would still be nice.

Maybe in my copious free time...

It would be nice if warnings like these came with stack backtraces, including the arguments to each call, identified by name. That would be very verbose, so it would also be nice if those stack backtraces were also collapsed by default and could be expanded by clicking on the warning. And I realize that this is probably a pretty tricky thing to do in what's basically a log viewer.  But it would still be nice. Maybe in my copious free time...
FH
Father Horton
Sat, Mar 12, 2022 2:19 AM

A general debugging tip: In situations like this, use echo() to show the
values of the variables. That will tell you which one is undefined, and
then you can look to figure out why.

On Fri, Mar 11, 2022 at 8:03 PM Whosawhatsis whosawhatsis@gmail.com wrote:

ff is undefined in BearingBlock() because you passed it one too few
parameters in BlockSide(). You skipped  h.
On Mar 11, 2022, 17:52 -0800, Bob Roos roosbob@wybatap.com, wrote:

Hello Discuss,

I decided to try making a module since things will be repeating. I get an
error on every arithmetic operation.
for example:

WARNING: undefined operation (number - undefined) in file Spool
Holder.scad, line 24
WARNING: undefined operation (number - undefined) in file Spool
Holder.scad, line 24
WARNING: undefined operation (number - undefined) in file Spool
Holder.scad, line 24
WARNING: Unable to convert cube(size=[undef, undef, undef], ...) parameter
to a number or a vec3 of numbers in file Spool Holder.scad, line 24

Thank you for any insights.

Bob Roos

Here is the program:

// spool holder
// Bob Roos
// March 11, 2022

$fn = 48;

// bearing
BOD = 22;
BID = 8;
BW = 7;

// material
FF = 1; // fudge factor
FF2 = 2FF;
T = 1.5;
W = 2
T+BW+FF;
L = 1.5BOD;
H = BOD
.67 + T;
Sep = 105;

module BearingBlock (w,l,h,bod,bid,bw,ff){
translate([0,0,0])difference(){
minkowski(){
cube([w-ff,l-ff,h-ff],center=true);
sphere(ff);
}

translate([0,0,bod/4])rotate([0,90,0])cylinder(h=bw+ff,d=bod+ff*2,center=true);

translate([0,0,bod/4])rotate([0,0,0])cube([w+2ff,bod+2ff,h/2],center=true);

translate([0,0,bod/4])rotate([0,90,0])cylinder(h=w+ff,d=bid+2*ff,center=true);

}
}

module BlockSide (sep,w,l,h,bod,bid,bw,ff){
BearingBlock(w,l,bod,bid,bw,ff);
minkowski(){
translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true);
sphere(ff);
}
BearingBlock(w,l,bod,bid,bw,ff);
}

//BlockSide(Sep,W,L,H,BOD,BID,BW,FF);
BlockSide(sep=Sep,w=W,l=L,h=H,bod=BOD,bid=BID,bw=BW,ff=FF);

--
Best regards,
Bob mailto:roosbob@wybatap.com


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

A general debugging tip: In situations like this, use echo() to show the values of the variables. That will tell you which one is undefined, and then you can look to figure out why. On Fri, Mar 11, 2022 at 8:03 PM Whosawhatsis <whosawhatsis@gmail.com> wrote: > ff is undefined in BearingBlock() because you passed it one too few > parameters in BlockSide(). You skipped h. > On Mar 11, 2022, 17:52 -0800, Bob Roos <roosbob@wybatap.com>, wrote: > > Hello Discuss, > > I decided to try making a module since things will be repeating. I get an > error on every arithmetic operation. > for example: > > WARNING: undefined operation (number - undefined) in file Spool > Holder.scad, line 24 > WARNING: undefined operation (number - undefined) in file Spool > Holder.scad, line 24 > WARNING: undefined operation (number - undefined) in file Spool > Holder.scad, line 24 > WARNING: Unable to convert cube(size=[undef, undef, undef], ...) parameter > to a number or a vec3 of numbers in file Spool Holder.scad, line 24 > > Thank you for any insights. > > Bob Roos > > Here is the program: > > // spool holder > // Bob Roos > // March 11, 2022 > > $fn = 48; > > // bearing > BOD = 22; > BID = 8; > BW = 7; > > // material > FF = 1; // fudge factor > FF2 = 2*FF; > T = 1.5; > W = 2*T+BW+FF; > L = 1.5*BOD; > H = BOD*.67 + T; > Sep = 105; > > module BearingBlock (w,l,h,bod,bid,bw,ff){ > translate([0,0,0])difference(){ > minkowski(){ > cube([w-ff,l-ff,h-ff],center=true); > sphere(ff); > } > > translate([0,0,bod/4])rotate([0,90,0])cylinder(h=bw+ff,d=bod+ff*2,center=true); > > translate([0,0,bod/4])rotate([0,0,0])cube([w+2*ff,bod+2*ff,h/2],center=true); > > translate([0,0,bod/4])rotate([0,90,0])cylinder(h=w+ff,d=bid+2*ff,center=true); > > } > } > > module BlockSide (sep,w,l,h,bod,bid,bw,ff){ > BearingBlock(w,l,bod,bid,bw,ff); > minkowski(){ > translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true); > sphere(ff); > } > BearingBlock(w,l,bod,bid,bw,ff); > } > > //BlockSide(Sep,W,L,H,BOD,BID,BW,FF); > BlockSide(sep=Sep,w=W,l=L,h=H,bod=BOD,bid=BID,bw=BW,ff=FF); > > -- > Best regards, > Bob mailto:roosbob@wybatap.com > _______________________________________________ > 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 >
AM
Adrian Mariano
Sat, Mar 12, 2022 2:24 AM

This feature is already basically available.  I always run with "stop
on first warning" enabled.  This turns warnings into errors, and then
you get the stack backtrace.

On Fri, Mar 11, 2022 at 9:19 PM Jordan Brown
openscad@jordan.maileater.net wrote:

It would be nice if warnings like these came with stack backtraces, including the arguments to each call, identified by name.

That would be very verbose, so it would also be nice if those stack backtraces were also collapsed by default and could be expanded by clicking on the warning.

And I realize that this is probably a pretty tricky thing to do in what's basically a log viewer.  But it would still be nice.

Maybe in my copious free time...


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

This feature is already basically available. I always run with "stop on first warning" enabled. This turns warnings into errors, and then you get the stack backtrace. On Fri, Mar 11, 2022 at 9:19 PM Jordan Brown <openscad@jordan.maileater.net> wrote: > > It would be nice if warnings like these came with stack backtraces, including the arguments to each call, identified by name. > > That would be very verbose, so it would also be nice if those stack backtraces were also collapsed by default and could be expanded by clicking on the warning. > > And I realize that this is probably a pretty tricky thing to do in what's basically a log viewer. But it would still be nice. > > Maybe in my copious free time... > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
BR
Bob Roos
Sat, Mar 12, 2022 2:32 AM

Hi Whosawhatsis,

THANK YOU.
 
It was fine after I put in all 8 parameters and each call.  I wish is said something like parameter count mismatch.  I thought I checked all of them, but obviously not a very good check.
 
Bob Roos
   
Friday, March 11, 2022, 8:57:35 PM, you wrote:

ff is undefined in BearingBlock() because you passed it one too few parameters in BlockSide(). You skipped  h.
On Mar 11, 2022, 17:52 -0800, Bob Roos roosbob@wybatap.com, wrote:

Hello Discuss,

I decided to try making a module since things will be repeating. I get an error on every arithmetic operation.
for example:

WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24
WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24
WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24
WARNING: Unable to convert cube(size=[undef, undef, undef], ...) parameter to a number or a vec3 of numbers in file Spool Holder.scad, line 24

Thank you for any insights.

Bob Roos

-- 
have Fun,
 Bob                           mailto:roosbob@wybatap.com

Hi Whosawhatsis, THANK YOU.   It was fine after I put in all 8 parameters and each call.  I wish is said something like parameter count mismatch.  I thought I checked all of them, but obviously not a very good check.   Bob Roos     Friday, March 11, 2022, 8:57:35 PM, you wrote: > ff is undefined in BearingBlock() because you passed it one too few parameters in BlockSide(). You skipped  h. > On Mar 11, 2022, 17:52 -0800, Bob Roos <roosbob@wybatap.com>, wrote: >> Hello Discuss, >> I decided to try making a module since things will be repeating. I get an error on every arithmetic operation. >> for example: >> WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24 >> WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24 >> WARNING: undefined operation (number - undefined) in file Spool Holder.scad, line 24 >> WARNING: Unable to convert cube(size=[undef, undef, undef], ...) parameter to a number or a vec3 of numbers in file Spool Holder.scad, line 24 >> Thank you for any insights. >> Bob Roos --  have Fun,  Bob                           mailto:roosbob@wybatap.com
JB
Jordan Brown
Sat, Mar 12, 2022 2:41 AM

I agree with whosawhatsis on the cause of the problem, but thought it
might be helpful to describe the thought processes that led to that
conclusion, and suggest a way to make the program more bug-resistant.

First, in the OpenSCAD UI things would be a little easier, because it's
immediately obvious which line is the problematic line 24.  And in the
message we can count to find the line.

But even without that, we want to look for a case where we have one
number subtracted from another, and for extra credit note that it
happens three times and that there's also a cube() involved.

There are two places in the program where there's subtraction: 

cube([w-ff,l-ff,h-ff],center=true);

and

translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true);

I looked at the first one first and found the problem, so I didn't look
at the second, but note that although they both involve a cube(), only
the first involves three subtractions.

Looking at the first one:

cube([w-ff,l-ff,h-ff],center=true);

the warning said "number - undefined", so it's the "ff" that's
undefined.  (Three times.)

Where did "ff" come from?  It's an argument to BearingBlock():

module BearingBlock (w,l,h,bod,bid,bw,ff){

So what called BearingBlock()?  It's called twice below. Both of the
calls look like this:

BearingBlock(w,l,bod,bid,bw,ff);

That call passes the arguments by position, so we have to compare it to
the module, and that's where we find that the call passes six arguments
but the module expects seven... and, lo and behold, "ff" is the last
argument expected and so gets "undefined".

So that's how (or at least one way) to find the problem.  (Another might
involve liberally sprinkling "echo()" calls throughout to see what the
values of the various variables are.)

But could the program have been written so that the problem would be
more obvious?  Maybe.  I would personally never use more than maybe two
positional arguments.  Past about two, I find it unpleasantly hard to
keep track of which argument is which.  If we were calling
BearingBlock() with numbers, instead of with variables with obvious
names, so that the call was

BearingBlock(2*T+BW+FF, 1.5*BOD, BOD*.67 + T, 22, 8, 7, 1);

would it be at all obvious which values were which arguments?  Sure, you
can tell by comparing the call to the declaration, and that's the way
you have to do it in many programming languages, but in OpenSCAD we can
make it a lot more obvious:

BearingBlock(w=2*T+BW+FF, l=1.5*BOD, h=BOD*.67 + T,
    bod=22, bid=8, bw=7, ff=1);

You might still leave "h" out, but at least then you'd have problems
with "h" instead of having problems with the apparently-unrelated "ff".

(Side note::  In JavaScript, you can use an object to simulate named
arguments, and that's the way that I tend to write JavaScript functions
that take more than a couple of arguments.  In C you're kind of stuck,
but I will sometimes pass a structure and use C99 named initializers to
set up the structure.)

I agree with whosawhatsis on the cause of the problem, but thought it might be helpful to describe the thought processes that led to that conclusion, and suggest a way to make the program more bug-resistant. First, in the OpenSCAD UI things would be a little easier, because it's immediately obvious which line is the problematic line 24.  And in the message we can count to find the line. But even without that, we want to look for a case where we have one number subtracted from another, and for extra credit note that it happens three times and that there's also a cube() involved. There are two places in the program where there's subtraction:  cube([w-ff,l-ff,h-ff],center=true); and translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true); I looked at the first one first and found the problem, so I didn't look at the second, but note that although they both involve a cube(), only the first involves three subtractions. Looking at the first one: cube([w-ff,l-ff,h-ff],center=true); the warning said "number - undefined", so it's the "ff" that's undefined.  (Three times.) Where did "ff" come from?  It's an argument to BearingBlock(): module BearingBlock (w,l,h,bod,bid,bw,ff){ So what called BearingBlock()?  It's called twice below. Both of the calls look like this: BearingBlock(w,l,bod,bid,bw,ff); That call passes the arguments by position, so we have to compare it to the module, and that's where we find that the call passes six arguments but the module expects seven... and, lo and behold, "ff" is the last argument expected and so gets "undefined". So that's how (or at least one way) to find the problem.  (Another might involve liberally sprinkling "echo()" calls throughout to see what the values of the various variables are.) But could the program have been written so that the problem would be more obvious?  Maybe.  I would personally never use more than maybe two positional arguments.  Past about two, I find it unpleasantly hard to keep track of which argument is which.  If we were calling BearingBlock() with numbers, instead of with variables with obvious names, so that the call was BearingBlock(2*T+BW+FF, 1.5*BOD, BOD*.67 + T, 22, 8, 7, 1); would it be at all obvious which values were which arguments?  Sure, you can tell by comparing the call to the declaration, and that's the way you have to do it in many programming languages, but in OpenSCAD we can make it a lot more obvious: BearingBlock(w=2*T+BW+FF, l=1.5*BOD, h=BOD*.67 + T, bod=22, bid=8, bw=7, ff=1); You might still leave "h" out, but at least then you'd have problems with "h" instead of having problems with the apparently-unrelated "ff". (Side note::  In JavaScript, you can use an object to simulate named arguments, and that's the way that I tend to write JavaScript functions that take more than a couple of arguments.  In C you're kind of stuck, but I will sometimes pass a structure and use C99 named initializers to set up the structure.)
JB
Jordan Brown
Sat, Mar 12, 2022 2:49 AM

On 3/11/2022 6:32 PM, Bob Roos wrote:

I wish is said something like parameter count mismatch.

Yeah, that's kind of the difference between "strict" languages and
looser ones.  Strict languages say "if you don't pass exactly the right
thing it's an error", while looser languages like JavaScript silently
populate missing arguments with "undefined" and ignore extra arguments. 
OpenSCAD is kind of half strict; it complains about extra arguments but
populates missing arguments.  That lets you have optional arguments
(that you can detect using is_undef()), but at the expense of not
detecting bugs like this.

I'm a "strict" kind of guy; I think that the "usability" win from
letting these constructs pass is dwarfed by the debugability win from
detecting these bugs.  If you want to have a language with optional
arguments, have an explicit defaulting mechanism (even if the default
you specify is to set the variable to "undefined").  A missing argument
with no default should be an error.

On 3/11/2022 6:32 PM, Bob Roos wrote: > I wish is said something like parameter count mismatch. Yeah, that's kind of the difference between "strict" languages and looser ones.  Strict languages say "if you don't pass exactly the right thing it's an error", while looser languages like JavaScript silently populate missing arguments with "undefined" and ignore extra arguments.  OpenSCAD is kind of half strict; it complains about extra arguments but populates missing arguments.  That lets you have optional arguments (that you can detect using is_undef()), but at the expense of not detecting bugs like this. I'm a "strict" kind of guy; I think that the "usability" win from letting these constructs pass is dwarfed by the debugability win from detecting these bugs.  If you want to have a language with optional arguments, have an explicit defaulting mechanism (even if the default you specify is to set the variable to "undefined").  A missing argument with no default should be an error.
GH
gene heskett
Sat, Mar 12, 2022 3:45 AM

On Friday, 11 March 2022 20:51:54 EST Bob Roos wrote:

And OpenSCAD's variables are case sensitive, you are mixing case.

Hello Discuss,

I decided to try making a module since things will be repeating.  I
get an error on every arithmetic operation. for example:

WARNING: undefined operation (number - undefined) in file Spool
Holder.scad, line 24 WARNING: undefined operation (number - undefined)
in file Spool Holder.scad, line 24 WARNING: undefined operation
(number - undefined) in file Spool Holder.scad, line 24 WARNING:
Unable to convert cube(size=[undef, undef, undef], ...) parameter to a
number or a vec3 of numbers in file Spool Holder.scad, line 24

Thank you for any insights.

Bob Roos

Here is the program:

// spool holder
// Bob Roos
// March 11, 2022

$fn = 48;

// bearing
BOD = 22;
BID = 8;
BW = 7;

// material
FF = 1;      // fudge factor
FF2 = 2FF;
T = 1.5;
W = 2
T+BW+FF;
L = 1.5BOD;
H = BOD
.67 + T;
Sep = 105;

module BearingBlock (w,l,h,bod,bid,bw,ff){
translate([0,0,0])difference(){
minkowski(){
cube([w-ff,l-ff,h-ff],center=true);
sphere(ff);
}

translate([0,0,bod/4])rotate([0,90,0])cylinder(h=bw+ff,d=bod+ff2,cent
er=true);
translate([0,0,bod/4])rotate([0,0,0])cube([w+2
ff,bod+2ff,h/2],center
=true);
translate([0,0,bod/4])rotate([0,90,0])cylinder(h=w+ff,d=bid+2
ff,cente
r=true);

 }

}

module BlockSide (sep,w,l,h,bod,bid,bw,ff){
BearingBlock(w,l,bod,bid,bw,ff);
minkowski(){
translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true);
sphere(ff);
}
BearingBlock(w,l,bod,bid,bw,ff);
}

//BlockSide(Sep,W,L,H,BOD,BID,BW,FF);
BlockSide(sep=Sep,w=W,l=L,h=H,bod=BOD,bid=BID,bw=BW,ff=FF);

--
Best regards,
Bob                          mailto:roosbob@wybatap.com


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

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, 1940)
If we desire respect for the law, we must first make the law respectable.

  • Louis D. Brandeis
On Friday, 11 March 2022 20:51:54 EST Bob Roos wrote: And OpenSCAD's variables are case sensitive, you are mixing case. > Hello Discuss, > > I decided to try making a module since things will be repeating. I > get an error on every arithmetic operation. for example: > > WARNING: undefined operation (number - undefined) in file Spool > Holder.scad, line 24 WARNING: undefined operation (number - undefined) > in file Spool Holder.scad, line 24 WARNING: undefined operation > (number - undefined) in file Spool Holder.scad, line 24 WARNING: > Unable to convert cube(size=[undef, undef, undef], ...) parameter to a > number or a vec3 of numbers in file Spool Holder.scad, line 24 > > Thank you for any insights. > > Bob Roos > > Here is the program: > > // spool holder > // Bob Roos > // March 11, 2022 > > $fn = 48; > > // bearing > BOD = 22; > BID = 8; > BW = 7; > > // material > FF = 1; // fudge factor > FF2 = 2*FF; > T = 1.5; > W = 2*T+BW+FF; > L = 1.5*BOD; > H = BOD*.67 + T; > Sep = 105; > > module BearingBlock (w,l,h,bod,bid,bw,ff){ > translate([0,0,0])difference(){ > minkowski(){ > cube([w-ff,l-ff,h-ff],center=true); > sphere(ff); > } > > translate([0,0,bod/4])rotate([0,90,0])cylinder(h=bw+ff,d=bod+ff*2,cent > er=true); > translate([0,0,bod/4])rotate([0,0,0])cube([w+2*ff,bod+2*ff,h/2],center > =true); > translate([0,0,bod/4])rotate([0,90,0])cylinder(h=w+ff,d=bid+2*ff,cente > r=true); > > } > } > > module BlockSide (sep,w,l,h,bod,bid,bw,ff){ > BearingBlock(w,l,bod,bid,bw,ff); > minkowski(){ > translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true); > sphere(ff); > } > BearingBlock(w,l,bod,bid,bw,ff); > } > > //BlockSide(Sep,W,L,H,BOD,BID,BW,FF); > BlockSide(sep=Sep,w=W,l=L,h=H,bod=BOD,bid=BID,bw=BW,ff=FF); > > -- > Best regards, > Bob mailto:roosbob@wybatap.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > . 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, 1940) If we desire respect for the law, we must first make the law respectable. - Louis D. Brandeis
BR
Bob Roos
Sat, Mar 12, 2022 4:01 AM

Hi gene,

Thanks yo everyone for your help with this.  I learned a lot.

Yes, I knew they were case sensitive and I was using an uppercase 1st letter to indicate a value that I would specify and all lower case to indicate a parameter.

Part of my problem came from moving the code from a working program with repeated blocks of the similar code to one using modules.

I will do better next time.

Thanks again,
Bob

Friday, March 11, 2022, 10:45:50 PM, you wrote:

On Friday, 11 March 2022 20:51:54 EST Bob Roos wrote:

And OpenSCAD's variables are case sensitive, you are mixing case.

Hello Discuss,

I decided to try making a module since things will be repeating.  I
get an error on every arithmetic operation. for example:

WARNING: undefined operation (number - undefined) in file Spool
Holder.scad, line 24 WARNING: undefined operation (number - undefined)
in file Spool Holder.scad, line 24 WARNING: undefined operation
(number - undefined) in file Spool Holder.scad, line 24 WARNING:
Unable to convert cube(size=[undef, undef, undef], ...) parameter to a
number or a vec3 of numbers in file Spool Holder.scad, line 24

Thank you for any insights.

Bob Roos

Here is the program:

// spool holder
// Bob Roos
// March 11, 2022

$fn = 48;

// bearing
BOD = 22;
BID = 8;
BW = 7;

// material
FF = 1;      // fudge factor
FF2 = 2FF;
T = 1.5;
W = 2
T+BW+FF;
L = 1.5BOD;
H = BOD
.67 + T;
Sep = 105;

module BearingBlock (w,l,h,bod,bid,bw,ff){
translate([0,0,0])difference(){
minkowski(){
cube([w-ff,l-ff,h-ff],center=true);
sphere(ff);
}

translate([0,0,bod/4])rotate([0,90,0])cylinder(h=bw+ff,d=bod+ff2,cent
er=true);
translate([0,0,bod/4])rotate([0,0,0])cube([w+2
ff,bod+2ff,h/2],center
=true);
translate([0,0,bod/4])rotate([0,90,0])cylinder(h=w+ff,d=bid+2
ff,cente
r=true);

 }

}

module BlockSide (sep,w,l,h,bod,bid,bw,ff){
BearingBlock(w,l,bod,bid,bw,ff);
minkowski(){
translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true);
sphere(ff);
}
BearingBlock(w,l,bod,bid,bw,ff);
}

//BlockSide(Sep,W,L,H,BOD,BID,BW,FF);
BlockSide(sep=Sep,w=W,l=L,h=H,bod=BOD,bid=BID,bw=BW,ff=FF);

--
Best regards,
Bob                          mailto:roosbob@wybatap.com


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

Cheers, Gene Heskett.

--
have Fun,
Bob                          mailto:roosbob@wybatap.com

Hi gene, Thanks yo everyone for your help with this. I learned a lot. Yes, I knew they were case sensitive and I was using an uppercase 1st letter to indicate a value that I would specify and all lower case to indicate a parameter. Part of my problem came from moving the code from a working program with repeated blocks of the similar code to one using modules. I will do better next time. Thanks again, Bob Friday, March 11, 2022, 10:45:50 PM, you wrote: > On Friday, 11 March 2022 20:51:54 EST Bob Roos wrote: > And OpenSCAD's variables are case sensitive, you are mixing case. >> Hello Discuss, >> >> I decided to try making a module since things will be repeating. I >> get an error on every arithmetic operation. for example: >> >> WARNING: undefined operation (number - undefined) in file Spool >> Holder.scad, line 24 WARNING: undefined operation (number - undefined) >> in file Spool Holder.scad, line 24 WARNING: undefined operation >> (number - undefined) in file Spool Holder.scad, line 24 WARNING: >> Unable to convert cube(size=[undef, undef, undef], ...) parameter to a >> number or a vec3 of numbers in file Spool Holder.scad, line 24 >> >> Thank you for any insights. >> >> Bob Roos >> >> Here is the program: >> >> // spool holder >> // Bob Roos >> // March 11, 2022 >> >> $fn = 48; >> >> // bearing >> BOD = 22; >> BID = 8; >> BW = 7; >> >> // material >> FF = 1; // fudge factor >> FF2 = 2*FF; >> T = 1.5; >> W = 2*T+BW+FF; >> L = 1.5*BOD; >> H = BOD*.67 + T; >> Sep = 105; >> >> module BearingBlock (w,l,h,bod,bid,bw,ff){ >> translate([0,0,0])difference(){ >> minkowski(){ >> cube([w-ff,l-ff,h-ff],center=true); >> sphere(ff); >> } >> >> translate([0,0,bod/4])rotate([0,90,0])cylinder(h=bw+ff,d=bod+ff*2,cent >> er=true); >> translate([0,0,bod/4])rotate([0,0,0])cube([w+2*ff,bod+2*ff,h/2],center >> =true); >> translate([0,0,bod/4])rotate([0,90,0])cylinder(h=w+ff,d=bid+2*ff,cente >> r=true); >> >> } >> } >> >> module BlockSide (sep,w,l,h,bod,bid,bw,ff){ >> BearingBlock(w,l,bod,bid,bw,ff); >> minkowski(){ >> translate([0,sep/2,-h/2+1])cube([w,sep-bod,ff],center=true); >> sphere(ff); >> } >> BearingBlock(w,l,bod,bid,bw,ff); >> } >> >> //BlockSide(Sep,W,L,H,BOD,BID,BW,FF); >> BlockSide(sep=Sep,w=W,l=L,h=H,bod=BOD,bid=BID,bw=BW,ff=FF); >> >> -- >> Best regards, >> Bob mailto:roosbob@wybatap.com >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> . > Cheers, Gene Heskett. -- have Fun, Bob mailto:roosbob@wybatap.com