AutoCAD/Block with Attributes within AutoLisp
Expert: Bill DeShawn - 10/13/2003
QuestionHallo,
I am Spiros from Greece.
I would like to know if there is a way to use the insertion of a Block with Attributes within an Autolisp Routine (an ATTDIA 1), without causin the routine to End !
This is the code I use :
(setvar "ATTDIA" 1)
(command "insert" Blockname "s" insertscale "r" 0)
(while (= (logand (getvar "CMDACTIVE") 2) 1)
(setvar "cmdecho" 1)
(command pause)
)
..... and it all works til the Block is inserted and the Attributes Dialog is filled, but then the Lisp ends !
I know that the value of 2 is not correct but I had to try something.
The fact is that I am trying to continou the LispRoutine after the insertion, for example with a follow up "alert" but it comes on BEFORE the insertion.
This is the code:
(setvar "ATTDIA" 1)
(command "insert" Blockname "s" insertscale "r" 0)
(while (= (logand (getvar "CMDACTIVE") 2) 1)
(setvar "cmdecho" 1)
(command pause)
)
(alert "pop")
I have also tried:
(command "insert" Blockname "s" insertscale "r" 0 pause) ;;;(or pause 2x)
Could you help me please ?
Thank you very mouch.
AnswerThe alert "pop" was interesting. :) Anyway, the last line made the most sense. Nowhere else did you pause for user input on the insertion point. This problem is probably the same reason that I use the command line version of the INSERT command instead of the dialog version. Since I have been using the command line version of insert in my routines, I have never missed having a dialog box come up with a list of prompts and a bunch of windows to fill with attribute values. You don't have to do any mouse-clicking at the command line.
Try something like this:
(setq oad (getvar "attdia"))
(setvar "attdia" 0)
(setvar atval1 (getstring "\nPut first prompt here: "))
(setvar atval2 (getstring "\nPut second prompt here: "))
(command "_.insert" blockname pause "" "" "" atval1 atval2)
(setvar "attdia" oad)
This way you get prompted at the command line for the attribute values instead of in a dialog box. Then you can continue your routine. If you want a space in the user input attribute value, then include a t after getstring:
(setvar atvalX (getstring T "\nPut a prompt here: "))
Keep in touch
Bill DeShawn
http://my.sterling.net/~bdeshawn