No function definition: =nil error.

No function definition: =nil error.

moreira.jose
Participant Participant
791 Views
5 Replies
Message 1 of 6

No function definition: =nil error.

moreira.jose
Participant
Participant

Hello, im making a small lisp to generate some 3d models, but i keep getting an error about not having "function definition".

Dont know why this is happening, if someone could point me in the right direction, please.

 

here is my code so far:

(defun c:cabinet ()
(setq 2dpoints (getvar "osmode"))
(setq 3dpoints (getvar "3dosmode"))
(setvar "osmode" 0)
(setvar "3dosmode" 0)
(setq pt1 (getpoint "what is the cabinet corner point: "))
(If (= nil
(setq wide (getreal "what is the cabinet lenght (in x):
")))
(setq wide 1.9))
(if (=nil
(setq depth(getreal "what is the cabinet depth (in y): ")))
(setq depth 0.32))
(If (= nil
(setq height (getreal "what is the cabinet height (exterior in z): ")))
(setq height 0.45))
(If (= nil
(setq thick (getreal "what is the material section: ")))
(setq thick 0.02))
(model)
(model2)
(setvar "osmode" 2dpoints)
(setvar "3dosmode" 3dpoints)
(command "ucs" "")
)
(defun model ()
(command "ucs" pt1 "")
(command "box" (list 0 0 0) (list wide depth thick))
)
(defun model2 ()
(command "box" (list 0 0 thick) (list thick depth height))
)

0 Likes
Accepted solutions (1)
792 Views
5 Replies
Replies (5)
Message 2 of 6

cadffm
Consultant
Consultant
Accepted solution

Hi,

 

it is because of  ..... there is no function defined with the name  "=nil"

If you would use the VLIDE, you would find your typo easily 😉

 

=nil

 

vs.

 

= nil

 

 

 

OFFtopic

 

NOTE: All what is not true, is nil 😉

 

(or (setq wide (getreal "what is the cabinet lenght (in x):")))
      (setq wide 1.9)
)

 

 

vlide-color.PNG

 

Sebastian

Message 3 of 6

moreira.jose
Participant
Participant

thank you... i feel like an idiot

0 Likes
Message 4 of 6

cadffm
Consultant
Consultant

Everyone has experienced this 100 times 😂

Sebastian

0 Likes
Message 5 of 6

ВeekeeCZ
Consultant
Consultant

Untested. See if that could be somehow inspiring.

 

(defun c:cabinet ( / :model :model2 2dpoints 3dpoints)
  
  (defun :model ()
    (command "ucs" pt1 "")
    (command "box" (list 0 0 0) (list wide depth thick)))
  
  (defun :model2 ()
    (command "box" (list 0 0 thick) (list thick depth height)))
  
  
  ; ----------------------------------------------------------------------------------------
  
  
  (or *c-wide* 	(setq *c-wide* 1.9))  		; default setting
  (or *c-depth*	(setq *c-depth* 0.32))
  (or *c-height*(setq *c-height* 0.45))
  (or *c-thick*	(setq *c-thick* 0.02))
  
  
  (setq 2dpoints (getvar "osmode"))
  (setq 3dpoints (getvar "3dosmode"))
  
  (if (and (setq pt1 (getpoint "what is the cabinet corner point: "))
	   (setq *c-wide* (cond ((getdist "\nWhat is the cabinet lenght (in x) <" (rtos *c-wide*) ">: "))
				(*c-wide*)))
	   (setq *c-depth* (cond ((getdist "\nWhat is the cabinet depth (in y) <" (rtos *c-depth*) ">: "))
				 (*c-depth*)))
	   (setq *c-height* (cond ((getdist "\nWhat is the cabinet height (in z) <" (rtos *c-height*) ">: "))
				  (*c-height*)))
	   (setq *c-thick* (cond ((getdist "\nWhat is the  material section <" (rtos *c-thick*) ">: "))
				 (*c-thick*)))
	   )
    (progn
      (setvar "osmode" 0)
      (setvar "3dosmode" 0)
      (:model)
      (:model2)
      (setvar "osmode" 2dpoints)
      (setvar "3dosmode" 3dpoints)
      (command "ucs" "")))
  
  (princ)
  )

 

0 Likes
Message 6 of 6

Sea-Haven
Mentor
Mentor

Your welcome to modify this, very close.

 

SeaHaven_0-1650592785549.png

 

; Getvals multi allows multiple line inputs with an image must be a slide image
; By Alan H Oct 2019
; code examples


; Example Code to use sldie name is furntable
; (if (not AH:getvalsimg)(load "Multi Getvals img.lsp"))
; (setq ans (AH:getvalsimg "D:\\Acadtemp\\furntable" 40 (list "Enter table size" "Enter length" 5 4 "1200" "Enter width" 5 4 "900" "Table thickness" 5 4 "30" "Enter height" 5 4 "900" "Enter Leg size" 5 4 "100")))


(defun AH:getvalsimg (img_name siz dcllst / x y num fo fname keynum key_lst v_lst)
(setq num (/ (- (length dcllst) 1) 4))
(setq x 0)
(setq y 0)
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
;(setq fo (open (setq fname "d:\\acadtemp\\alantest.dcl") "w"))
(write-line "getvalsimg : dialog {" fo)
(write-line (strcat "label =  " (chr 34) (nth 0 dcllst) (chr 34) "  ; ") fo)
(write-line " : row {" fo)
(write-line "spacer ;" fo)
(write-line "  : column {" fo)
(write-line "spacer ;" fo)
(write-line "  : icon_image { " fo)
(write-line (strcat "  width =" (rtos siz 2 0) " ;") fo)
(write-line "  aspect_ratio = 1.0 ;" fo)
(write-line  (strcat "key = " (chr 34)  "Ah_img"  (chr 34) " ;") fo)
(write-line "  }" fo)
(write-line "  }" fo)
(write-line " : boxed_column {" fo)
(write-line "  width = 22 ;" fo)
(write-line "spacer_1 ;" fo)
(repeat num
(write-line ": edit_box {" fo)
(setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0)))
(write-line (strcat "    key = " (chr 34) keynum (chr 34) ";") fo)
(write-line (strcat " label = " (chr 34) (nth (+ x 1) dcllst) (chr 34) ";") fo)
(write-line (strcat "     edit_width = " (rtos (nth (+ x 2) dcllst) 2 0) ";") fo)
(write-line (strcat "     edit_limit = " (rtos (nth (+ x 3) dcllst) 2 0) ";") fo)
(write-line "   is_enabled = true ;" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(setq x (+ x 4))
)
(write-line "    }" fo)
(write-line "    }" fo)
(write-line "spacer_1 ;" fo)
(write-line "ok_only;}" fo)
(close fo)

  (setq dcl_id (load_dialog fname))
  (if (not (new_dialog "getvalsimg" dcl_id))
    (exit)
  )
  (setq x 0)
  (setq y 0)
  (setq v_lst '())
  (repeat num
    (setq keynum (strcat "key" (rtos (setq y (+ Y 1)) 2 0)))
    (setq key_lst (cons keynum key_lst))
    (set_tile keynum (nth (setq x (+ x 4)) dcllst))
    (mode_tile keynum 3)
  )

      (start_image "Ah_img")
      (slide_image  0 0 (- (dimx_tile "Ah_img") 1) (- (dimy_tile "Ah_img") 1) img_name)
      (end_image)

  (action_tile "accept" "(mapcar '(lambda (x) (setq v_lst (cons (get_tile x) v_lst))) key_lst)(done_dialog)")
  (start_dialog)
  (unload_dialog dcl_id)
  (vl-file-delete fname)

  (princ v_lst)
)

 your welcome to modify this to suit.

 

(if (not AH:getvalsimg)(load "Multi Getvals img.lsp"))
(setq ans (AH:getvalsimg "D:\\Acadtemp\\furntable" 40 (list "Enter table size" "Enter length" 5 4 "1200" "Enter width" 5 4 "900" "Table thickness" 5 4 "30" "Enter height" 5 4 "900" "Enter Leg size" 5 4 "100")))

(setq len (atof (nth 0 ans))
wid  (atof (nth 1 ans))
thick (atof (nth 2 ans))
Ht (atof (nth 3 ans))
leg (atof (nth 4 ans))
)