TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: kameron1967 on February 02, 2011, 11:33:20 AM
-
Can anyone tell me why I'm getting this error on just a simple lisp?
Command: KA
Unknown command "F". Press F1 for help.
Unknown command "*KEYPLAN|*PATT-*". Press F1 for help.
Unknown command "KA". Press F1 for help.
Unknown command "F". Press F1 for help.
Unknown command "X*|S-GRID*MAT**". Press F1 for help.
Unknown command "KA". Press F1 for help.
Unknown command "T". Press F1 for help.
Unknown command "*KEYPLAN|*PATT-A". Press F1 for help.
Unknown command "KA". Press F1 for help.
Unknown command "T". Press F1 for help.
Unknown command "X*|S-GRID*MAT*-A". Press F1 for help.
Unknown command "KA". Press F1 for help.
Unknown command "T". Press F1 for help.
Unknown command "*KEYPLAN|*PATT-NOTE". Press F1 for help.
Unknown command "KA". Press F1 for help.
THIS IS THE CODE FOR KA.LSP
(defun c:KA ()
(command "layer" "f" "*keyplan|*patt-*" "")
(command "layer" "f" "X*|s-grid*mat**" "")
(command "layer" "T" "*keyplan|*patt-A" "")
(command "layer" "T" "X*|s-grid*mat*-A" "")
(command "layer" "T" "*keyplan|*patt-NOTE" "")
(princ)
)
[\CODE]
-
"-layer"
you forgot the hyphen, and you can shorten it up...
(defun c:KA ()
(command "-layer"
"f" "*keyplan|*patt-*"
"f" "X*|s-grid*mat**"
"T" "*keyplan|*patt-A"
"T" "X*|s-grid*mat*-A"
"T" "*keyplan|*patt-NOTE"
"")
(princ)
)
-
Also, have you tried entering each line directly into the command line to see if you get the same error?
For instance:
Command: (command "layer" "f" "*keyplan|*patt-*" "")
This is what I got...
Command: (command "layer" "f" "*keyplan|*patt-*" "")
Unknown command "F". Press F1 for help.
Unknown command "*KEYPLAN|*PATT-*". Press F1 for help.
nil
Do you suppose the autocad utility is not being loaded..?? Like acaddoc.lsp, etc..??
-
Also, have you tried entering each line directly into the command line to see if you get the same error?
For instance:
Command: (command "layer" "f" "*keyplan|*patt-*" "")
This is what I got...
Command: (command "layer" "f" "*keyplan|*patt-*" "")
Unknown command "F". Press F1 for help.
Unknown command "*KEYPLAN|*PATT-*". Press F1 for help.
nil
Do you suppose the autocad utility is not being loaded..?? Like acaddoc.lsp, etc..??
um, did you look at the post above this one that I am quoting? :?
-
and you can shorten it up...
(defun c:KA (/)
(command "_.-layer" "_freeze" "*keyplan|*patt-*,X*|s-grid*mat*,*keyplan|*patt-A" "_thaw"
"X*|s-grid*mat*-A,*keyplan|*patt-NOTE" ""
)
(princ)
)
-
and you can shorten it up...
(defun c:KA (/)
(command "_.-layer" "_freeze" "*keyplan|*patt-*,X*|s-grid*mat*,*keyplan|*patt-A" "_thaw"
"X*|s-grid*mat*-A,*keyplan|*patt-NOTE" ""
)
(princ)
)
:roll: i would have gotten there eventually... :wink:
-
and you can shorten it up...
(defun c:KA (/)
(command "_.-layer" "_freeze" "*keyplan|*patt-*,X*|s-grid*mat*,*keyplan|*patt-A" "_thaw"
"X*|s-grid*mat*-A,*keyplan|*patt-NOTE" ""
)
(princ)
)
:roll: i would have gotten there eventually... :wink:
I know. :)
VL option (runs transparently)...(defun c:KA (/ name)
(vl-load-com)
(vlax-for x (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
(and (wcmatch (setq name (strcase (vla-get-name x)))
"*KEYPLAN|*PATT-*,X*|S-GRID*MAT*,*KEYPLAN|*PATT-A"
)
(vla-put-freeze x :vlax-true)
)
(and (wcmatch name "X*|S-GRID*MAT*-A,*KEYPLAN|*PATT-NOTE") (vla-put-freeze x :vlax-false))
)
(princ)
)
-
Vanilla method :wink:
(defun c:ka ( / _FreezeThawLayer frzestring thawstring layerdef layer )
(setq frzestring "*keyplan|*patt-*,X*|s-grid*mat*,*keyplan|*patt-A"
thawstring "X*|s-grid*mat*-A,*keyplan|*patt-NOTE"
)
(defun _FreezeThawLayer ( layer freeze )
(if (setq layer (tblobjname "LAYER" layer))
( (lambda ( elist ) (entmod (subst (cons 70 (boole (if freeze 7 4) 1 (cdr (assoc 70 elist)))) (assoc 70 elist) elist)))
(entget layer)
)
)
)
(while (setq layerdef (tblnext "LAYER" (null layerdef)))
(setq layer (cdr (assoc 2 layerdef)))
(cond
( (wcmatch layer frzestring)
(_FreezeThawLayer layer t)
)
( (wcmatch layer thawstring)
(_FreezeThawLayer layer nil)
)
)
)
(princ)
)
-
Love it when the programming gurus get together. Unfortunately, it has not solved my initial problem. :lol:
-
Lee, so if I have sectors A-K, how I can do this in one routine - without copying over and over to make one for each sector? Thanks!
Vanilla method :wink:
(defun c:ka ( / _FreezeThawLayer frzestring thawstring layerdef layer )
(setq frzestring "*keyplan|*patt-*,X*|s-grid*mat*,*keyplan|*patt-A"
thawstring "X*|s-grid*mat*-A,*keyplan|*patt-NOTE"
)
(defun _FreezeThawLayer ( layer freeze )
(if (setq layer (tblobjname "LAYER" layer))
( (lambda ( elist ) (entmod (subst (cons 70 (boole (if freeze 7 4) 1 (cdr (assoc 70 elist)))) (assoc 70 elist) elist)))
(entget layer)
)
)
)
(while (setq layerdef (tblnext "LAYER" (null layerdef)))
(setq layer (cdr (assoc 2 layerdef)))
(cond
( (wcmatch layer frzestring)
(_FreezeThawLayer layer t)
)
( (wcmatch layer thawstring)
(_FreezeThawLayer layer nil)
)
)
)
(princ)
)
-
Love it when the programming gurus get together. Unfortunately, it has not solved my initial problem. :lol:
are you sure? you asked about errors. :-P
Can anyone tell me why I'm getting this error on just a simple lisp?
Command: KA
Unknown command "F". Press F1 for help.
Unknown command "*KEYPLAN|*PATT-*". Press F1 for help.
Unknown command "KA". Press F1 for help.
Unknown command "F". Press F1 for help.
Unknown command "X*|S-GRID*MAT**". Press F1 for help.
Unknown command "KA". Press F1 for help.
Unknown command "T". Press F1 for help.
Unknown command "*KEYPLAN|*PATT-A". Press F1 for help.
Unknown command "KA". Press F1 for help.
Unknown command "T". Press F1 for help.
Unknown command "X*|S-GRID*MAT*-A". Press F1 for help.
Unknown command "KA". Press F1 for help.
Unknown command "T". Press F1 for help.
Unknown command "*KEYPLAN|*PATT-NOTE". Press F1 for help.
Unknown command "KA". Press F1 for help.
THIS IS THE CODE FOR KA.LSP
(defun c:KA ()
(command "layer" "f" "*keyplan|*patt-*" "")
(command "layer" "f" "X*|s-grid*mat**" "")
(command "layer" "T" "*keyplan|*patt-A" "")
(command "layer" "T" "X*|s-grid*mat*-A" "")
(command "layer" "T" "*keyplan|*patt-NOTE" "")
(princ)
)
[\CODE]
-
Vanilla method :wink:
FYI: -Layer is not case sensitive, wcmatch is.
-
Nibster - you're right. I did not try this. The "-layer" does do the track. But I've never had that problem before. Could that be that the "CMDDIA" needs to be set to "0" always, then?
"-layer"
you forgot the hyphen, and you can shorten it up...
(defun c:KA ()
(command "-layer"
"f" "*keyplan|*patt-*"
"f" "X*|s-grid*mat**"
"T" "*keyplan|*patt-A"
"T" "X*|s-grid*mat*-A"
"T" "*keyplan|*patt-NOTE"
"")
(princ)
)
-
Nibster - you're right. I did not try this. The "-layer" does do the track. But I've never had that problem before. Could that be that the "CMDDIA" needs to be set to "0" always, then?
"-layer"
you forgot the hyphen, and you can shorten it up...
(defun c:KA ()
(command "-layer"
"f" "*keyplan|*patt-*"
"f" "X*|s-grid*mat**"
"T" "*keyplan|*patt-A"
"T" "X*|s-grid*mat*-A"
"T" "*keyplan|*patt-NOTE"
"")
(princ)
)
what was your previous ACAD version?