PDA

View Full Version : Lisp routines not loading



stusic
2004-11-05, 07:15 PM
What would cause AutoCAD to not recognize a LISP routine? I loaded it, it says it's loaded, but when I typ ethe command, it says "Unknown command "SPP2". Press F1 for help." The directory where the LISP routine is located is listed in my support paths. Any help would be great.

Ed Jobe
2004-11-05, 07:20 PM
That may not be the actual command name. Open the lsp file in Notepad or in the vlide and the first line should be like:
(defun c:spp2 ()

You need to enter the text that is after "c:". If there is no "c:", then it is not designed to be run at the command line.

CAB2k
2004-11-06, 01:29 AM
But you can run it at the command line if it's (defun spp2
by entering (spp2) at the command prompt. I will name a lisp
(defun long_name and this way I can call the lisp from other lisp
but to run it from the command line I create this lisp to call the other
(defun c:short_name ()
(long_name)
(princ)
)

If nothing else post the lisp here and someone will help you.

stusic
2004-11-08, 02:32 PM
Here is the code I'm working from:


;;; ProjectPaths.LSP
;;; Among other things it can save the paths
;;; to a file that can be imported on another PC.
;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2003 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com / http://jtbworld.vze.com
;;; E-mail: info@jtbworld.com / jtbworld@hotmail.com
;;; Tested on AutoCAD 2000

(vl-load-com)

(defun ReadProject-Settings (cprof)
(vl-registry-descendents
(strcat
"HKEY_CURRENT_USER\\"
(vlax-product-key)
"\\Profiles\\"
cprof
"\\Project Settings"
)
)
)

(defun ReadRefSearchPath (cprof ProjSet)
(vl-registry-read
(strcat
"HKEY_CURRENT_USER\\"
(vlax-product-key)
"\\Profiles\\"
cprof
"\\Project Settings\\"
ProjSet
)
"RefSearchPath"
)
)

;;; Ex: (AllProjPath (getvar "CPROFILE"))
(defun AllProjPath (cprof / lst ProjSet)
(foreach ProjSet (ReadProject-Settings cprof)
(setq lst (cons (cons ProjSet (ReadRefSearchPath cprof ProjSet)) lst))
)
)

;;; Ex: (WriteRefSearchPath (getvar "CPROFILE") "Project1" "c:\temp;c:\project")
(defun WriteRefSearchPath (cprof ProjSet path)
(vl-registry-write
(strcat
"HKEY_CURRENT_USER\\"
(vlax-product-key)
"\\Profiles\\"
cprof
"\\Project Settings\\"
ProjSet
)
"RefSearchPath"
path
)
)

;;; Deletes all Project paths
(defun DeleteRefSearchPath (cprof)
(foreach ProjSet (ReadProject-Settings cprof)
(vl-registry-delete
(strcat
"HKEY_CURRENT_USER\\"
(vlax-product-key)
"\\Profiles\\"
cprof
"\\Project Settings\\"
ProjSet
)
)
)
)

;;; Ex: (WriteAllProjPath (getvar "CPROFILE") (list (cons "Project1" "C:\\") (cons "Project2" "D:\\")))
;;; Deletes all old Paths first
(defun WriteAllProjPath (cprof lst / ProjSet)
(DeleteRefSearchPath cprof)
(foreach ProjSet lst
(WriteRefSearchPath cprof (car ProjSet) (cdr ProjSet))
)
)

;;; Ex: (Print-AllProjPaths (getvar "CPROFILE"))
(defun Print-AllProjPaths (cprof / ProjSet)
(princ "Project Files Search Path:\n")
(foreach ProjSet (ReadProject-Settings cprof)
(princ ProjSet)
(princ " = ")
(princ (ReadRefSearchPath cprof ProjSet))
(terpri)
)
(princ)
)

;;; Change "r:\\paths.txt" to a location on the server
;;; (getProjectPaths "r:\\paths.txt")
(defun C:getProjectPaths (fn / cprof paths f)
(setq cprof (getvar "CPROFILE"))
(setq paths (AllProjPath cprof))
(setq f (open fn "w"))
(foreach ProjSet (ReadProject-Settings cprof)
(write-line ProjSet f)
(write-line (ReadRefSearchPath cprof ProjSet) f)
)
(close f)
)

;;; Change "r:\\paths.txt" to a location on the server
;;; (putProjectPaths "r:\\paths.txt")
(defun C:putProjectPaths (fn / cprof line1 line2 paths f)
(setq cprof (getvar "CPROFILE"))
(setq f (open fn "r"))
(while (and (setq line1 (read-line f)) (setq line2 (read-line f)))
(setq paths (cons (cons line1 line2) paths))
)
(close f)
(WriteAllProjPath cprof paths)
)


I've looked at the line of code eljobe, and i dont' se ewhre you're talking about, unless it's the line that looks like "(defun ReadProject-Settings (cprof)"

This is still that stupid routine i'm working on trying to load Projects with out using a profile....

Y'all have been a great help. Thanks.

Phillip - Lost is relative

CAB2k
2004-11-08, 02:49 PM
Only two choices that are in this routine


(defun C:getProjectPaths
(defun C:putProjectPaths

You may enter at the command line
getProjectPaths or putProjectPaths
There is no spp2. Where did you come up with that name for a command?

LanceMcHatton
2004-11-08, 04:33 PM
I have a lisp that, when I run it, will run just fine the first time. The second time, it'll give me the same error "Unknown command". I'm not the greatest lisp writer, but I've noticed with my lisp that if the lisp can actually perform it's function, it's fine. If it cannot perform it's function, it'll give the error. Bascially, it deletes all raster images from a drawing. If it cannot find any raster images, it's "Unknown command" time.

I know this isn't the best explanation, but it may be that your lisp is running fine. It just can't do what it needs to do because the drawing environment does not contain the characteristics the lisp needs in order to run.

Good luck!

kennet.sjoberg
2004-11-09, 06:39 AM
Hi Lance, You have probably an if statement that is not correct.
IF there is any raster images => delete them.
IF not => cause command error, instead of handling it correct.

: ) Happy Computing !

kennet