definition could not be loaded

definition could not be loaded

qkakkel
Contributor Contributor
5,950 Views
40 Replies
Message 1 of 41

definition could not be loaded

qkakkel
Contributor
Contributor

What goes wrong I try to load a lisp file but I get the message definition could not be loaded.

I am still a newbee with lisp!

 

(defun C:SAMPLE33 ()

(defun saveVars (/ readlist count item)

;;;---Setup a list to hold the selected items
(setq retlist (list))

;;;---Save the list setting
(setq readlist (get_tile "myList1"))

;;;---Setup a variable to run through the list
(setq count 1)

;;;---cycle through the list getting all of the selected items
(while (setq item (read readlist))
(setq retlist2 (append retList2 (list (nth item myList1))))
(while
(and
(/= "" (substr readlist count 1))
(/= "" (substr readList count 1))
)
(setq count (1+ count))
)
(setq readlist (substr readlist count))
)
;;;---Setup a list to hold the selected items
(setq retList2 (list))

;;;---Save the list setting
(setq readlist (get_tile "myList2"))

;;;---Setup a variable to run through the list
(setq count 1)

;;;---cycle through the list getting all of the selected items
(while (setq item (read readList))
(setq retlist2 (append retList2 (list (nth item mylist2))))
(while
(and
(/= " " (substr readlist count 1))
(/= "" (substr readlist count 1))
)
(setq count (1+ count))
)
(setq readlist (substr readlist count))
)
)


(setq myList1 (list "Electrical" "Structual" "Plumbing" "Foundation"))
(setq myList2 (list "Plastic" "Steel" "Aluminium" "Concrete"))

;;;---Load the dcl file from disk into memory
(if (not (setq dcl_id (load_dialog "SAMPLE33.dcl")))
(progn
(alert "The DCL file could not be loaded!")
(exit)
)

;;;---Else, the DCL file was loaded
(progn

 

;;;---Load the dialog definition inside the DCL file
(if (not (new_dialog "SAMPLE33" dcl_id))
(progn
(alert "The SAMPLE33 definition could not be loaded!")
(exit)
)

;;;---Else, the definition was loaded
(progn

(start_list "myList1" 3)
(mapcar 'add_list myList1)
(end_list)

(start_list "myList2" 3)
(mapcar 'add_list myList2)
(end_list)

;;;---if an action event occurs, do this function
(action_tile "accept" "(saveVars)(done_dialog 2)")
(action_tile "cancel" "done_dialog 1)")

;;;---Display the dialog box
(setq ddiag (start_dialog))

;;;---Unload the dialog box
(unload_dialog dcl_id)

;;;---if the user pressed the Cancel button
(if (= ddiag 1)
(princ "\n Sample33 cancelled!")
)

;;;---if the user pressed the Okay button
(if (= ddiag 2)
(progn


;;;---Inform the user of his selection from the first list
(princ (strcat "\n You chose "
(car retList)
"from the
first list box."
)
)

;;;---Inform the user of his selection from the second list
(princ "\n Your choise(s) from the second list box: ")
(foreach a retList2
(princ "\n ")
(princ a)
)
)
)

;;;;---Suppress the last echo for a clean exit
(princ)

)
)
)
)
)

 

0 Likes
Accepted solutions (1)
5,951 Views
40 Replies
Replies (40)
Message 21 of 41

paullimapa
Mentor
Mentor

Looks like you may have another sample33.lsp file AutoCAD may be loading. Since you’ve already added your new folder to support and trusted paths do this at the AutoCAD command prompt

(findfile “sample33.lsp”)

now see where AutoCAD actually locates that file. If it’s somewhere else then delete that occurrence and then repeat the above code until it shows as the folder where you’ve saved it. Then finally do

(load”sample33”)

sample33


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 22 of 41

qkakkel
Contributor
Contributor
I think I surrender this is the answer from the command prompt.
By the way are not sleeping I see you live in California I guess it is night on your side of the ocean?

Command: (findfile “sample33.lsp”)
; error: bad argument type: stringp nil
Command: (findfile “sample33.lsp”)
; error: bad argument type: stringp nil
Command:
0 Likes
Message 23 of 41

paullimapa
Mentor
Mentor

It’s 8am morning in California 

looks like your AutoCAD crashed. Close AutoCAD and relaunch and try those commands again.  Also send a screenshot of how you set the new folder in the AutoCAD support search path under Options


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 24 of 41

qkakkel
Contributor
Contributor
This is the pdf file where al the samples are in .
I am disappointed in people that post things on the net that don’t work.
I attemped the samples from 1 to 5 and not one is working.




0 Likes
Message 25 of 41

paullimapa
Mentor
Mentor

no attachment


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 27 of 41

paullimapa
Mentor
Mentor
Accepted solution

that link goes to a web page that shows:

Expired Error! ...

Since you have the pdf, why don't you open your web browser, go to this forum, reply, then just drag & drop the pdf file in?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 28 of 41

qkakkel
Contributor
Contributor
Good idea the whole pdf file is on the forum, I will take a look to find it.
0 Likes
Message 29 of 41

qkakkel
Contributor
Contributor

Sorry but where can I find it?

0 Likes
Message 30 of 41

paullimapa
Mentor
Mentor

I have no idea. Do you or do you not have the pdf file?  If you don’t have it then we cannot help you. If you do have it then like my response earlier in order for you to post it as an attachment don’t use email. You have to use your web browser to access this AutoCAD forum to post the pdf attachment 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 31 of 41

qkakkel
Contributor
Contributor

pdf file

0 Likes
Message 32 of 41

qkakkel
Contributor
Contributor

Sorry didn't read the message not good

0 Likes
Message 33 of 41

Moshe-A
Mentor
Mentor

@qkakkel ,

 


@qkakkel wrote:
I think I surrender this is the answer from the command prompt.
By the way are not sleeping I see you live in California I guess it is night on your side of the ocean?

Command: (findfile “sample33.lsp”)
; error: bad argument type: stringp nil
Command: (findfile “sample33.lsp”)
; error: bad argument type: stringp nil
Command:

According to this, there is a call to some function outside (c:sample33) function and that's why you are getting an error. as soon as lsp file is loaded, autocad auto run any expression that are outside (defun ...) functions.

 

i suggest this:

attach your files that you are using (do not copy & paste them). bare in mind that yesterday i checked these files (and post them back with minor correction) and they are OK load and run.

make sure that these files (sample33.lsp + sample33.dcl) are the only files found on your disk and your autocad

knows how to find them.

 

Moshe

 

0 Likes
Message 34 of 41

paullimapa
Mentor
Mentor

the error you're receiving when you attempt to load has to do with using the incorrect quote symbols

when I do the same I get the same error:

Command: (findfile “sample33.lsp”)
; error: bad argument type: stringp nil
Command: (findfile"sample33.lsp") --- this one is correct


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 35 of 41

paullimapa
Mentor
Mentor

There's nothing wrong with the instructions provided in the pdf file. The problem occurs when you type the code from the pdf pages onto a computer file (lsp or dcl). With coding, every punctuation needs to be placed exactly otherwise it'll fail.  Just like using the correct quotation symbol ["] to successfully load a function, proper placement of parenthesis which includes open "(" vs close ")" is absolutely important.

For example, one of the lines of the code you typed up shows this:

(action_tile "cancel" "done_dialog 1)") 
But it is missing an open parenthesis "(" so the function fails. 
The correct line of code is this:
(action_tile "cancel" "(done_dialog 1)")
So your sample33.lsp & sample33.dcl are filled with llittle errors like this causing the code to fail.
I've again modified the code so that the dcl is now written on the fly when the function runs and you no longer need to have a separate dcl file for sample33 to successfully run.
I've also added the ability for you to select multiple items from the list boxes.
When the code loads and runs successfully it'll look like this:
paulli_apa_1-1667160554985.png

So open the attached zip file, save Sample33.lsp to your new folder overwrting the old file. You can also delete Sample33.dcl. Then in AutoCAD properly type the quotes to load it:

(load"Sample33")

Sample33

 

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 36 of 41

qkakkel
Contributor
Contributor
Thank you for your help as I mentioned I am still learning.
0 Likes
Message 37 of 41

paullimapa
Mentor
Mentor

Sure you are welcome we all have a humble beginning when we first start learning so just keep at it..,cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 38 of 41

qkakkel
Contributor
Contributor
I have one more question (I am still a newbie)
What am I doing wrong ?
I am trying to get sample 7 to work but I still get the message ; error: malformed string on input.

On the last line (setvar “users4”sStr)

;;;---See if we need to save settings
as defaults
(if(=saveSet 1)
(progn
(setvar "USERS1" radios)
(setvar "USERS2" numStr)
(setvar "USERS3" (itoa saveSet))
(setvar "USERS4" sSTR)


Thanks in advance

Aad

0 Likes
Message 39 of 41

paullimapa
Mentor
Mentor

please post the sample 7 lisp & dcl code you've typed out


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 40 of 41

qkakkel
Contributor
Contributor

 

I have one more question (I am still a newbie)

What am I doing  wrong ?

I am trying to get sample 7 to work but I still get the message ; error: malformed string on input.

 

On the last  line (setvar “users4”sStr)

 

;;;---See if we need to save settings

                               as defaults

                               (if(=saveSet 1)

                                 (progn

                               (setvar "USERS1" radios)

                               (setvar "USERS2" numStr)

                               (setvar "USERS3" (itoa saveSet))

                               (setvar "USERS4" sSTR)

 

 

Thanks in advance

 

Aad

0 Likes