Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Contributor
cjacobson
Posts: 35
Registered: ‎01-10-2003
Message 1 of 12 (146 Views)

; error: bad argument type: numberp: nil

146 Views, 11 Replies
12-08-2002 11:20 PM
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
*Turvill, Paul
Message 2 of 12 (146 Views)

Re: ; error: bad argument type: numberp: nil

12-09-2002 12:40 AM 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
*Tanzillo, Tony
Message 3 of 12 (146 Views)

Re: ; error: bad argument type: numberp: nil

12-09-2002 12:40 AM 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
>
Active Contributor
cjacobson
Posts: 35
Registered: ‎01-10-2003
Message 4 of 12 (146 Views)

Re:

12-09-2002 12:50 AM 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
Active Contributor
cjacobson
Posts: 35
Registered: ‎01-10-2003
Message 5 of 12 (146 Views)

Re:

12-09-2002 12:53 AM in reply to: cjacobson
By the way Tony, you helped me on this one when I first started on it in 2000.

Wayne
*Uhden, John
Message 6 of 12 (146 Views)

Re: ; error: bad argument type: numberp: nil

12-09-2002 11:13 AM 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
>
Active Contributor
cjacobson
Posts: 35
Registered: ‎01-10-2003
Message 7 of 12 (146 Views)

Re:

12-09-2002 11:40 PM 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
*Tobey, Peter
Message 8 of 12 (146 Views)

Re:

12-10-2002 12:39 AM 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
Active Contributor
cjacobson
Posts: 35
Registered: ‎01-10-2003
Message 9 of 12 (146 Views)

Re:

12-10-2002 03:12 AM 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
*Esquivel, Luis
Message 10 of 12 (146 Views)

Re:

12-10-2002 03:32 AM 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)))
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!