View Full Version : LISP routine not working in AutoCAD 2007, but does in 2000
esaffle
2007-03-08, 10:02 PM
Hey folks, this is my first time posting to this forum. I have been migrating our company from ACAD 2000 to 2007 for the last month. Just kind of doing it on the side while trying to get some work done. Anyways, I found your site through Autodesk itself and I have found it to be priceless in aiding me with my problems.
Until now, I have been able to find the solutions already posted. But this one is getting me. I am learning pretty quickly how to do lsp routines. But I can't get this one. I will attach the routine later, but here is the error I am receiving.
"Command: shim
Enter Thickness: 2
Enter Width: 2
Insert point: ; error: bad argument type: numberp: nil"
I am trying to make a "shim".
Below is the routine. Can anybody help me figure out why this works without fail in ACAD 2000, but fails everytime in 2007? Thanks!
Hey folks, this is my first time posting to this forum. I have been migrating our company from ACAD 2000 to 2007 for the last month. Just kind of doing it on the side while trying to get some work done. Anyways, I found your site through Autodesk itself and I have found it to be priceless in aiding me with my problems.
Until now, I have been able to find the solutions already posted. But this one is getting me. I am learning pretty quickly how to do lsp routines. But I can't get this one. I will attach the routine later, but here is the error I am receiving.
"Command: shim
Enter Thickness: 2
Enter Width: 2
Insert point: ; error: bad argument type: numberp: nil"
I am trying to make a "shim".
Below is the routine. Can anybody help me figure out why this works without fail in ACAD 2000, but fails everytime in 2007? Thanks!
It looks like you are missing the halfpi variable. Maybe replace it with (/ pi 2)
Also, instead of setting pt1 through pt4 nil at the end, why not declair them as local:
(defun c:shim ( / pt1 pt2 pt3 pt4)......
HTH
Edit: BTW, welcome to AUGI :)
kennet.sjoberg
2007-03-08, 10:31 PM
LSP routine not working in 2007, but does in 2000...
It may depends on that your code is unsafe and all your variables are left as global
you may have an other routine in 2000 that left the halfpi variable garbaging around in the environment that this code use.
Please try to define your variables as local to avoid conflicts in other programs, like
(defun C:shim (/ thick width pt1 pt2 pt3 pt4 A B )
: ) Happy Computing !
kennet
Please try to define your variables as local to avoid conflicts in other programs, like
(defun C:shim (/ thick width pt1 pt2 pt3 pt4 A B )
kennet
Dang, I forgot to include those. Thanks, Kennet. :beer:
Adesu
2007-03-09, 12:59 AM
Hi esaffle,
test this code again.
(defun c:shim (/ a b halfpi pause pt1 pt2 pt3 pt4 thick width)
(setq thick (getdist "\nEnter thickness: "))
(setq width (getdist "\nEnter width: "))
(initget 1)
(setq pt1 (getpoint "\nInsert point: "))
(setq pt2 (polar pt1 0 thick))
(setq halfpi (/ pi 2.0))
(setq pt3 (polar pt2 halfpi width))
(setq pt4 (polar pt1 halfpi width))
;(command "_clayer" "s" "wood" "")
(setvar "clayer" "wood")
(command "pline" pt1 "w" "0" "" pt2 pt3 pt4 pt1 "")
(setq a (entlast))
;(command "_layer" "s" "0" "")
(setvar "clayer" "0")
(command "_pline" pt1 "w" "0" "" pt3 "")
(setq b (entlast))
;(command "_rotate" a b "" pt1 pause)
(command "_rotate" a b "" pt1)
(princ)
)
Hey folks, this is my first time posting to this forum. I have been migrating our company from ACAD 2000 to 2007 for the last month. Just kind of doing it on the side while trying to get some work done. Anyways, I found your site through Autodesk itself and I have found it to be priceless in aiding me with my problems.
Until now, I have been able to find the solutions already posted. But this one is getting me. I am learning pretty quickly how to do lsp routines. But I can't get this one. I will attach the routine later, but here is the error I am receiving.
"Command: shim
Enter Thickness: 2
Enter Width: 2
Insert point: ; error: bad argument type: numberp: nil"
I am trying to make a "shim".
Below is the routine. Can anybody help me figure out why this works without fail in ACAD 2000, but fails everytime in 2007? Thanks!
esaffle
2007-03-09, 01:21 PM
Thank you all so much for your help. Adesu, I just ignorantly took your code and inserted it into the lsp, and it worked great. Now I will begin the process of trying to understand the reasoning for why it wasn't working. You guys posted some great information in such a short time. Thanks!! I know I will continue to visit this site, daily!!!
Do you have any suggestions as to a great instructional manual for lsp writing/editing? I found some good sites through some earlier posts. But I was just curious of some had been updated.
Also, any suggestions on a good text editing program to write/edit lsp?
Thanks again for all of your help. The boss is happy!!
abdulhuck
2007-03-11, 09:05 AM
Do you have any suggestions as to a great instructional manual for lsp writing/editing?
I think you must have seen these two threads in the beginning of the forum.
http://forums.augi.com/showthread.php?t=42122
http://forums.augi.com/showthread.php?t=4657
These have links to a lot of resources to learn Lisp.
Also, any suggestions on a good text editing program to write/edit lsp?
The Visual Lisp Editor within AutoCAD is the best one (type VLIDE in command prompt). But I have seen some people are using different text editor program. Hang on here, they will come up with their favourite editors...
Regards,
Abdul Huck
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.