View Full Version : Double "Unknown command" After Routine
stusic
2008-05-02, 07:23 PM
I've got this routine, and it runs fine, but after it executes, I get "Unknown command "IBN"" twice. I can't figure out why it's doing that. Can someone take a look and let me know what they think?
(defun c:insertbundlenumber (/ ss j mode)
(COMMAND "-INSERT" "f:/apps/CCS_CAD/LABEL/1TEN_L" "S" "96" PAUSE PAUSE)
(COMMAND "EXPLODE" "L" "")
(COMMAND "CHPROP" "L" "P" "" "LA" (getvar "clayer") "" "")
(progn
(setq ss (ssadd))
(ssadd (entlast) ss)
(setq mode 0)
(setvar "highlight" 0)
(setq j (bns_trot ss mode))
);progn
(setvar "highlight" 1)
(princ);exit quietly
);defun
;;; SHORTCUT
(DEFUN C:IBN () (C:insertbundlenumber))
Thanks you all,
I've got this routine, and it runs fine, but after it executes, I get "Unknown command "IBN"" twice. I can't figure out why it's doing that. Can someone take a look and let me know what they think?
(defun c:insertbundlenumber (/ ss j mode)
(COMMAND "-INSERT" "f:/apps/CCS_CAD/LABEL/1TEN_L" "S" "96" PAUSE PAUSE)
(COMMAND "EXPLODE" "L" "")
(COMMAND "CHPROP" "L" "P" "" "LA" (getvar "clayer") "" "")
(progn
(setq ss (ssadd))
(ssadd (entlast) ss)
(setq mode 0)
(setvar "highlight" 0)
(setq j (bns_trot ss mode))
);progn
(setvar "highlight" 1)
(princ);exit quietly
);defun
;;; SHORTCUT
(DEFUN C:IBN () (C:insertbundlenumber))Thanks you all,
Why don't you just make your shortcut the command?
If you can't, did you try adding (princ) after it?
stusic
2008-05-02, 07:45 PM
I don't think the shortcut's the problem, as I've tried "insertbundlenumber" and it still gives me the error: "Unknown command "insertbundlenumber"" twice. Lemme comment it out and see what it does...
I don't think the shortcut's the problem, as I've tried "insertbundlenumber" and it still gives me the error: "Unknown command "insertbundlenumber"" twice. Lemme comment it out and see what it does...
Hemm, I don't know. I couldn't test your routine, but just for giggles I added a similar shortcut to one of my routines, and it worked fine with no "unknown command".
Sorry, I don't have an answer. I have seen that before (unknown command) but I don't know what caused it. I think it must be within the main routine.
:beer:
stusic
2008-05-02, 07:50 PM
Yep, still gives the error...
Any other ideas? I'm stumped -- there's only so much code...
stusic
2008-05-02, 07:52 PM
Okay, the trimmed code:
(defun c:insertbundlenumber (/ ss j mode)
(COMMAND "-INSERT" "f:/apps/CCS_CAD/LABEL/1TEN_L" "S" "96" PAUSE PAUSE)
(COMMAND "EXPLODE" "L" "")
(COMMAND "CHPROP" "L" "P" "" "LA" (getvar "clayer") "" "")
(progn
(setq ss (ssadd))
(ssadd (entlast) ss)
(setq mode 0)
(setvar "highlight" 0)
(setq j (bns_trot ss mode))
);progn
(setvar "highlight" 1)
(princ);exit quietly
);defun
I tried running your routine with a drawing I created.
(defun c:IBN (/ ss j mode)
(COMMAND "-INSERT" "c:/lumber" "S" "96" PAUSE PAUSE)
(COMMAND "EXPLODE" "L" "")
(COMMAND "CHPROP" "L" "P" "" "LA" (getvar "clayer") "" "")
(progn
(setq ss (ssadd))
(ssadd (entlast) ss)
(setq mode 0)
(setvar "highlight" 0)
(setq j (bns_trot ss mode))
);progn
(setvar "highlight" 1)
(princ);exit quietly
);defun
What version of AutoCAD are you using?
It returned: "Command: no function definition: BNS_TROT"
Also I get:
Unknown command "LA". Press F1 for help.
Unknown command "0". Press F1 for help.
Unknown command "IBN". Press F1 for help.
Unknown command "IBN". Press F1 for help.
It did, however insert the drawing, what are you trying to achieve with this routine?
stusic
2008-05-02, 08:17 PM
I'm using 2000, so that may be why you aren't getting the BNS_TROT, but LA should work (it's LAYER, after all).
I'm trying to insert this block, then rotate the text in it to horizontal, no matter what the rotation of the block is. It's a stripped-down version of the express tool's "TORIENT" lisp
d_m_hopper
2008-05-02, 08:51 PM
I'm using 2000, so that may be why you aren't getting the BNS_TROT, but LA should work (it's LAYER, after all).
I'm trying to insert this block, then rotate the text in it to horizontal, no matter what the rotation of the block is. It's a stripped-down version of the express tool's "TORIENT" lisp
I can't solve your main issue but if add the * it will explode the block after it is inserted
(COMMAND "-INSERT" "*c:/lumber" "S" "96" PAUSE PAUSE)
then you can remove this line
(COMMAND "EXPLODE" "L" "")
ccowgill
2008-05-05, 12:13 PM
I've got this routine, and it runs fine, but after it executes, I get "Unknown command "IBN"" twice. I can't figure out why it's doing that. Can someone take a look and let me know what they think?
(defun c:insertbundlenumber (/ ss j mode)
(COMMAND "-INSERT" "f:/apps/CCS_CAD/LABEL/1TEN_L" "S" "96" PAUSE PAUSE)
(COMMAND "EXPLODE" "L" "")
(COMMAND "CHPROP" "L" "P" "" "LA" (getvar "clayer") "" "")
(progn
(setq ss (ssadd))
(ssadd (entlast) ss)
(setq mode 0)
(setvar "highlight" 0)
(setq j (bns_trot ss mode))
);progn
(setvar "highlight" 1)
(princ);exit quietly
);defun
;;; SHORTCUT
(DEFUN C:IBN () (C:insertbundlenumber))Thanks you all,
what's the progn for? you only need to use it for an if statement
stusic
2008-05-05, 03:09 PM
what's the progn for? you only need to use it for an if statement
See, that's what happens when someone who doesn't know lisp tries to make things work. As I said, I stripped down the code from the TOPRIENT command, which did involve IF statement(s). When I removed that line (I didn't know what to replace it with), it didn't work anymore. So I left it in...
I can't solve your main issue but if add the * it will explode the block after it is inserted
(COMMAND "-INSERT" "*c:/lumber" "S" "96" PAUSE PAUSE)
Ah, I didn't know that, it's great!
mvsawyer
2008-05-05, 06:10 PM
If you take out the double quotes at the end of the chprop command it should work fine. It think you just have an extra "enter" in there.
What is the BNS_TROT function?
stusic
2008-05-05, 06:27 PM
If you take out the double quotes at the end of the chprop command it should work fine. It think you just have an extra "enter" in there.
BRAVO! :beer:
What is the BNS_TROT function?
Apparently, it's an legacy function. What it means, I have no idea, but the "TROT" seems like "Text ROTation" to me...
mvsawyer
2008-05-05, 06:32 PM
By looking at the command I deduced that it's probably an express bonus tool (BNS = Bonus, TROT = Text rotate). Express Tools was an add-on back in them Acad 2000 days
Glad to help out.
stusic
2008-05-05, 06:45 PM
It's definately an express tool, as i grabbed it out of the ET folder.
As far as the progn... I have no idea how to do this without using an "IF" function... I'd like to make it a proper piece of code, but oh well, it works...
mvsawyer
2008-05-05, 07:10 PM
I'd write it this way:
(defun c:IBN (/ ss j mode)
(setvar "cmdecho" 0)
(COMMAND "-INSERT" "f:/apps/CCS_CAD/LABEL/1TEN_L" "S" "96" PAUSE PAUSE)
(COMMAND "EXPLODE" "L")
(COMMAND "CHPROP" "L" "P" "" "LA" (getvar "clayer") "")
(setq ss (ssadd))
(ssadd (entlast) ss)
(setq mode 0)
(setvar "highlight" 0)
(setq j (bns_trot ss mode))
(setvar "highlight" 1)
(setvar "cmdecho" 1)
(princ);exit quietly
);defun
I added the setvar "cmdecho" so you don't get the commands that the lisp routine throws out. This way all you see is the issuance of the command IBN. You also may wanna add some error trapping since the user can hit escape resutling in a "Error: Function canceled" message.
Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)
stusic
2008-05-05, 07:16 PM
I'd write it this way:
(defun c:IBN (/ ss j mode)
(setvar "cmdecho" 0)
(COMMAND "-INSERT" "f:/apps/CCS_CAD/LABEL/1TEN_L" "S" "96" PAUSE PAUSE)
(COMMAND "EXPLODE" "L")
(COMMAND "CHPROP" "L" "P" "" "LA" (getvar "clayer") "")
(setq ss (ssadd))
(ssadd (entlast) ss)
(setq mode 0)
(setvar "highlight" 0)
(setq j (bns_trot ss mode))
(setvar "highlight" 1)
(setvar "cmdecho" 1)
(princ);exit quietly
);defun
I added the setvar "cmdecho" so you don't get the commands that the lisp routine throws out. This way all you see is the issuance of the command IBN. You also may wanna add some error trapping since the user can hit escape resutling in a "Error: Function canceled" message.
In the code above, where does it rotate the text if you remove the "bns_trot"?
I've added the CMDECHO (I was trying to remember what that was), but no nothing about error trapping except the fact that I need it...
Thanks for all of your help. :beer:
mvsawyer
2008-05-05, 07:38 PM
I just copy/pasted from my text file. I put the semi-colon in front of that line because it hung up the lisp when I ran it on my machine. My mistake.
Error Trapping:
Basically you are just saving the ACAD error and redefining it while the program runs then setting it back before the lisp exits.
1. add the olderr variable
2. set the *error* function
3. reset to olderr at end of program
(defun c:IBN (/ ss j mode olderr)
(setvar "cmdecho" 0)
(setq olderr *error*); save copy of ACAD error
(defun *error* (msg)
(if (= msg "Function cancelled"); user presses escape
(princ); do nothing
(princ (strcat "Error: " str)); print error string
);if
(setvar "cmdecho" 1)
(setvar "highlight" 1)
); end of error
(COMMAND "-INSERT" "f:/apps/CCS_CAD/LABEL/1TEN_L" "S" "96" PAUSE PAUSE)
(COMMAND "EXPLODE" "L")
(COMMAND "CHPROP" "L" "P" "" "LA" (getvar "clayer") "")
(setq ss (ssadd))
(ssadd (entlast) ss)
(setq mode 0)
(setvar "highlight" 0)
(setq j (bns_trot ss mode))
(setq *error* olderr); set back to ACAD error
(setvar "highlight" 1)
(setvar "cmdecho" 1)
(princ);exit quietly
);defun
Moderator Note:
Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)
stusic
2008-05-05, 07:58 PM
Very cool.
So that's error trapping huh? I'm assuming I can use that as a template for my other routines, replacing the variables with whatever ones I use?
stusic
2008-05-05, 08:16 PM
One more small question if you will...
I noticed that when I UNDO thsi routine, it undoes everything one at a time. Can I use the MARK option of UNDO to just undo it all, or is there a better way to this?
Thanks! (again)
mvsawyer
2008-05-05, 08:17 PM
Yep! Error trapping is just a way to say to Autocad "If there's an error run all these commands before exiting." It's an essential part of the lisp.
stusic
2008-05-05, 08:29 PM
Excellent, thanks. For everything. ;)
mvsawyer
2008-05-05, 08:39 PM
Yes. Just set an undo beginning and end. Add (command "undo" "be") after the cmdecho line. Then add (command "undo" "e") before the cmdecho line at the end of the routine and in the error trap. You have to always remember that anything you set back at the end of the lisp you'll also want to set back in the error trap.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.