Error: bad argument type: consp nil

Error: bad argument type: consp nil

Anonymous
Not applicable
3,226 Views
5 Replies
Message 1 of 6

Error: bad argument type: consp nil

Anonymous
Not applicable

Hello! Thank you ahead of time for anyone who spends any time looking at this. I am currently trying to have my routine identify the customer and send a .dwf to the appropriate reviewer. I can make everything work when I don't have the if statement:

(if (eq pval1 "OPERATIONS")...

 

I'm trying to use the if statement to decide which folder to send to. As soon as I run the LISP though, I get "Error: bad argument type: consp nil". Any help or suggestions would be highly appreciated and recognized. Thank you.

 

(defun c:MODDWF ( / file ;file name for TEMP.DSD
OldFda ;system variable FILEDIA
pathtxt ;path where drawing is saved to write TEMP.DSD
nosheets ;number of PDF pages to print
*error* ;error trap
) ;end variables

(vl-load-com)

(cb:writetotext "mod" "MODDWF" )

(defun steal:listbox ( title lst / *error* dch des tmp res )

(defun *error* ( msg )
(if (< 0 dch)
(unload_dialog dch)
)
(if (= 'file (type des))
(close des)
)
(if (and (= 'str (type tmp)) (setq tmp (findfile tmp)))
(vl-file-delete tmp)
)
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(princ)
)

(cond
( (not
(and
(setq tmp (vl-filename-mktemp nil nil ".dcl"))
(setq des (open tmp "w"))
(write-line
(strcat
"listbox : dialog { label = \""
title
"\"; spacer; : list_box { key = \"list\"; multiple_select = false"
"; } spacer; ok_cancel; }"
)
des
)
(not (close des))
(< 0 (setq dch (load_dialog tmp)))
(new_dialog "listbox" dch)
)
)
(prompt "\nError loading Steal list box.")
)
( t
(start_list "list")
(foreach item lst (add_list item))
(end_list)
(setq res (set_tile "list" "0"))
(action_tile "list" "(setq res $value)")
(setq res
(if (= 1 (start_dialog))
(mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" res ")")))
)
)
)
)
(if (< 0 dch)
(setq dch (unload_dialog dch))
)
(if (and (= 'str (type tmp)) (setq tmp (findfile tmp)))
(vl-file-delete tmp)
)
res
)

;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

(setq si (vla-Get-SummaryInfo (vla-Get-ActiveDocument (vlax-Get-Acad-Object))))

(vla-GetCustomByKey si "customer" 'pval1)
(vla-GetCustomByKey si "Site Name1" 'pval2)
(vla-GetCustomByKey si "state" 'pval3)
(vla-GetCustomByKey si "Project Number" 'pval4)

;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

(if (eq pval1 "OPERATIONS")

((setq tmp (vl-remove-if '(lambda (x) (or (eq x ".") (eq x ".."))) (vl-directory-files "c:/Operations" NIL -1)))
(if (not (eq nil (setq file (steal:listbox "Select Detail File:" tmp))))
(setq openfileLoc (strcat "C:\\Operations\\" (car file) "\\"))
))

((setq tmp (vl-remove-if '(lambda (x) (or (eq x ".") (eq x ".."))) (vl-directory-files "C:/Structural" NIL -1)))
(if (not (eq nil (setq file (steal:listbox "Select Detail File:" tmp))))
(setq openfileLoc (strcat "C:\\Structural\\" (car file) "\\"))
)))

;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

0 Likes
Accepted solutions (1)
3,227 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Sorry, the code I'm referring to is right under the single row of ;XXXX's near the end

0 Likes
Message 3 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

You've used wrong syntax of if... this as written looks like you wanted use cond.

Message 4 of 6

Anonymous
Not applicable

I think you're exactly right BeekeeCZ. Thank you! I'll update with the results. 

0 Likes
Message 5 of 6

Anonymous
Not applicable

got it! Thanks a ton!

0 Likes
Message 6 of 6

ВeekeeCZ
Consultant
Consultant

Glad to help 🙂

0 Likes