Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

; error: bad argument type: numberp: nil

11 REPLIES 11
Reply
Message 1 of 12
cjacobson
354 Views, 11 Replies

; error: bad argument type: numberp: nil

I have suddenly run into this error. I have two routines that run off variables asigned at the begining.

The prompt >Use the decimal sizes for the SCREW DIAMETER
#4=.112 #6=.138 #8=.164< assigning SIZE to the decimals , .112 etc. The .138 will work but the .112 & .164 will come up with the error.

Other factors,
(setq drill-sizes
'(
(0.112 . 0.089);#4
(0.138 . 0.1094);#6
(0.164 . 0.136);#8
....

(setq cbdrill-sizes
'(
(0.112 . 0.142);#4
(0.138 . 0.168);#6
(0.164 . 0.194);#8
....

(setq cbore-sizes
'(
(0.112 . 0.213);#4
(0.138 . 0.256);#6
(0.164 . 0.300);#8
....

Remember that the #6 sizes work but the #4 & #8 get the error.

Thanks Wayne Bork
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: cjacobson

The only discrepancy I can see is that you've specified four decimal places
for #6 in drill-sizes, while #4 and #8 show only three. I can't see why this
should make a difference, given common coding methods, but ...

Perhaps if we could see your code ...
___

"cjacobson" wrote in message
news:f12ae12.-1@WebX.maYIadrTaRb...
> I have suddenly run into this error. I have two routines that run off
variables asigned at the begining.
> The prompt >Use the decimal sizes for the SCREW DIAMETER
> #4=.112 #6=.138 #8=.164< assigning SIZE to the decimals , .112 etc. The
.138 will work but the .112 & .164 will come up with the error.
>
> Other factors,
> (setq drill-sizes
> '(
> (0.112 . 0.089);#4
> (0.138 . 0.1094);#6
> (0.164 . 0.136);#8
Message 3 of 12
Anonymous
in reply to: cjacobson

The error message indicates that a built-in
function that is expecting to be passed a number
is getting nil instead.

"cjacobson" wrote in message news:f12ae12.-1@WebX.maYIadrTaRb...
> I have suddenly run into this error. I have two routines that run off variables asigned at the begining.
> The prompt >Use the decimal sizes for the SCREW DIAMETER
> #4=.112 #6=.138 #8=.164< assigning SIZE to the decimals , .112 etc. The .138 will work but the .112 & .164 will come
up with the error.
>
> Other factors,
> (setq drill-sizes
> '(
> (0.112 . 0.089);#4
> (0.138 . 0.1094);#6
> (0.164 . 0.136);#8
> ....
>
> (setq cbdrill-sizes
> '(
> (0.112 . 0.142);#4
> (0.138 . 0.168);#6
> (0.164 . 0.194);#8
> ....
>
> (setq cbore-sizes
> '(
> (0.112 . 0.213);#4
> (0.138 . 0.256);#6
> (0.164 . 0.300);#8
> ....
>
> Remember that the #6 sizes work but the #4 & #8 get the error.
>
> Thanks Wayne Bork
>
Message 4 of 12
cjacobson
in reply to: cjacobson

ok, Tony,

>The error message indicates that a built-in
>function that is expecting to be passed a number
>is getting nil instead.

& Paul,

I changed to 4-place , still the error. The the built-in function Tony, the program did not change except the addition of the three sizes, #4,6 & 8. #6 works but the other don't.

I have attached the file

Thanks

Wayne Bork
Message 5 of 12
cjacobson
in reply to: cjacobson

By the way Tony, you helped me on this one when I first started on it in 2000.

Wayne
Message 6 of 12
Anonymous
in reply to: cjacobson

Apparently, (getreal) isn't cooperating the way we might expect (using
R15.06)...

Command: (while (setq SIZE (getreal "\nEnter the SCREW diameter: "))(prin1
(assoc size drill-sizes)))
Enter the SCREW diameter: .112
nil
Enter the SCREW diameter: 0.112
nil
Enter the SCREW diameter: 0.1120
(0.112 . 0.089)
Enter the SCREW diameter: .164
nil
Enter the SCREW diameter: .1640
(0.164 . 0.136)

Perhaps a dialog with a preset list of strings and associated data would work
better.

--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ

"cjacobson" wrote in message
news:f12ae12.-1@WebX.maYIadrTaRb...
> I have suddenly run into this error. I have two routines that run off
variables asigned at the begining.
> The prompt >Use the decimal sizes for the SCREW DIAMETER
> #4=.112 #6=.138 #8=.164< assigning SIZE to the decimals , .112 etc. The .138
will work but the .112 & .164 will come up with the error.
>
> Other factors,
> (setq drill-sizes
> '(
> (0.112 . 0.089);#4
> (0.138 . 0.1094);#6
> (0.164 . 0.136);#8
> ....
>
> (setq cbdrill-sizes
> '(
> (0.112 . 0.142);#4
> (0.138 . 0.168);#6
> (0.164 . 0.194);#8
> ....
>
> (setq cbore-sizes
> '(
> (0.112 . 0.213);#4
> (0.138 . 0.256);#6
> (0.164 . 0.300);#8
> ....
>
> Remember that the #6 sizes work but the #4 & #8 get the error.
>
> Thanks Wayne Bork
>
Message 7 of 12
cjacobson
in reply to: cjacobson

>Perhaps a dialog with a preset list of strings and >associated data would work better.

I have others that works with the dialog box. Just never got around to that with this routine.

I still get back the original question tho, Why would the #6 work and not the #4 or #8? The information is the same except the sizes.

>a preset list of strings and associated data<

are you talking about the following...

;;;set variables for SHCS TAP DRILL
(setq drill-sizes
'(
(0.112 . 0.0890);#4
(0.138 . 0.1094);#6
(0.164 . 0.1360);#8
(0.190 . 0.1495);#10
(0.250 . 0.201)
(0.3125 . 0.261)
(0.375 . 0.316)
(0.500 . 0.4219)
(0.625 . 0.5312)
(0.750 . 0.6562)
(1.000 . 0.875)
(1.250 . 1.1094)
(1.500 . 1.3281)
)
)
(setq drill (cdr (assoc size drill-sizes)))

and putting it in a dialog?

Thanks

Wayne Bork
Message 8 of 12
Anonymous
in reply to: cjacobson

Wayne;

I think the problem here is that the (assoc) function hides an equality
test for the (car) of the target item. Due to the way real numbers are
handled, absolute equality between reals is an unreliable test. As John
suggested, making your 'key' values strings & forcing the user to select
from a discrete list would be one solution. Another would be to use a
"fuzzy" test of some sort, in place of the simple (assoc) mechanism.

-peter
Message 9 of 12
cjacobson
in reply to: cjacobson

This can not be right. For you see, this program Shcs-sv.lsp was written with ten sizes from a #10 to 1-1/2 SHCS's back in 2000. I have not had a problem with it until I put in the #4,6 & 8. The #6 draws the screw without a problem. The #4 & 8 has the problem. WHY would that be since every thing being equal except the sizes. I just checked the sizes again and they are correct according to the screw chart I have. I am the first one to admit that I am a novice at the more complicated routines and the use of the better syntax, but this routine does work for all the other screws. It has been awhile since I have written a dialog based program, but that would be a better solution I admit.

Thanks
Message 10 of 12
Anonymous
in reply to: cjacobson

I made a fix to your lisp, take a look.

by using: (setq cbore (cdr (assoc (distof (rtos size 2 8)) cbore-sizes)))
Message 11 of 12
cjacobson
in reply to: cjacobson

Luis, you are a life saver. Thanks is small words. The program works NOW for the #4 & #8 screws. Thanks to all who helped.

Wayne Bork

Standing in awe to those who are GURU's in the world of Autolisp.
Message 12 of 12
Anonymous
in reply to: cjacobson

😉

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost