### Author Topic: ? syntax error in AutoLisp? error: bad argument type: numberp: nil  (Read 961 times)

0 Members and 1 Guest are viewing this topic.

#### +X^N

• Guest
##### ? syntax error in AutoLisp? error: bad argument type: numberp: nil
« on: September 11, 2016, 06:15:24 PM »
Hello ,
I am learning AutoLisp ;
get error: bad argument type: numberp: nil
.
Am seeking to make new UCS at an angle .
here is the code :
Code: [Select]
`;   Define local FUNCTIONs(dfnc dist_half(/ x_refl y_refl)  ;; UCS distance X to Point     (/ (sqrt(+ (expt x_refl 2.0) (expt y_refl 2.0))) 2.0) ;; SquareRoot of X^2 + Y^2 = Hypotenuse)(dfnc c:distz-hgt(/ fo_hgt_z reflhgtz)  ;; UCS distance Y to Point (- fo_hgt_z reflhgtz));; TESTing 20160911;  Create UCS  "ReflNN_1"  tipped towards  Point       (setq point2 '(dist_half(20.8125 20.8125) distz-hgt(0.625) 0) );;  use FUNCTION of distance : from UCS 'horizonatally' to the    (command "_.ucs" "_3p" (0 0 0) point2 (0 0 1)) ;; UCS Origin , Positive X Axis , Positive Y Orientation _ the Refel Center , Tip the UCS towards THE Point ,  UCS Positive Z direction unit ; still need to 'flip  '   (command "_.ucs" "_na" "_s" "Refl25_1_TEST");; end_TESTing 20160911`any help is _pre_appreciated
« Last Edit: September 11, 2016, 06:45:23 PM by +X^N »

#### snownut2

• Swamp Rat
• Posts: 934
##### Re: ? syntax error in AutoLisp? error: bad argument type: numberp: nil
« Reply #1 on: September 11, 2016, 08:51:00 PM »
At first glance it looks like;
(0 0 0) is not a list you need to make it '(0 0 0) same with the list after point2.

#### +X^N

• Guest
##### Re: ? syntax error in AutoLisp? error: bad argument type: numberp: nil
« Reply #2 on: September 11, 2016, 09:51:54 PM »
Calculating the numbers by hand and using in the setq works :
Code - Auto/Visual Lisp: [Select]
1. ;; TESTing 20160911
2. ;  Create UCS 'tipped' towards Point "ReflNN_1"
3.
4.     (setq point1 '(0 0 0) point2 '(-14.716659883445020351592573286307 62.375 0) point3 '(0 0 1)) ;;  from UCS 'horizonatally' to the
5.
6.     (command "_.ucs" "_3p" point1 point2 point3) ;; UCS Origin , Positive X Axis , Positive Y Orientation _ the Refel , Tip the UCS towards THE  Point ,  UCS Positive Z direction unit
7.         (command "_.ucs" "_na" "_s" "Refl25_1_TEST")
8.
9. ;; end_TESTing 20160911
10.
However , would like to have calculation in the setq  _ as in the first post .
« Last Edit: September 13, 2016, 01:10:14 AM by +X^N »

#### ribarm

• Water Moccasin
• Posts: 2126
• Marko Ribar, architect
##### Re: ? syntax error in AutoLisp? error: bad argument type: numberp: nil
« Reply #3 on: September 12, 2016, 01:13:05 AM »
Just guessing, but according to your later numerical interpretation, maybe it should look like this :

Code: [Select]
`;   Define local FUNCTIONs(defun dist_half ( x_refl y_refl )  ;; UCS distance X to Point  (/ (sqrt (+ (expt x_refl 2.0) (expt y_refl 2.0))) -2.0) ;; SquareRoot of X^2 + Y^2 = Hypotenuse)(defun distz-hgt ( fo_hgt_z reflhgtz )  ;; UCS distance Y to Point  (- fo_hgt_z reflhgtz));; TESTing 20160911;  Create UCS  "ReflNN_1"  tipped towards  Point      (setq point2 (list (dist_half 20.8125 20.8125) (distz-hgt 63.0 0.625) 0.0));;  use FUNCTION of distance : from UCS 'horizonatally' to the    (command "_.ucs" "_3p" "_non" '(0.0 0.0 0.0) "_non" point2 "_non" '(0.0 0.0 1.0)) ;; UCS Origin , Positive X Axis , Positive Y Orientation _ the Refel Center , Tip the UCS towards THE Point ,  UCS Positive Z direction unit ; still need to 'flip  '   (command "_.ucs" "_na" "_s" "Refl25_1_TEST");; end_TESTing 20160911`
And I would set point2 variable at the end to nil or localize point2 variable inside main function that haven't yet been defined...

HTH, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

#### +X^N

• Guest
##### Re: ? syntax error in AutoLisp? error: bad argument type: numberp: nil
« Reply #4 on: September 12, 2016, 09:52:25 PM »
Just guessing, but according to your later numerical interpretation, maybe it should look like this :

Code - Auto/Visual Lisp: [Select]
1. ;   Define local FUNCTIONs
2. (defun dist_half ( x_refl y_refl )  ;; UCS distance X to Point
3.   (/ (sqrt (+ (expt x_refl 2.0) (expt y_refl 2.0))) -2.0) ;; SquareRoot of X^2 + Y^2 = Hypotenuse
4. )
5.
6. (defun distz-hgt ( fo_hgt_z reflhgtz )  ;; UCS distance Y to Point
7.   (- fo_hgt_z reflhgtz)
8. )
9.
10. ;; TESTing 20160911
11. ;  Create UCS  "ReflNN_1"  tipped towards  Point
12.
13.    (setq point2 (list (dist_half 20.8125 20.8125) (distz-hgt 63.0 0.625) 0.0));;  use FUNCTION of distance : from UCS 'horizonatally' to the
14.
15.    (command "_.ucs" "_3p" "_non" '(0.0 0.0 0.0) "_non" point2 "_non" '(0.0 0.0 1.0)) ;; UCS Origin , Positive X Axis , Positive Y Orientation _ the Refel Center , Tip the UCS towards THE Point ,  UCS Positive Z direction unit ; still need to 'flip  '
16.    (command "_.ucs" "_na" "_s" "Refl25_1_TEST")
17.
18. ;; end_TESTing 20160911
19.

And I would set point2 variable at the end to nil or localize point2 variable inside main function that haven't yet been defined...

HTH, M.R.
Thank you _ am just learning - it (mostly) was the need for list (which allows evaluative statements ) ,
rather than ' (which seems to act as a literal ) .
.
My trig was incorrect ;
I need to halve the angle not a horiz. dist . (I still need the horiz dist though) .
« Last Edit: September 13, 2016, 01:10:53 AM by +X^N »

#### +X^N

• Guest
##### Re: ? syntax error in AutoLisp? error: bad argument type: numberp: nil
« Reply #5 on: September 13, 2016, 01:00:27 AM »
Quote from: BIGAL;669329
Interesting did a quick copy and paste to see what was happening.

Command: (setq point2 '((/ (sqrt(+ (expt 20.8125 2.0) (expt 20.8125 2.0))) 2.0) (- 63.0 0.625) 0))
((/ (SQRT (+ (EXPT 20.8125 2.0) (EXPT 20.8125 2.0))) 2.0) (- 63.0 0.625) 0)

Command: !point2
((/ (SQRT (+ (EXPT 20.8125 2.0) (EXPT 20.8125 2.0))) 2.0) (- 63.0 0.625) 0)
I gather that the ' acts like the AutoLISP function quote
in that it acts as a literal , or prvents the statement following  evaluation ;
this is sometimes what we need .
Otherwise use the
Code - Auto/Visual Lisp: [Select]
1. (setq point2 (list (/ (sqrt(+ (expt 20.8125 2.0) (expt 20.8125 2.0))) 2.0) (- 63.0 0.625) 0))
(see below)

Quote from: BKT;669273
Just got back from Lee Mac's amazing site, and the explanation for use of the apostrophe and the quote function is described in depth.

http://www.lee-mac.com/quote.html

Thanks again, Lee Mac!

Learning is fun ctional .
« Last Edit: September 13, 2016, 01:12:07 AM by +X^N »